From 3daefdabc4d46282deb07ac73ea45082e00dfea8 Mon Sep 17 00:00:00 2001 From: Emeric Date: Fri, 15 Jun 2018 14:58:26 +0200 Subject: [PATCH] Prevent a crash if the server hasn't returned any results --- OpenSubtitlesDownload.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSubtitlesDownload.py b/OpenSubtitlesDownload.py index d374d1d..d9264b2 100755 --- a/OpenSubtitlesDownload.py +++ b/OpenSubtitlesDownload.py @@ -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() @@ -657,7 +658,7 @@ def dependencyChecker(): superPrint("error", "Search error!", "Unable to reach opensubtitles.org servers!\nSearch error") # 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