From: Fredrik Tolf Date: Mon, 16 Nov 2015 04:57:44 +0000 (+0100) Subject: Fixed some more Python3-compatibility in mangafox. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=20a9e62afa4842b32b664d764c7a95ee1ca7cf89;p=automanga.git Fixed some more Python3-compatibility in mangafox. --- diff --git a/manga/mangafox.py b/manga/mangafox.py index 8b4300a..0e8c2e9 100644 --- a/manga/mangafox.py +++ b/manga/mangafox.py @@ -147,7 +147,11 @@ class manga(lib.manga): return "" % self.name def libalphacmp(a, b): - return cmp(a.upper(), b.upper()) + if a.upper() < b.upper(): + return -1 + elif a.upper() > b.upper(): + return 1 + return 0 class library(lib.library): def __init__(self): @@ -205,8 +209,10 @@ class library(lib.library): i = 0 def search(self, expr): - with urllib.request.urlopen(self.base + ("ajax/search.php?term=%s" % urllib.quote(expr))) as resp: - rc = json.load(resp) + req = urllib.request.Request(self.base + ("ajax/search.php?term=%s" % urllib.parse.quote(expr)), + headers={"User-Agent": "automanga/1"}) + with urllib.request.urlopen(req) as resp: + rc = json.loads(resp.read().decode("utf-8")) return [manga(self, id, name, self.base + ("manga/%s/" % id)) for num, name, id, genres, author in rc] def byid(self, id):