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

Request for sorting multiple languages in most to least preferred. #25

Closed mhertz closed 7 years ago

mhertz commented 7 years ago

First, thanks for this awesome script, I love it, and other implementations always takes a bunch of other deps to work.

Now, my "issue" is that I want to retrieve subs in my native language, and if not available, then in english. I also use the script from my own shell-script set to run after each finished torrent download, so need automated behavior. I initially thought I could just use '-a -l dan,swe,eng', but this will take the best match, meaning highest rank. Highest rank is of course fine, but when there are a sub in my native language, then I rather want that sub, instead of an english sub with higher rank. My point is that I define the languages in the order of most to least preferred and not just randomly.

I would love if there could be an option for when selecting multiple languages, then the firstly mentioned one should take precedence irregardless of ranks.

To workaround this, then I have the script running 3 times now for every file, one on the least favored language, and second run in next favored and last in most favored language, and the subs are overwritten by default in your script, so this works fine, though not very efficient.

Hope I am making myself clear on what I mean here :) Thanks for your work regardless of the outcome of this request!

-Martin.

emericg commented 7 years ago

Hi mhertz, I see what you mean, and I though it was supposed to use the first subtitles found (so the first language specified, meaning 'dan' in 'dan,swe,eng'. I'll need to dive into the code in order to fix that because It's been a while since this has been coded, thanks for your patience :)

mhertz commented 7 years ago

Thanks alot, I really appreciate that! :)

emericg commented 7 years ago

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

Downloading 'Spanish' subtitles for 'FILE' 2017-07-01 13:12:02 URL:http://dl.opensubtitles.org/en/download/src-api/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.gz [49731/49731] -> "-" [1]

Using '-l spa,fre,eng' only the first language specified is downloaded here, (all 3 languages are available) but the selection is done by selecting the most downloaded subtitles (that's what the 'auto' does when enabled. I guess that can be changed to select the most downloaded subtitles for the first language yes. I'll try to come up with a solution.

mhertz commented 7 years ago

Indeed, my issue, is that no matter how you change the order of those languages, only the most downloaded is selected, meaning changing the order have absolutely no effect, though I understand it's by design and of course I can see that design would appeal to many also, just not me personally. Thanks for thinking about it, it's much appreciated.

emericg commented 7 years ago

I have one solution right now, I'll test it a little bit more and push it later today ;-)

emericg commented 7 years ago

Allright can you try the latest version and tell me if that fixes your problem? Thanks!

mhertz commented 7 years ago

Thanks again! No change for me though, with latest version, meaning, '-l eng,swe' and '-l swe,eng' gives exactly the same result, in the english sub is downloaded, because more popular I guess.

emericg commented 7 years ago

Allright so I had a second look at your problem, and it looks like an usual case...

There is two type of search mode, by file hash and by file name. When using the multiple search languages, the search by hash provides results for one of the language (here, english), and so the search by name will not start because the results list is not empty.

I'll close this issue because it is fixed (sorting multiple languages from most to least preferred is now working) and we'll continue on the other issue you wrote ;-)