Provide proper referers for nelo and kakalot.
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 8 Jun 2020 14:46:40 +0000 (16:46 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 8 Jun 2020 14:46:40 +0000 (16:46 +0200)
manga/kakalot.py
manga/lib.py
manga/nelo.py

index 9a5fb03..d3b82a3 100644 (file)
@@ -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
index da64e0c..849e632 100644 (file)
@@ -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:
index 959c2a0..4b51ba7 100644 (file)
@@ -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