mirror of
https://github.com/instaloader/instaloader.git
synced 2026-10-16 13:48:03 -07:00
Merge branch 'master' into upcoming/v4.13
This commit is contained in:
@@ -351,7 +351,7 @@ single-line-if-stmt=no
|
|||||||
allow-any-import-level=
|
allow-any-import-level=
|
||||||
|
|
||||||
# Allow explicit reexports by alias from a package __init__.
|
# 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 imports from modules that define __all__.
|
||||||
allow-wildcard-with-all=no
|
allow-wildcard-with-all=no
|
||||||
|
|||||||
+24
-9
@@ -1,7 +1,7 @@
|
|||||||
"""Download pictures (or videos) along with their captions and other metadata from Instagram."""
|
"""Download pictures (or videos) along with their captions and other metadata from Instagram."""
|
||||||
|
|
||||||
|
|
||||||
__version__ = '4.12'
|
__version__ = '4.12.2'
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -13,11 +13,26 @@ else:
|
|||||||
win_unicode_console.enable()
|
win_unicode_console.enable()
|
||||||
|
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
from .instaloader import Instaloader
|
from .instaloader import Instaloader as Instaloader
|
||||||
from .instaloadercontext import InstaloaderContext, RateController
|
from .instaloadercontext import (InstaloaderContext as InstaloaderContext,
|
||||||
from .lateststamps import LatestStamps
|
RateController as RateController)
|
||||||
from .nodeiterator import NodeIterator, FrozenNodeIterator, resumable_iteration
|
from .lateststamps import LatestStamps as LatestStamps
|
||||||
from .structures import (Hashtag, Highlight, Post, PostSidecarNode, PostComment, PostCommentAnswer, PostLocation,
|
from .nodeiterator import (NodeIterator as NodeIterator,
|
||||||
Profile, Story, StoryItem, TopSearchResults, TitlePic,
|
FrozenNodeIterator as FrozenNodeIterator,
|
||||||
load_structure_from_file, save_structure_to_file,
|
resumable_iteration as resumable_iteration)
|
||||||
load_structure, get_json_structure)
|
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)
|
||||||
|
|||||||
@@ -722,7 +722,7 @@ class Instaloader:
|
|||||||
# Download the image(s) / video thumbnail and videos within sidecars if desired
|
# Download the image(s) / video thumbnail and videos within sidecars if desired
|
||||||
downloaded = True
|
downloaded = True
|
||||||
if post.typename == 'GraphSidecar':
|
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(
|
if not _all_already_downloaded(
|
||||||
filename_template, enumerate(
|
filename_template, enumerate(
|
||||||
(post.get_is_videos()[i]
|
(post.get_is_videos()[i]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
|||||||
from lzma import LZMAError
|
from lzma import LZMAError
|
||||||
from typing import Any, Callable, Dict, Iterable, Iterator, NamedTuple, Optional, Tuple, TypeVar
|
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
|
from .instaloadercontext import InstaloaderContext
|
||||||
|
|
||||||
class FrozenNodeIterator(NamedTuple):
|
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.
|
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)
|
_shelf_life = timedelta(days=29)
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
@@ -98,23 +98,13 @@ class NodeIterator(Iterator[T]):
|
|||||||
pagination_variables: Dict[str, Any] = {'first': NodeIterator._graphql_page_length}
|
pagination_variables: Dict[str, Any] = {'first': NodeIterator._graphql_page_length}
|
||||||
if after is not None:
|
if after is not None:
|
||||||
pagination_variables['after'] = after
|
pagination_variables['after'] = after
|
||||||
try:
|
data = self._edge_extractor(
|
||||||
data = self._edge_extractor(
|
self._context.graphql_query(
|
||||||
self._context.graphql_query(
|
self._query_hash, {**self._query_variables, **pagination_variables}, self._query_referer
|
||||||
self._query_hash, {**self._query_variables, **pagination_variables}, self._query_referer
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self._best_before = datetime.now() + NodeIterator._shelf_life
|
)
|
||||||
return data
|
self._best_before = datetime.now() + NodeIterator._shelf_life
|
||||||
except QueryReturnedBadRequestException:
|
return data
|
||||||
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
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
|||||||
Reference in New Issue
Block a user