From 83be8dcead2a47c303acad930f71571a87d01edf Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Mon, 8 Jun 2020 16:46:40 +0200 Subject: [PATCH] Provide proper referers for nelo and kakalot. --- manga/kakalot.py | 2 +- manga/lib.py | 7 +++++-- manga/nelo.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) 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 -- 2.11.0