[artstation] add 'max-posts' option (#3270)

This commit is contained in:
Mike Fährmann
2022-11-23 22:00:18 +01:00
parent b1ad6f2289
commit 501d9bccfe
2 changed files with 17 additions and 1 deletions

View File

@@ -885,6 +885,16 @@ Description
Try to follow external URLs of embedded players. Try to follow external URLs of embedded players.
extractor.artstation.max-posts
------------------------------
Type
``integer``
Default
``null``
Description
Limit the number of posts/projects to download.
extractor.artstation.search.pro-first extractor.artstation.search.pro-first
------------------------------------- -------------------------------------
Type Type

View File

@@ -10,6 +10,7 @@
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, util, exception from .. import text, util, exception
import itertools
import random import random
import string import string
@@ -31,7 +32,12 @@ class ArtstationExtractor(Extractor):
def items(self): def items(self):
data = self.metadata() data = self.metadata()
for project in self.projects(): projects = self.projects()
max_posts = self.config("max-posts")
if max_posts:
projects = itertools.islice(projects, max_posts)
for project in projects:
for num, asset in enumerate( for num, asset in enumerate(
self.get_project_assets(project["hash_id"]), 1): self.get_project_assets(project["hash_id"]), 1):
asset.update(data) asset.update(data)