From: Fredrik Tolf Date: Sat, 11 May 2013 04:18:34 +0000 (+0200) Subject: Added clen attribute to imgstreams. X-Git-Url: http://dolda2000.com/gitweb/?p=automanga.git;a=commitdiff_plain;h=9948db89162b12bd94971dbad4b0f765dd1b47f5 Added clen attribute to imgstreams. --- diff --git a/manga/lib.py b/manga/lib.py index 8ec9c2e..d901e9f 100644 --- a/manga/lib.py +++ b/manga/lib.py @@ -115,7 +115,9 @@ class imgstream(object): when exiting the with-scope. All imgstreams should contain an attribute `ctype', being the - Content-Type of the image being read by the stream.""" + Content-Type of the image being read by the stream, and `clen`, + being either an int describing the total number of bytes in the + stream, or None if the value is not known in advance.""" def __enter__(self): return self diff --git a/manga/mangafox.py b/manga/mangafox.py index 339ed5e..572853c 100644 --- a/manga/mangafox.py +++ b/manga/mangafox.py @@ -7,6 +7,7 @@ class imgstream(lib.imgstream): def __init__(self, url): self.bk = urllib.urlopen(url) self.ctype = self.bk.info()["Content-Type"] + self.clen = int(self.bk.info()["Content-Length"]) def fileno(self): return self.bk.fileno()