From 33fe1b68b7ea9e8e610f5d1b06b43be8c41903da Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Sun, 18 Aug 2024 13:32:26 +0800 Subject: [PATCH] [wikimedia] add 'limit' option --- docs/configuration.rst | 12 ++++++++++++ gallery_dl/extractor/wikimedia.py | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index 633c913f..9f4a81c7 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -4536,6 +4536,18 @@ Description Download video files. +extractor.wikimedia.limit +------------------------- +Type + ``integer`` +Default + ``10`` +Description + Number of results to return in a single API query. + + The value must be between 10 and 500. + + extractor.ytdl.cmdline-args --------------------------- Type diff --git a/gallery_dl/extractor/wikimedia.py b/gallery_dl/extractor/wikimedia.py index 9aaa88a5..dbcc1e27 100644 --- a/gallery_dl/extractor/wikimedia.py +++ b/gallery_dl/extractor/wikimedia.py @@ -29,6 +29,8 @@ class WikimediaExtractor(BaseExtractor): self.category = "{}-{}".format( self.category, self.root.partition(".")[0].rpartition("/")[2]) + self.per_page = self.config("limit", 10) + def _init(self): api_path = self.config_instance("api-path") if api_path: @@ -179,6 +181,7 @@ class WikimediaArticleExtractor(WikimediaExtractor): "generator": "categorymembers", "gcmtitle" : path, "gcmtype" : "file", + "gcmlimit" : self.per_page, } elif prefix == "file": self.params = { @@ -187,6 +190,7 @@ class WikimediaArticleExtractor(WikimediaExtractor): else: self.params = { "generator": "images", + "gimlimit" : self.per_page, "titles" : path, } @@ -208,4 +212,5 @@ class WikimediaWikiExtractor(WikimediaExtractor): self.params = { "generator" : "allpages", "gapnamespace": 6, # "File" namespace + "gaplimit" : self.per_page, }