Dolda2000 GitWeb
/
automanga.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a803365
)
Handle mangafox download errors slightly nicer.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 12 May 2013 04:01:36 +0000
(06:01 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 12 May 2013 04:03:46 +0000
(06:03 +0200)
manga/mangafox.py
patch
|
blob
|
blame
|
history
diff --git
a/manga/mangafox.py
b/manga/mangafox.py
index
ed40efb
..
b165d21
100644
(file)
--- 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)
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()
def fileno(self):
return self.bk.fileno()