Auto stash before merge of "develop" and "python-utility-scripts/develop"

pull/7/head
Trivernis 6 years ago
parent f79a0de8c1
commit 632164dba1

@ -48,8 +48,8 @@ def get_next_url(baseurl: str, url: str):
except KeyError: except KeyError:
pass pass
ids = [_id for _id in ids if _id] ids = [_id for _id in ids if _id]
if len(ids) == 0: if len(ids) == 0: # if no id was found, we can't get any further into the past
return [] return False
_id = ids[-1] _id = ids[-1]
next_url = '{}/?after={}'.format(baseurl, _id) next_url = '{}/?after={}'.format(baseurl, _id)
return next_url return next_url
@ -164,9 +164,20 @@ def parser_init():
parser.add_option('-t', '--test', dest='test', parser.add_option('-t', '--test', dest='test',
action='store_true', default=False, action='store_true', default=False,
help='Tests the functions of the script') help='Tests the functions of the script')
parser.add_option('-l', '--loop', dest='loop',
action='store_true', default=False,
help="""Continuing download loop. When this option is set every 5 Minutes the program searches for
new images""")
return parser.parse_args() return parser.parse_args()
def download_subreddits(subreddits, count, output):
for sub in subreddits:
print('[~] Downloading %s' % sub)
download_subreddit(sub, count=count, out=output)
print()
def main(): def main():
options, subreddits = parser_init() options, subreddits = parser_init()
count = options.count count = options.count
@ -175,14 +186,19 @@ def main():
count = 1 count = 1
subreddits = ['python'] subreddits = ['python']
output = 'test.zip' output = 'test.zip'
for sub in subreddits: if options.loop:
print('[~] Downloading %s' % sub) while True:
download_subreddit(sub, count=count, out=output) download_subreddits(subreddits, count, output)
time.sleep(300)
else:
download_subreddits(subreddits, count, output)
cleanup() cleanup()
if options.test: if options.test:
os.remove(output) os.remove(output)
if len(errors.keys()) > 0: if len(errors.keys()) > 0:
print(errors) print('[-] Following errors occured:')
for key in errors.keys():
print(' %s times: %s' % (errors[key], key))
if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save