From: Fredrik Tolf Date: Mon, 8 Jun 2020 14:46:40 +0000 (+0200) Subject: Provide proper referers for nelo and kakalot. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=83be8dcead2a47c303acad930f71571a87d01edf;p=automanga.git Provide proper referers for nelo and kakalot. --- diff --git a/manga/kakalot.py b/manga/kakalot.py index 9a5fb03..d3b82a3 100644 --- a/manga/kakalot.py +++ b/manga/kakalot.py @@ -15,7 +15,7 @@ class page(lib.page): self.iurl = url def open(self): - return lib.stdimgstream(self.iurl) + return lib.stdimgstream(self.iurl, referer=self.chapter.url) def __str__(self): return self.name diff --git a/manga/lib.py b/manga/lib.py index da64e0c..849e632 100644 --- a/manga/lib.py +++ b/manga/lib.py @@ -158,9 +158,12 @@ class stdimgstream(imgstream): """A standard implementation of imgstream, for libraries which have no particular implementation requirements.""" - def __init__(self, url): + def __init__(self, url, referer=None): import urllib.request - req = urllib.request.Request(url, headers={"User-Agent": "automanga/1"}) + headers = {"User-Agent": "automanga/1"} + if referer: + headers["Referer"] = referer + req = urllib.request.Request(url, headers=headers) self.bk = urllib.request.urlopen(req) ok = False try: diff --git a/manga/nelo.py b/manga/nelo.py index 959c2a0..4b51ba7 100644 --- a/manga/nelo.py +++ b/manga/nelo.py @@ -15,7 +15,7 @@ class page(lib.page): self.iurl = url def open(self): - return lib.stdimgstream(self.iurl) + return lib.stdimgstream(self.iurl, referer=self.chapter.url) def __str__(self): return self.name