From 66c257362dd0b7c521c57daa29ddeaa10c31f10e Mon Sep 17 00:00:00 2001 From: Seamus Mullan <43112447+SeamusMullan@users.noreply.github.com> Date: Wed, 3 Jul 2024 06:19:16 +0000 Subject: [PATCH 1/5] Fix for issue #1085 (#2214) Implement check for post.mediacount before checking if posts have been downloaded. --------- Co-authored-by: Alexander Graf <17130992+aandergr@users.noreply.github.com> --- instaloader/instaloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 062c983..7543df1 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -722,7 +722,7 @@ class Instaloader: # Download the image(s) / video thumbnail and videos within sidecars if desired downloaded = True if post.typename == 'GraphSidecar': - if self.download_pictures or self.download_videos: + if (self.download_pictures or self.download_videos) and post.mediacount > 0: if not _all_already_downloaded( filename_template, enumerate( (post.get_is_videos()[i] From b4cb9ea83a9c88b726e4fe81f0d668b462abfedd Mon Sep 17 00:00:00 2001 From: Liponex <43170114+liponex@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:46:00 +0500 Subject: [PATCH 2/5] PEP 561 compliance enhancement (#2314) --- .pylintrc | 2 +- instaloader/__init__.py | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.pylintrc b/.pylintrc index 1d438dc..73fb4e1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -351,7 +351,7 @@ single-line-if-stmt=no allow-any-import-level= # Allow explicit reexports by alias from a package __init__. -allow-reexport-from-package=no +allow-reexport-from-package=yes # Allow wildcard imports from modules that define __all__. allow-wildcard-with-all=no diff --git a/instaloader/__init__.py b/instaloader/__init__.py index 39e7538..d775104 100644 --- a/instaloader/__init__.py +++ b/instaloader/__init__.py @@ -13,11 +13,26 @@ else: win_unicode_console.enable() from .exceptions import * -from .instaloader import Instaloader -from .instaloadercontext import InstaloaderContext, RateController -from .lateststamps import LatestStamps -from .nodeiterator import NodeIterator, FrozenNodeIterator, resumable_iteration -from .structures import (Hashtag, Highlight, Post, PostSidecarNode, PostComment, PostCommentAnswer, PostLocation, - Profile, Story, StoryItem, TopSearchResults, TitlePic, - load_structure_from_file, save_structure_to_file, - load_structure, get_json_structure) +from .instaloader import Instaloader as Instaloader +from .instaloadercontext import (InstaloaderContext as InstaloaderContext, + RateController as RateController) +from .lateststamps import LatestStamps as LatestStamps +from .nodeiterator import (NodeIterator as NodeIterator, + FrozenNodeIterator as FrozenNodeIterator, + resumable_iteration as resumable_iteration) +from .structures import (Hashtag as Hashtag, + Highlight as Highlight, + Post as Post, + PostSidecarNode as PostSidecarNode, + PostComment as PostComment, + PostCommentAnswer as PostCommentAnswer, + PostLocation as PostLocation, + Profile as Profile, + Story as Story, + StoryItem as StoryItem, + TopSearchResults as TopSearchResults, + TitlePic as TitlePic, + load_structure_from_file as load_structure_from_file, + save_structure_to_file as save_structure_to_file, + load_structure as load_structure, + get_json_structure as get_json_structure) From 7dac8ad1e59a99388511618eebeaaa88777a9906 Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Wed, 31 Jul 2024 08:47:41 +0200 Subject: [PATCH 3/5] Release of Version 4.12.1 --- instaloader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/__init__.py b/instaloader/__init__.py index d775104..21eaf11 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.12' +__version__ = '4.12.1' try: From e3b8c38f8ce4323f3ed755aaef16207ea46658e2 Mon Sep 17 00:00:00 2001 From: Caramel7 <133055232+Caramel7@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:00:19 +0200 Subject: [PATCH 4/5] Reduce GraphQL page length to 12 (#2332) Fixes #2319. --- instaloader/nodeiterator.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/instaloader/nodeiterator.py b/instaloader/nodeiterator.py index 37544d7..2c8b583 100644 --- a/instaloader/nodeiterator.py +++ b/instaloader/nodeiterator.py @@ -7,7 +7,7 @@ from datetime import datetime, timedelta from lzma import LZMAError from typing import Any, Callable, Dict, Iterable, Iterator, NamedTuple, Optional, Tuple, TypeVar -from .exceptions import AbortDownloadException, InvalidArgumentException, QueryReturnedBadRequestException +from .exceptions import AbortDownloadException, InvalidArgumentException from .instaloadercontext import InstaloaderContext class FrozenNodeIterator(NamedTuple): @@ -66,7 +66,7 @@ class NodeIterator(Iterator[T]): See also :func:`resumable_iteration` for a high-level context manager that handles a resumable iteration. """ - _graphql_page_length = 50 + _graphql_page_length = 12 _shelf_life = timedelta(days=29) def __init__(self, @@ -98,23 +98,13 @@ class NodeIterator(Iterator[T]): pagination_variables: Dict[str, Any] = {'first': NodeIterator._graphql_page_length} if after is not None: pagination_variables['after'] = after - try: - data = self._edge_extractor( - self._context.graphql_query( - self._query_hash, {**self._query_variables, **pagination_variables}, self._query_referer - ) + data = self._edge_extractor( + self._context.graphql_query( + self._query_hash, {**self._query_variables, **pagination_variables}, self._query_referer ) - self._best_before = datetime.now() + NodeIterator._shelf_life - return data - except QueryReturnedBadRequestException: - new_page_length = int(NodeIterator._graphql_page_length / 2) - if new_page_length >= 12: - NodeIterator._graphql_page_length = new_page_length - self._context.error("HTTP Error 400 (Bad Request) on GraphQL Query. Retrying with shorter page length.", - repeat_at_end=False) - return self._query(after) - else: - raise + ) + self._best_before = datetime.now() + NodeIterator._shelf_life + return data def __iter__(self): return self From 754c3845d723864dc5b089fd2be7d7a24b2ac838 Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:00:58 +0200 Subject: [PATCH 5/5] Release of Version 4.12.2 --- instaloader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/__init__.py b/instaloader/__init__.py index 21eaf11..5f6bb20 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.12.1' +__version__ = '4.12.2' try: