Code Monkey home page Code Monkey logo

fitzflix's Introduction

fitzflix

A media library manager. Fitzflix was created by Glenn Fitzpatrick so he would know what was in his family's library when browsing for movies at thrift shops, and to keep track of his movie reviews.

Screen Shot 2022-05-31 at 11 50 36 AM

Fitzflix takes video files for movies and TV shows, uploads to AWS S3 Glacier Deep-Archive storage for backup, sorts them into a Plex-compatible folder hierarchy, removes non-native languages and subtitles to save space, and lets you easily see what movies and TV shows you have in your library and in what formats to help upgrade their quality.

Files named like these…

Screen Shot 2022-05-31 at 11 59 46 AM

…become sorted like so…

Screen Shot 2022-05-31 at 12 05 56 PM

…and are displayed in the application as…

Screen Shot 2022-05-31 at 11 55 06 AM

Screen Shot 2022-05-31 at 12 15 25 PM

…and show associated information from TMDb:

Screen Shot 2022-05-31 at 11 53 15 AM

It supports reviewing films to help keep track of what you've seen:

Screen Shot 2022-05-31 at 11 56 40 AM

It also supports TV shows:

Screen Shot 2022-05-31 at 11 56 13 AM

And makes a great shopping list for searching for films that aren't as good as they could be (e.g. finding non-fullscreen versions of films, upgrading from DVD to Blu-Ray, etc.):

Screen Shot 2022-05-31 at 11 55 31 AM

How to use

TODO

Installation

python3 -m venv venv &&
source venv/bin/activate &&
pip install -r requirements.txt &&
pip install gunicorn pymysql &&
flask db upgrade

Running via supervisor

Update command, directory, and user fields in fitzflix_supervisor.ini file with installation and user information.

brew install supervisor &&
cp fitzflix_supervisor.ini /opt/homebrew/etc/supervisor.d/ &&
brew services start supervisor

Running Manually

Redis

Scheduler

source venv/bin/activate &&
rqscheduler

Workers

Run a max of 1 SQL worker so database operations are properly serialized.

source venv/bin/activate &&
rq worker fitzflix-sql

Vary the number of following workers according to needs:

source venv/bin/activate &&
rq worker fitzflix-user-request
source venv/bin/activate &&
rq worker fitzflix-import fitzflix-file-operation
source venv/bin/activate &&
rq worker fitzflix-transcode fitzflix-import fitzflix-file-operation
source venv/bin/activate &&
rq worker fitzflix-file-operation fitzflix-import

Flask

flask run

fitzflix's People

Contributors

dependabot[bot] avatar gfitzp avatar

Stargazers

 avatar

Watchers

 avatar  avatar

fitzflix's Issues

Add option to manually import files from import directory

I'm not entirely certain but it feels like when I try to have files in the Import directory added on first startup, that it also delays any background tasks as they also try to import when they start up. Add a button to the Admin page to scan the Import directory and add any files that aren't currently in the import / localization queue, so it's possible to add those files but not have it performed automatically.

Make updates to Shopping List page

  • Add navigation tabs for small screen
  • Replace spaces in search string with '%' (searching for "Spider Man" should bring up "Spider-Man")
  • Create new list filter to show digital versions without a physical equivalent

Send an email when a physical quality file is replaced

Physical quality files are only deleted when they're being replaced with another physical-quality file. Send an email to the admin when a physical quality file is replaced so they can pull it from their library for selling/donation.

Make updates to Recently Added page

  • Show last week's worth of imports + 10 latest imports regardless of import date
  • Add import date for each entry
  • Add link to movie or TV show/season page
  • Add special feature type
  • Update navigation tabs so it doesn't overflow the screen on small devices

Use actual forms instead of WTForms on auth pages

reset_password_request.html and reset_password.html pages are both using Flask WTForms to generate their forms, but it's incompatible with the current version of Bootstrap.

  • reset_password_request.html
  • reset_password.html

Prevent the watchdog task from the same item to the localization queue multiple times

When the watchdog task finds a file in the import directory, it adds the same file to the localization queue multiple times; it appears to be a side-effect of using gunicorn to run the app via multiple workers. It doesn't appear to harm anything, because the redis worker creates a lock on the file so only a single worker can process it at a time, and if a worker gets the task but the file no longer exists in the import directory, the task is discarded. The only issue this appears to cause is the count of items currently in the queue is inflated by ~4x.

Better handle renaming files already uploaded to AWS

Currently, if a movie changes its title or year, the local file and any uploaded files are renamed to match. The problem is that if the uploaded file has been migrated to Glacier Deep Archive, it can't easily be renamed; it needs to be restored, copied to the new name, and the original upload deleted. Since we're not currently checking the storage class status, we just assume that all the remote files are in Deep Archive, and we get an error when we try to restore one of these files for renaming.

To fix this, for any file that needs to be renamed:

  • Get the current storage class for the uploaded file
  • If the storage class is Standard, copy the file to the new name, delete the original upload, and update the database
  • If the storage class is not Standard, request the file to be restored, and schedule a copy/delete/database update task in the future

Create an actual Index page

Right now the index page is the Recently Added page; there should be a user-specific Index page with recommendations.

Add quality filter to Movie library

It'd be nice to be able to see all the films I have in a particular quality, whether or not it's the best quality for that film (e.g. see all the films I have on DVD).

Remove AWS files that aren't in the library

  • Get a list of all AWS objects with the untouched/ prefix
  • Search the File table for each object; if it doesn't exist in the File table as aws_untouched_key, delete it from AWS S3 storage

Only show jobs that exist in on the Queue page

Exception on /queue [GET]
Traceback (most recent call last):
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/Users/server/Sites/fitzflix/app/main/routes.py", line 1670, in queue
    job = Job.fetch(job_id, connection=current_app.redis)
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/rq/job.py", line 299, in fetch
    job.refresh()
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/rq/job.py", line 518, in refresh
    raise NoSuchJobError('No such job: {0}'.format(self.key))
rq.exceptions.NoSuchJobError: No such job: b'rq:job:The Owl and the Raven- An Eskimo Legend (1973) - [WEBDL-1080p].mkv'

Create "Name that Frame" game

Show a random frame from a random movie and let the user try to guess what film it's from.

Three levels of difficulty:

  • Easy (select only from movies that have been rated by the user, and provide a limited selection of possible options)
  • Difficult (select from all movies, but provide a list of films to choose from)
  • "Siracusa" (select from all movies, user has to enter the movie title themselves, do a fuzzy match on the user's input when matching against the movie title)

Bash code to get a random frame:

ms=$(mediainfo --Inform="Video;%Duration%" input.mkv)
secs=$(( ${ms%.*} / 1000 ))
ffmpeg -y -ss $(( $RANDOM % ${secs} )) -i input.mkv -vf "scale='min(1080,iw)':-1" -vframes 1 -q:v 2 output.jpg

Increase S3 upload retries

Traceback (most recent call last):
  File "./app/videos.py", line 178, in localization_task
    ) = aws_upload(file_path, current_app.config["AWS_UNTOUCHED_PREFIX"])
  File "./app/videos.py", line 1358, in aws_upload
    response = s3_client.upload_file(
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/boto3/s3/inject.py", line 129, in upload_file
    return transfer.upload_file(
  File "/Users/server/Sites/fitzflix/venv/lib/python3.8/site-packages/boto3/s3/transfer.py", line 285, in upload_file
    raise S3UploadFailedError(
boto3.exceptions.S3UploadFailedError: Failed to upload /Volumes/Media/videos/renamed/Sleepwalking Land (2007) - [HDTV-720p].mkv to aws-us-east-1-medialibrary.glennfitzpatrick.com/untouched/Sleepwalking Land (2007) - [HDTV-720p].mkv: An error occurred (InternalError) when calling the UploadPart operation (reached max retries: 0): We encountered an internal error. Please try again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.