From 41e734e1b83bfdc2b33b88bf4f08b75282e3087d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sun, 7 Oct 2018 14:59:16 +0200 Subject: [PATCH] Fix fast_update in case of no download If Instaloader was called with --fast-update and encountered a post where nothing has been downloaded because of flags that disable download of certain types of media, the download was aborted. This behavior is now fixed. Closes #183. --- instaloader/instaloader.py | 8 ++++---- test/instaloader_unittests.py | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 9c1e0cf..8c238dd 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -358,18 +358,18 @@ class Instaloader: os.makedirs(os.path.dirname(filename), exist_ok=True) # Download the image(s) / video thumbnail and videos within sidecars if desired - downloaded = False + downloaded = True if self.download_pictures: if post.typename == 'GraphSidecar': edge_number = 1 for sidecar_node in post.get_sidecar_nodes(): # Download picture or video thumbnail if not sidecar_node.is_video or self.download_video_thumbnails is True: - downloaded |= self.download_pic(filename=filename, url=sidecar_node.display_url, + downloaded &= self.download_pic(filename=filename, url=sidecar_node.display_url, mtime=post.date_local, filename_suffix=str(edge_number)) # Additionally download video if available and desired if sidecar_node.is_video and self.download_videos is True: - downloaded |= self.download_pic(filename=filename, url=sidecar_node.video_url, + downloaded &= self.download_pic(filename=filename, url=sidecar_node.video_url, mtime=post.date_local, filename_suffix=str(edge_number)) edge_number += 1 elif post.typename == 'GraphImage': @@ -387,7 +387,7 @@ class Instaloader: # Download video if desired if post.is_video and self.download_videos is True: - downloaded |= self.download_pic(filename=filename, url=post.video_url, mtime=post.date_local) + downloaded &= self.download_pic(filename=filename, url=post.video_url, mtime=post.date_local) # Download geotags if desired if self.download_geotags and post.location: diff --git a/test/instaloader_unittests.py b/test/instaloader_unittests.py index aece971..7e80e64 100644 --- a/test/instaloader_unittests.py +++ b/test/instaloader_unittests.py @@ -63,6 +63,12 @@ class TestInstaloaderAnonymously(unittest.TestCase): def test_hashtag_download(self): self.L.download_hashtag(HASHTAG, NORMAL_MAX_COUNT) + def test_hashtag_paging(self): + for count, post in enumerate(self.L.get_hashtag_posts(HASHTAG)): + print(post) + if count == PAGING_MAX_COUNT: + break + def test_get_id_by_username(self): self.assertEqual(PUBLIC_PROFILE_ID, instaloader.Profile.from_username(self.L.context, PUBLIC_PROFILE).userid)