[instagram] add 'max-posts' option (#6054)

pull/6104/head
Mike Fährmann 1 month ago
parent 6af26a424a
commit f32e10f6a5
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -2435,6 +2435,16 @@ Description
It is possible to use ``"all"`` instead of listing all values separately.
extractor.instagram.max-posts
-----------------------------
Type
``integer``
Default
``null``
Description
Limit the number of posts to download.
extractor.instagram.metadata
----------------------------
Type

@ -12,6 +12,7 @@
from .common import Extractor, Message
from .. import text, util, exception
from ..cache import cache, memcache
import itertools
import binascii
import json
import re
@ -57,12 +58,17 @@ class InstagramExtractor(Extractor):
data = self.metadata()
videos = self.config("videos", True)
previews = self.config("previews", False)
max_posts = self.config("max-posts")
video_headers = {"User-Agent": "Mozilla/5.0"}
order = self.config("order-files")
reverse = order[0] in ("r", "d") if order else False
for post in self.posts():
posts = self.posts()
if max_posts:
posts = itertools.islice(posts, max_posts)
for post in posts:
if "__typename" in post:
post = self._parse_post_graphql(post)

Loading…
Cancel
Save