emericg / OpenSubtitlesDownload

Automatically find and download the right subtitles for your favorite videos!
https://emeric.io/OpenSubtitlesDownload
GNU General Public License v3.0
595 stars 66 forks source link

Bug in -l option when used multiple times. #26

Closed mhertz closed 7 years ago

mhertz commented 7 years ago

I found a bug, which is that this line:

OpenSubtitlesDownload.py -a -l eng -l swe -l dan foo.mp4

Downloads only the sub in english, though there is also a swedish sub available but not gotten(the -a isn't the issue, it's the same without).

If moving the english language last, then it works and I get both swedish and english subs downloaded(there's no danish sub available for example file)

OpenSubtitlesDownload.py -a -l dan -l swe -l eng foo.mp4

This is an issue for me, because I set OpenSubtitlesDownload to not add country name to subs and then wanted to use the first line at top for getting first english subs and if swedish was available, then overwrite with that, and finally if danish(my native language) is available, then overwrite with that, since I only want one sub named after the video, and in that order of availability.

Let me know if you want the file to test or anything else. Thanks in advance.

emericg commented 7 years ago

Hi mhertz, I'll have a look at what's happening when one of the search has no results and if that can make the other searchs misbehave. Just to be sure, you are trying to make the -l dan,swe,eng working with a different approach right?

mhertz commented 7 years ago

Yes, indeed i was trying to make the '-l dan,swe,eng' work through different approach. I have defined to not add language suffix, and so the srt is just overwritten in the written order if available.

To make sure we're on the same page, then it's always the 'eng' when used as first language, that interrupts the functionality(is buggy), meaning that I e.g. have a video where there's both eng and swe subs available, and if I run:

OpenSubtitlesDownload.py -a -l swe -l eng foo.mkv

then both subs are downloaded(and overwritten per my settings), but the following fails, meaning only english is downloaded and nothing else:

OpenSubtitlesDownload.py -a -l swe -l eng foo.mkv

Thanks again!

emericg commented 7 years ago

Hi, So I had a look at this and I'm not really sure I'm able to reproduce your problem.

./OpenSubtitlesDownload.py -g cli -a -l spa -l fre -l eng 'FILE.mkv'

Downloading 'Spanish' subtitles for 'FILE' 2017-07-01 13:07:34 URL:http://dl.opensubtitles.org/en/download/src-api/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.gz [49731/49731] -> "-" [1] Downloading 'French' subtitles for 'FILE' 2017-07-01 13:07:35 URL:http://dl.opensubtitles.org/en/download/src-api/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.gz [53872/53872] -> "-" [1] Downloading 'English' subtitles for 'FILE' 2017-07-01 13:07:35 URL:http://dl.opensubtitles.org/en/download/src-api/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.gz [22168/22168] -> "-" [1]

Using '-l spa -l fre -l eng' all subtitles are downloaded in the 'correct' order, so only the last (english) will be there if you do not use language code. Maybe you can just invert the languages code if you want english only as last resort?

mhertz commented 7 years ago

Sorry if not describing the issue so good, but my point is that this only works when not having english as first language, which for me is an issue as I only want english when my native language(s) isn't available, hence I make english the first so that it's overwritten(lang-suffix disabled) if native languages is available. Thanks again.

emericg commented 7 years ago

I'm sorry in my case if whenever I use "-l spa -l fre -l eng" or "-l eng -l fre -l spa" both commands works as intended, respecting the order and downloading all three languages.

mhertz commented 7 years ago

That's strange? It doesn't work for me in the files i've tried. If not to much trouble, then could you maybe please check with one of my files(206mb) I just uploaded to my dropbox and made a shared link for, so you can see the issue first-hand: (file)

On that file(and many others i've tested), then '-l swe -l eng' returns swedish and english subs, whereas '-l eng -l swe' returns only english subs and nothing else.

Thanks in advance!

emericg commented 7 years ago

Allright I think I got the problem, it was also related to the mix of search by file hash for the first language (english) and search by file name for the other (swedish). The latest commit should finally fix your problem!

mhertz commented 7 years ago

You rock, latest version tested and working perfectly! Thank you so much for looking into and fixing this! Also, about the other issue of mine you just closed, I am sorry for wasting your time with my ignorance, I facepalmed myself when reading your explanation :) Thanks again mate, much appreciated!

emericg commented 7 years ago

Good to know it works for you! It's allright there was no time wasted, thanks to you we found three issues and already fixed two!