1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[wikimedia] add 'wiki' extractor

This commit is contained in:
ClosedPort22 2024-08-18 13:00:59 +08:00
parent a3b2c88fbe
commit 33d2ddd9fb
No known key found for this signature in database
3 changed files with 32 additions and 0 deletions

View File

@ -193,3 +193,19 @@ class WikimediaArticleExtractor(WikimediaExtractor):
def prepare(self, image):
WikimediaExtractor.prepare(image)
image["page"] = self.title
class WikimediaWikiExtractor(WikimediaExtractor):
"""Extractor for all files on a MediaWiki instance"""
subcategory = "wiki"
pattern = BASE_PATTERN + r"/?$"
example = "https://en.wikipedia.org/"
def __init__(self, match):
WikimediaExtractor.__init__(self, match)
# ref: https://www.mediawiki.org/wiki/API:Allpages
self.params = {
"generator" : "allpages",
"gapnamespace": 6, # "File" namespace
}

View File

@ -98,4 +98,12 @@ __tests__ = (
"#class" : wikimedia.WikimediaArticleExtractor,
},
{
"#url" : "https://youtube.fandom.com",
"#category": ("wikimedia", "fandom-youtube", "wiki"),
"#class" : wikimedia.WikimediaWikiExtractor,
"#range" : "1-20",
"#count" : 20,
},
)

View File

@ -50,4 +50,12 @@ __tests__ = (
"#class" : wikimedia.WikimediaArticleExtractor,
},
{
"#url" : "https://en.wikipedia.org",
"#category": ("wikimedia", "wikipedia", "wiki"),
"#class" : wikimedia.WikimediaWikiExtractor,
"#range" : "1-10",
"#count" : 10,
},
)