emericg / OpenSubtitlesDownload

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

Duplicate subtle filename search mode ignores valid search result from hash when using "hash_then_filename" mode #106

Closed matkook404log closed 5 months ago

matkook404log commented 6 months ago

The line 823 "if ('filename' in opt_search_mode) or ('hash_then_filename' in opt_search_mode and len(subtitlesResultList['data']) == 0):" can incorrectly be executed if opt_search_mode = 'hash_then_filename'.

For example, subtitlesResultList correctly returns result from hash search, but still get executed by the "'filename' in opt_search_mode" part of the condition. As a result, valid result from hash is deleted with "0" result from filename search method.

The substring search is ambiguous and covers both cases: "hash_and_filename" and "hash_then_filename".

The first part of the condition in line 823 should specify exactly "hash_and_filename" instead of the ambiguous "filename" string only.

emericg commented 6 months ago

Looks like you are right, thanks for taking a look at the problem. I've made changes so this doesn't happen anymore.