diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-05-11 13:25:42 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-05-11 13:25:42 +0100 |
commit | 5424f0aa3499ef9cad33ebad4db055860b8000c8 (patch) | |
tree | eded53772fa732631b80b4ab7493fc0c2707b932 /app/tasks/importtasks.py | |
parent | 7aec5368d887974b74d87e215e39da48fc971f65 (diff) | |
download | cheatdb-5424f0aa3499ef9cad33ebad4db055860b8000c8.tar.xz |
Read from description.txt
Diffstat (limited to 'app/tasks/importtasks.py')
-rw-r--r-- | app/tasks/importtasks.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index 50b5f5d..2027f74 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -25,6 +25,12 @@ class GithubURLMaker: def getModConfURL(self): return self.baseUrl + "/mod.conf" + def getDescURL(self): + return self.baseUrl + "/description.txt" + + def getScreenshotURL(self): + return self.baseUrl + "/screenshot.png" + def parseConf(string): retval = {} for line in string.split("\n"): @@ -55,7 +61,7 @@ def getMeta(urlstr): try: contents = urllib.request.urlopen(urlmaker.getModConfURL()).read().decode("utf-8") conf = parseConf(contents) - for key in ["name", "description"]: + for key in ["name", "description", "title"]: try: result[key] = conf[key] except KeyError: @@ -65,4 +71,11 @@ def getMeta(urlstr): except OSError: print("mod.conf does not exist") + if not "description" in result: + try: + contents = urllib.request.urlopen(urlmaker.getDescURL()).read().decode("utf-8") + result["description"] = contents.strip() + except OSError: + print("description.txt does not exist!") + return result |