Merge pull request #157 from NotoriousRebel/master

Added error check to duckduckgo to make sure it doesn't crash
This commit is contained in:
Matt 2019-01-14 02:19:12 +00:00 committed by GitHub
commit 759992d6a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -48,9 +48,11 @@ def crawl(self, text):
load = json.loads(text)
for key in load.keys(): # Iterate through keys of dict.
val = load.get(key)
if isinstance(val, int) or isinstance(val, dict):
if isinstance(val, int) or isinstance(val, dict) or val is None:
continue
if isinstance(val, list):
if len(val) == 0: # Make sure not indexing an empty list
continue
val = val[0] # First value should be dict.
if isinstance(val, dict): # Sanity check.
for key in val.keys():

View file

@ -922,4 +922,4 @@ def start(argv):
except Exception:
import traceback
print(traceback.print_exc())
sys.exit(1)
sys.exit(1)