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` 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: diff --git a/instaloader/__main__.py b/instaloader/__main__.py index 93b2262..a8f5aae 100644 --- a/instaloader/__main__.py +++ b/instaloader/__main__.py @@ -89,6 +89,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() @@ -141,9 +145,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: @@ -151,7 +155,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: @@ -163,25 +167,23 @@ 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, download_tagged=tagged, - download_tagged_only=tagged_only, - post_filter=post_filter) + download_tagged_only=tagged_only, post_filter=post_filter) if anonymous_retry_profiles: instaloader.context.log("Downloading anonymously: {}" .format(' '.join([p.username for p in anonymous_retry_profiles]))) 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, download_tagged=tagged, - download_tagged_only=tagged_only, - post_filter=post_filter) - if stories or stories_only: + download_tagged_only=tagged_only, post_filter=post_filter) + 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, 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.