mueslimak3r / tv-intro-detection

This project tries to detect intros of tv series by comparing pairs of episodes to find the largest common subset of frames.
https://mueslimak3r.github.io/tv-intro-detection/
GNU General Public License v3.0
81 stars 3 forks source link

[Feature request] Skipping corrupt files and moving on to the next season. #6

Closed Cookie-Monster-Coder closed 2 years ago

Cookie-Monster-Coder commented 2 years ago

Is your feature request related to a problem? Please describe. Having a corrupt file throws an error and restarts script.

creating new fingerprint for [/Media/Tv/Strike Back (2010)/Season 06/Strike Back (2010)-S06E09-Episode 9 [Bluray-1080p] [x264 DTS]-SbR.mkv]
running ffmpeg
ran ffmpeg in 0:00:21.128079
Traceback (most recent call last):
  File "/app/jellyfin.py", line 262, in <module>
    main(sys.argv[1:])
  File "/app/jellyfin.py", line 250, in main
    process_jellyfin_shows(log_level, log, save_json)
  File "/app/jellyfin.py", line 193, in process_jellyfin_shows
    result = process_directory(file_paths=file_paths, cleanup=False, log_level=log_level, log_file=log_file, log_timestamp=session_timestamp)
  File "/app/decode.py", line 361, in process_directory
    fingerprint, profile = get_or_create_fingerprint(file_path, cleanup, log_level, log_file)
  File "/app/decode.py", line 124, in get_or_create_fingerprint
    fingerprint = create_video_fingerprint(profile, log_level, log_file)
  File "/app/decode.py", line 76, in create_video_fingerprint
    video_fingerprint = get_fingerprint_ffmpeg(profile['path'], quarter_frames_or_first_X_mins, log_level, log_file, session_timestamp)
  File "/app/ffmpeg_fingerprint.py", line 74, in get_fingerprint_ffmpeg
    with Image.open(filename) as image:
  File "/usr/local/lib/python3.10/site-packages/PIL/Image.py", line 2953, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: './config/data/fingerprints/MediaTvStrikeBack2010Season06StrikeBack2010S06E09Episode9Bluray1080px264DTSSbRmkv/frames/frame-00005642.jpeg'
started new session at 2022-04-02 17:17:58.394109

Describe the solution you'd like Instead of auto restarting the script and having it reprocess the same corrupt file again (basically stuck in a loop), log the file that caused the issues in a new log file ex: error.log and either skip that season or series as a whole and move on to the next season/series.

User can the fix the files in error.log and the next time they launch the script it will reprocess that season.

This is going to be useful for people who have large library's.

Describe alternatives you've considered Creating a script using ffmpeg to find corrupt video file. This alone is waste full.

Additional context Add any other context or screenshots about the feature request here.

mueslimak3r commented 2 years ago

Do you find more than one episode in that season is corrupted?

imo an ideal solution would be to skip the episode and keep processing the season. There are already plenty of cases where intros can't be found for individual episodes but they can be found for the other episodes in the season.

Cookie-Monster-Coder commented 2 years ago

Do you find more than one episode in that season is corrupted?

No, it was just one episode.

ideal solution would be to skip the episode and keep processing the season

Yeah, if that would be the easiest. Would it be possible to log the skip?

mueslimak3r commented 2 years ago

Yeah, if that would be the easiest. Would it be possible to log the skip?

Yeah I'll look intro this and it will be logged. I think I'll tweak the logging system one more time and add log prefixes that can be used to search the output with grep. so for instance with a skipped episode it might be: Failed to process frames due to possible corruption for [filename] - ERROR - SKIPPED - CORRUPTED.

Does that sound like it would be useful or overkill?

Cookie-Monster-Coder commented 2 years ago

Yeah, that sound good! In my experience over logging is better than under logging.

mueslimak3r commented 2 years ago

Can you test the latest version against the problematic file(s) and see if you still have problems?

Cookie-Monster-Coder commented 2 years ago

Can you test the latest version against the problematic file(s) and see if you still have problems?

I already replaced the bad file and I haven't found another yet. I'll reopen the issue if it errors out on a corrupt file again. Thank you for the fast fix!

mueslimak3r commented 2 years ago

Great. I saw you had issue with the docker images publishing in your fork because your username has uppercase letters. I just pushed a change to the workflow that should fix that by converting it to lowercase. Can you test it?

Cookie-Monster-Coder commented 2 years ago

Yes, the docker images built and published perfectly, thank you!. https://github.com/Cookie-Monster-Coder/tv-intro-detection/actions/runs/2094462419

Since I have a large library, I am flipping the show's list and running a second scanner. Using a read only mergerfs mount to combine them for the skipper container. Seems to be running well.