2017-02-06 23:46:26 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2017-02-08 22:49:18 +00:00
|
|
|
import errno, fpdf, helpers, os, os.path, PIL, urllib.request
|
2017-02-06 23:46:26 +00:00
|
|
|
|
|
|
|
def getPage(issue, page):
|
|
|
|
try:
|
|
|
|
f = urllib.request.urlopen("https://www.falter.at/falter/e-paper/fetch/%i/%i.jpg" % (issue, page))
|
|
|
|
|
|
|
|
with open("%i/%i.jpg" % (issue, page), "b+w") as o:
|
|
|
|
o.write(f.read())
|
|
|
|
|
|
|
|
except urllib.error.HTTPError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def getIssue(issue, makepdf = True):
|
2017-02-08 22:49:18 +00:00
|
|
|
if helpers.makeDir(issue):
|
2017-02-06 23:46:26 +00:00
|
|
|
i = 1
|
|
|
|
|
|
|
|
while getPage(issue, i) is not False:
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
if i == 1:
|
2017-02-06 23:55:45 +00:00
|
|
|
os.rmdir(str(issue))
|
2017-02-06 23:46:26 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
if i < 5:
|
|
|
|
print("[NOTICE] Incomplete issue: %i" % issue)
|
|
|
|
|
|
|
|
if makepdf:
|
2017-02-08 22:49:18 +00:00
|
|
|
helpers.makePDF(issue, i-1)
|
2017-02-06 23:46:26 +00:00
|
|
|
|
2017-02-06 23:55:45 +00:00
|
|
|
else:
|
|
|
|
print("[NOTICE] Skipping issue: %i (already exists)" % issue)
|
|
|
|
|
2017-02-06 23:46:26 +00:00
|
|
|
def getterLoop(start = 53):
|
|
|
|
i = start
|
2017-02-06 23:55:45 +00:00
|
|
|
j = 0
|
|
|
|
|
|
|
|
while j < 5:
|
|
|
|
if getIssue(i) is False:
|
|
|
|
j += 1
|
2017-02-07 00:02:15 +00:00
|
|
|
print("[NOTICE] Skipping issue: %i (not found - %i)" (i, j))
|
2017-02-06 23:55:45 +00:00
|
|
|
else:
|
|
|
|
j = 0
|
2017-02-06 23:46:26 +00:00
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
getterLoop()
|