X-Git-Url: http://dolda2000.com/gitweb/?p=automanga.git;a=blobdiff_plain;f=manga%2Fmangafox.py;h=b165d21aa4e11eddf6c02aa2a32ccda699073237;hp=ed40efb1636a3f3bd1cd07a13415b55803011831;hb=30053c2cfe18b77da52df38daebbc91b3a2b5240;hpb=a803365ba47dd030f121be0ca48342c4e79efcf5 diff --git a/manga/mangafox.py b/manga/mangafox.py index ed40efb..b165d21 100644 --- a/manga/mangafox.py +++ b/manga/mangafox.py @@ -6,8 +6,16 @@ soup = BeautifulSoup.BeautifulSoup 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"]) + ok = False + try: + if self.bk.getcode() != 200: + raise IOError("Server error: " + str(self.bk.getcode())) + self.ctype = self.bk.info()["Content-Type"] + self.clen = int(self.bk.info()["Content-Length"]) + ok = True + finally: + if not ok: + self.bk.close() def fileno(self): return self.bk.fileno()