Skip to content

Commit

Permalink
Prevent a crash if the server hasn't returned any results
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Jun 15, 2018
1 parent 82c0782 commit 3daefda
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions OpenSubtitlesDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ def dependencyChecker():
# TODO Cleanup duplicate between moviehash and filename results

# Fallback search
if ((not subtitlesList['data']) and (opt_search_mode == 'hash_then_filename')):
if ((opt_search_mode == 'hash_then_filename') and
(('data' in subtitlesList) and (len(subtitlesList['data']) == 0))):
searchList[:] = [] # searchList.clear()
searchList.append({'sublanguageid':SubLanguageID, 'query':videoFileName})
subtitlesList.clear()
Expand All @@ -657,7 +658,7 @@ def dependencyChecker():
superPrint("error", "Search error!", "Unable to reach opensubtitles.org servers!\n<b>Search error</b>")

# Parse the results of the XML-RPC query
if subtitlesList['data']:
if ('data' in subtitlesList) and (len(subtitlesList['data']) > 0):

# Mark search as successful
searchLanguageResult += 1
Expand Down

0 comments on commit 3daefda

Please sign in to comment.