+ def open(self, url):
+ req = urllib.request.Request(url, headers={"User-Agent": "automanga/1"})
+ return urllib.request.urlopen(req)
+
+ def miss(self, url):
+ try:
+ s = self.open(url)
+ except urllib.error.HTTPError as exc:
+ if exc.code == 404:
+ raise notfound(url)
+ raise
+ with s:
+ if s.headers.get("content-encoding") == "gzip":
+ import gzip, io
+ return gzip.GzipFile(fileobj=io.BytesIO(s.read()), mode="r").read()
+ return s.read()
+
+ def fetch(self, url, expire=3600):