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

Download profile pic unless --no-profile-pic

Fixes #165.

To download (S = Stories, P = Profile Pic, p = Posts)

p	--no-profile-pic
P	--profile-pic-only
Pp	(default)
S	--no-profile-pic --stories-only
Sp	--no-profile-pic --stories
SP	--stories-only
SPp	--stories
This commit is contained in:
Alexander Graf 2018-08-13 17:44:06 +02:00
parent 8303f1d1c5
commit a3777cad5d

View File

@ -88,6 +88,10 @@ def _main(instaloader: Instaloader, targetlist: List[str],
else:
instaloader.interactive_login(username)
instaloader.context.log("Logged in as %s." % username)
# Determine what to download
download_profile_pic = profile_pic or profile_pic_only
download_profile_posts = not (stories_only or profile_pic_only)
download_profile_stories = stories or stories_only
# Try block for KeyboardInterrupt (save session on ^C)
profiles = set()
anonymous_retry_profiles = set()
@ -140,9 +144,9 @@ def _main(instaloader: Instaloader, targetlist: List[str],
try:
profile = instaloader.check_profile_id(target)
if instaloader.context.is_logged_in and profile.has_blocked_viewer:
if not stories_only and not profile.is_private:
raise ProfileNotExistsException("{} blocked you; But she's public, "
"so we just download her anonymously.".format(target))
if download_profile_pic or (download_profile_posts and not profile.is_private):
raise ProfileNotExistsException("{} blocked you; But we download her anonymously."
.format(target))
else:
instaloader.context.error("{} blocked you.".format(target))
else:
@ -150,7 +154,7 @@ def _main(instaloader: Instaloader, targetlist: List[str],
except ProfileNotExistsException as err:
# Not only our profile.has_blocked_viewer condition raises ProfileNotExistsException,
# check_profile_id() also does, since access to blocked profile may be responded with 404.
if instaloader.context.is_logged_in and not stories_only:
if instaloader.context.is_logged_in and (download_profile_pic or download_profile_posts):
instaloader.context.log(err)
instaloader.context.log("Trying again anonymously, helps in case you are just blocked.")
with instaloader.anonymous_copy() as anonymous_loader:
@ -162,11 +166,11 @@ def _main(instaloader: Instaloader, targetlist: List[str],
if len(profiles) > 1:
instaloader.context.log("Downloading {} profiles: {}".format(len(profiles),
' '.join([p.username for p in profiles])))
if not stories_only:
if download_profile_pic or download_profile_posts:
# Iterate through profiles list and download them
for target in profiles:
with instaloader.context.error_catcher(target):
instaloader.download_profile(target, profile_pic, profile_pic_only,
instaloader.download_profile(target, download_profile_pic, not download_profile_posts,
fast_update, post_filter=post_filter)
if anonymous_retry_profiles:
instaloader.context.log("Downloading anonymously: {}"
@ -174,9 +178,9 @@ def _main(instaloader: Instaloader, targetlist: List[str],
with instaloader.anonymous_copy() as anonymous_loader:
for target in anonymous_retry_profiles:
with instaloader.context.error_catcher(target):
anonymous_loader.download_profile(target, profile_pic, profile_pic_only,
anonymous_loader.download_profile(target, download_profile_pic, not download_profile_posts,
fast_update, post_filter=post_filter)
if stories or stories_only:
if download_profile_stories and profiles:
with instaloader.context.error_catcher("Download stories"):
instaloader.context.log("Downloading stories")
instaloader.download_stories(userids=list(profiles), fast_update=fast_update,