1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-11-04 09:22:29 +01:00

Also save session when interrupted by user

Fixes #8.
This commit is contained in:
Alexander Graf 2016-07-26 17:03:32 +02:00
parent 087a69ef7e
commit a99d1875e5

View File

@ -293,13 +293,16 @@ def download_profiles(targets, username=None, password=None, sessionfile=None,
session = get_anonymous_session() session = get_anonymous_session()
# Iterate through targets list and download them # Iterate through targets list and download them
failedtargets = [] failedtargets = []
for target in targets: try:
try: for target in targets:
download(target, session, profile_pic_only, download_videos, try:
fast_update, sleep_min_max, quiet) download(target, session, profile_pic_only, download_videos,
except NonfatalException as err: fast_update, sleep_min_max, quiet)
failedtargets.append(target) except NonfatalException as err:
print(err, file=sys.stderr) failedtargets.append(target)
print(err, file=sys.stderr)
except KeyboardInterrupt:
print("\nInterrupted by user.", file=sys.stderr)
if len(targets) > 1 and len(failedtargets) > 0: if len(targets) > 1 and len(failedtargets) > 0:
print("Errors occured (see above) while downloading profiles: %s" % print("Errors occured (see above) while downloading profiles: %s" %
", ".join(failedtargets), file=sys.stderr) ", ".join(failedtargets), file=sys.stderr)
@ -335,8 +338,6 @@ def main():
[0,0] if args.no_sleep else [0.25,2], args.quiet) [0,0] if args.no_sleep else [0.25,2], args.quiet)
except InstaloaderException as err: except InstaloaderException as err:
raise SystemExit("Fatal error: %s" % err) raise SystemExit("Fatal error: %s" % err)
except KeyboardInterrupt:
print("Interrupted by user.", file=sys.stderr)
if __name__ == "__main__": if __name__ == "__main__":
main() main()