From 77ca78e97796e9fa67841b7499e0b77e4d5a2c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Koch-Kramer?= Date: Tue, 7 Aug 2018 19:16:08 +0200 Subject: [PATCH 1/4] Fix logging out when download profile_pic fails Add try-finally-block to InstaloaderContext.anonymous_copy(). Fixes #159. --- instaloader/instaloadercontext.py | 10 ++++++---- instaloader/structures.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index 7cf4700..d17ce43 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -75,10 +75,12 @@ class InstaloaderContext: username = self.username self._session = self.get_anonymous_session() self.username = None - yield self - self._session.close() - self.username = username - self._session = session + try: + yield self + finally: + self._session.close() + self.username = username + self._session = session @property def is_logged_in(self) -> bool: diff --git a/instaloader/structures.py b/instaloader/structures.py index da85d35..208a67d 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -552,6 +552,8 @@ class Profile: @property def has_viewable_story(self) -> bool: """ + .. deprecated:: 4.0.6 + Some stories are private. This property determines if the :class:`Profile` has at least one story which can be viewed using the associated :class:`InstaloaderContext`, i.e. the viewer has privileges to view it. From 998333b7cd91d76b92042b132705b5ae0604f9a1 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 7 Aug 2018 19:55:46 +0200 Subject: [PATCH 2/4] Revert "Mention IRC channel #instaloader on Freenode" This reverts commit 8423e3bd000419507e898d4814e2a0665364db22. The channel did not have as much activity as expected and an IRC channel does not work if there are not at least a few people in it. --- README.rst | 9 --------- docs/contributing.rst | 16 ---------------- docs/index.rst | 4 ---- 3 files changed, 29 deletions(-) diff --git a/README.rst b/README.rst index 79ae125..3e03d4c 100644 --- a/README.rst +++ b/README.rst @@ -96,12 +96,3 @@ development of Instaloader. | For Donations, we provide a PayPal.Me link and a Bitcoin address. | PayPal: `PayPal.me/aandergr `__ | BTC: 1Nst4LoadeYzrKjJ1DX9CpbLXBYE9RKLwY - -For a direct and personal communication within Instaloader's community, we have -an IRC channel - -**#instaloader** on **Freenode**. - -Freenode provides a `Web IRC Client -`__, allowing to join our -channel without having an IRC client installed. diff --git a/docs/contributing.rst b/docs/contributing.rst index 876103c..80e643d 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -102,19 +102,3 @@ development of Instaloader. .. donations-end .. (Discussion in :issue:`130`) - -IRC Channel ------------ - -.. ircchannel-start - -For a direct and personal communication within Instaloader's community, we have -an IRC channel - -**#instaloader** on **Freenode**. - -Freenode provides a `Web IRC Client -`__, allowing to join our -channel without having an IRC client installed. - -.. ircchannel-end diff --git a/docs/index.rst b/docs/index.rst index 89d0a74..5f0987f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -88,10 +88,6 @@ become an even greater tool. :start-after: donations-start :end-before: donations-end -.. include:: contributing.rst - :start-after: ircchannel-start - :end-before: ircchannel-end - .. * :ref:`genindex` * :ref:`modindex` From 8303f1d1c5c5b29b6be7859dcf60aa9e8c25f444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Koch-Kramer?= Date: Tue, 7 Aug 2018 20:07:41 +0200 Subject: [PATCH 3/4] Release of version 4.0.8 --- instaloader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/__init__.py b/instaloader/__init__.py index 13ac807..df41aeb 100644 --- a/instaloader/__init__.py +++ b/instaloader/__init__.py @@ -1,7 +1,7 @@ """Download pictures (or videos) along with their captions and other metadata from Instagram.""" -__version__ = '4.0.7' +__version__ = '4.0.8' try: From a3777cad5d777f894965576d4ad4bc5d9c87da92 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 13 Aug 2018 17:44:06 +0200 Subject: [PATCH 4/4] 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 --- instaloader/__main__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/instaloader/__main__.py b/instaloader/__main__.py index 1eaaf81..9f9c54e 100644 --- a/instaloader/__main__.py +++ b/instaloader/__main__.py @@ -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,