Fix crash on mod name not specified

This commit is contained in:
rubenwardy 2018-05-14 13:58:31 +01:00
parent 46a4bfbcff
commit 4bea3484d1
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
1 changed files with 9 additions and 4 deletions

View File

@ -91,9 +91,9 @@ def getKrockList():
return krock_list_cache, krock_list_cache_by_name
def findModInfo(author, name, link):
_, lookup = getKrockList()
list, lookup = getKrockList()
if name in lookup:
if name is not None and name in lookup:
if len(lookup[name]) == 1:
return lookup[name][0]
@ -101,6 +101,11 @@ def findModInfo(author, name, link):
if x["author"] == author:
return x
if link is not None and len(link) > 15:
for x in list:
if link in x["link"]:
return x
return None
@ -161,9 +166,9 @@ def getMeta(urlstr, author):
cutIdx = min(len(desc), 200 if idx < 5 else idx)
result["short_description"] = desc[:cutIdx]
info = findModInfo(author, result["name"], result["repo"])
info = findModInfo(author, result.get("name"), result["repo"])
if info is not None:
result["forumId"] = info["topicId"]
result["forumId"] = info.get("topicId")
return result