[instagram] add 'max-posts' option (#6054)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user