Dolda2000 GitWeb
/
automanga.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Provide proper referers for nelo and kakalot.
[automanga.git]
/
getmanga
diff --git
a/getmanga
b/getmanga
index
f678e33
..
bd8401e
100755
(executable)
--- a/
getmanga
+++ b/
getmanga
@@
-12,7
+12,7
@@
def msg(vl, msg, *args):
sys.stderr.write("getmanga: " + (msg % args) + "\n")
def getprop(nm, default=None):
sys.stderr.write("getmanga: " + (msg % args) + "\n")
def getprop(nm, default=None):
- if "dl-" + nm in mprof.props:
+ if
mprof and
"dl-" + nm in mprof.props:
return mprof.props["dl-" + nm]
if nm in props:
return props[nm]
return mprof.props["dl-" + nm]
if nm in props:
return props[nm]
@@
-83,11
+83,17
@@
def download(mng, tdir, pattern):
msg(1, "getting %s...", nm)
with page.open() as fp:
with open(path, "wb") as out:
msg(1, "getting %s...", nm)
with page.open() as fp:
with open(path, "wb") as out:
- while True:
- data = fp.read(65536)
- if data == b"":
- break
- out.write(data)
+ done = False
+ try:
+ while True:
+ data = fp.read(65536)
+ if data == b"":
+ done = True
+ break
+ out.write(data)
+ finally:
+ if not done:
+ os.unlink(path)
try:
img = Image.open(path)
except OSError:
try:
img = Image.open(path)
except OSError:
@@
-105,12
+111,16
@@
def download(mng, tdir, pattern):
def usage(out):
out.write("usage: getmanga [-hv] [-w WAIT] [-p PROFILE] [-P PATTERN] DIRECTORY [LIBRARY ID]\n")
def usage(out):
out.write("usage: getmanga [-hv] [-w WAIT] [-p PROFILE] [-P PATTERN] DIRECTORY [LIBRARY ID]\n")
+ out.write("\tpattern templates:\n")
+ out.write("\t %i\tSequence number\n")
+ out.write("\t %n\tName\n")
+ out.write("\t %d\tID\n")
def main():
global verbose, wait, mprof, props
opts, args = getopt.getopt(sys.argv[1:], "hvp:w:P:")
def main():
global verbose, wait, mprof, props
opts, args = getopt.getopt(sys.argv[1:], "hvp:w:P:")
- profnm =
""
+ profnm =
None
pattern = None
for o, a in opts:
if o == "-h":
pattern = None
for o, a in opts:
if o == "-h":
@@
-143,8
+153,10
@@
def main():
elif words[0] == "lset" and len(words) > 1:
props[words[1]] = words[2:]
elif words[0] == "lset" and len(words) > 1:
props[words[1]] = words[2:]
- if profnm
== ""
:
+ if profnm
is None
:
profile = manga.profile.profile.last()
profile = manga.profile.profile.last()
+ elif profnm == "":
+ profile = None
else:
profile = manga.profile.profile.byname(profnm)
else:
profile = manga.profile.profile.byname(profnm)
@@
-168,9
+180,12
@@
def main():
except KeyError:
sys.stderr.write("getmanga: no such manga: %s\n" % (mid))
sys.exit(1)
except KeyError:
sys.stderr.write("getmanga: no such manga: %s\n" % (mid))
sys.exit(1)
- mprof = profile.getmanga(libnm, mng.id)
+ if profile is not None:
+ mprof = profile.getmanga(libnm, mng.id)
+ else:
+ mprof = None
- download(m
prof.open()
, tdir, pattern or getprop("pattern"))
+ download(m
ng
, tdir, pattern or getprop("pattern"))
if __name__ == "__main__":
try:
if __name__ == "__main__":
try: