MestreLion / legendastv

API for Legendas.TV website, world's largest repository of Brazilian Portuguese Movie/TV Series subtitles. Utilities to search, retrieve info, download, extract and match subtitles.
15 stars 3 forks source link

Crash when input file is smaller then 64 KB #14

Closed ratoaq2 closed 9 years ago

ratoaq2 commented 9 years ago

If the input file is smaller then 64KB the application crashes:

2015-02-19 20:19:02,791 CRITICAL File '/home/jones/projetos/legendastv/CSI S15E17 720p HDTV X264 DIMENSION' must be at least 65536 bytes Traceback (most recent call last): File "/home/jones/projetos/legendastv/legendastv.py", line 128, in main(sys.argv[1:]) File "/home/jones/projetos/legendastv/legendastv.py", line 104, in main subtitles.retrieve_subtitle_for_movie(filename) File "/home/jones/projetos/legendastv/legendastv/subtitles.py", line 128, in retrieve_subtitle_for_movie osdb_movies = opensubtitles.videoinfo(usermovie) File "/home/jones/projetos/legendastv/legendastv/providers/opensubtitles.py", line 181, in videoinfo hash = videohash(filename) File "/home/jones/projetos/legendastv/legendastv/providers/opensubtitles.py", line 174, in videohash (filename, block)) OpenSubtitlesError: File '/home/jones/projetos/legendastv/CSI S15E17 720p HDTV X264 DIMENSION' must be at least 65536 bytes

I know that this seems to be a hypothetical scenario, but it's not.

I use this script for automation (in a raspberry pi) and my media files is in a NAS server and my script that runs from time to time does not access the NAS server (to not spin up my HDD all the time).

The raspberry pi keep references to the "pending" subtitles in a folder as below:

osmc@osmc:~/subtitles$ cat CSI\ S15E17\ 720p\ HDTV\ X264\ DIMENSION.pending /media/Public/TV Shows/CSI - Crime Scene Investigation/Season 15/CSI - Crime Scene Investigation - S15E17 - Under My Skin.pt.srt

The file is a placeholder. Its name is the media name (movie or TV show). Its content is the place to put the subtitles when found.

If the file hashing is enabled all the time and it's not configurable it becomes really hard to keep this automated scenario for me.

So, please, make it configurable (at least) :+1:

MestreLion commented 9 years ago

Fixed, but... why are you running Legendas.TV on pending, unfinished, "fake" files? Isn't it better to run it only on finished, complete, actual video files? This way you will get all the benefits of OSDB video hash database to identify the video. Otherwise, you'll get only the built-in filename parser, which I have to admit is very weak. Works fine for me, but I'm seriously considering replacing it with the smarter guessit module in the future

ratoaq2 commented 9 years ago

The video files are on a NAS server (HDD) and the subtitles might not be yet available: e.g.: an episode was just released, the video is complete on a NAS server, but the subtitle might be available only in 1, 2, or even 5 or 6 days. Most of the times (>90%) the video is complete and there's no subtitle available for it.

The raspberry pi (SD card) has a schedule (let's say "every 1 hour") to check legendas.tv for a subtitle. If I always check against a finished, completed, video file, the HDD will spin up every hour and only spin down after 10 or 15 minutes; so it will only sleep for 45 min. It will consume more power and it will decrease drastically its lifetime. It's not an option to spin up and down the HDD every hour. The NAS server should stay quiet and only wake up when there are files for it, and not to perform checks every now and then.

And the build-in filename parser (with all those changes in the past few days) is not very weak. It's really accurate. I must tell you that after almost 6 months, if you set the similarity to 0.94 or 0.95, you will always get the correct subtitle.

Please, do not remove/replace it. Don't want to live on an old fork of the project.