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

[wikimedia] combine most wikimedia.org sites (#1443)

add wikidata.org and wikivoyage.org
This commit is contained in:
Mike Fährmann 2024-02-10 03:00:58 +01:00
parent c7d17f1111
commit af61d2b037
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
5 changed files with 59 additions and 73 deletions

View File

@ -124,7 +124,7 @@ Consider all listed sites to potentially be NSFW.
<tr> <tr>
<td>Bluesky</td> <td>Bluesky</td>
<td>https://bsky.app/</td> <td>https://bsky.app/</td>
<td>Likes, Media Files, Posts, Replies, User Profiles</td> <td>Feeds, Followed Users, Likes, Lists, Media Files, Posts, Replies, User Profiles</td>
<td>Supported</td> <td>Supported</td>
</tr> </tr>
<tr> <tr>
@ -1470,44 +1470,8 @@ Consider all listed sites to potentially be NSFW.
<td colspan="4"><strong>Wikimedia Instances</strong></td> <td colspan="4"><strong>Wikimedia Instances</strong></td>
</tr> </tr>
<tr> <tr>
<td>Wikipedia</td> <td>Wikimedia</td>
<td>https://www.wikipedia.org/</td> <td>https://www.wikimedia.org/</td>
<td>Articles</td>
<td></td>
</tr>
<tr>
<td>Wiktionary</td>
<td>https://www.wiktionary.org/</td>
<td>Articles</td>
<td></td>
</tr>
<tr>
<td>Wikiquote</td>
<td>https://www.wikiquote.org/</td>
<td>Articles</td>
<td></td>
</tr>
<tr>
<td>Wikibooks</td>
<td>https://www.wikibooks.org/</td>
<td>Articles</td>
<td></td>
</tr>
<tr>
<td>Wikisource</td>
<td>https://www.wikisource.org/</td>
<td>Articles</td>
<td></td>
</tr>
<tr>
<td>Wikinews</td>
<td>https://www.wikinews.org/</td>
<td>Articles</td>
<td></td>
</tr>
<tr>
<td>Wikiversity</td>
<td>https://www.wikiversity.org/</td>
<td>Articles</td> <td>Articles</td>
<td></td> <td></td>
</tr> </tr>

View File

@ -25,7 +25,9 @@ class WikimediaExtractor(BaseExtractor):
BaseExtractor.__init__(self, match) BaseExtractor.__init__(self, match)
path = match.group(match.lastindex) path = match.group(match.lastindex)
if self.category == "fandom": if self.category == "wikimedia":
self.category = self.root.split(".")[-2]
elif self.category == "fandom":
self.category = \ self.category = \
"fandom-" + self.root.partition(".")[0].rpartition("/")[2] "fandom-" + self.root.partition(".")[0].rpartition("/")[2]
@ -119,39 +121,12 @@ class WikimediaExtractor(BaseExtractor):
BASE_PATTERN = WikimediaExtractor.update({ BASE_PATTERN = WikimediaExtractor.update({
"wikipedia": { "wikimedia": {
"root": None, "root": None,
"pattern": r"[a-z]{2,}\.wikipedia\.org", "pattern": r"[a-z]{2,}\."
"api-path": "/w/api.php", r"wik(?:i(?:pedia|quote|books|source|news|versity|data"
}, r"|voyage)|tionary)"
"wiktionary": { r"\.org",
"root": None,
"pattern": r"[a-z]{2,}\.wiktionary\.org",
"api-path": "/w/api.php",
},
"wikiquote": {
"root": None,
"pattern": r"[a-z]{2,}\.wikiquote\.org",
"api-path": "/w/api.php",
},
"wikibooks": {
"root": None,
"pattern": r"[a-z]{2,}\.wikibooks\.org",
"api-path": "/w/api.php",
},
"wikisource": {
"root": None,
"pattern": r"[a-z]{2,}\.wikisource\.org",
"api-path": "/w/api.php",
},
"wikinews": {
"root": None,
"pattern": r"[a-z]{2,}\.wikinews\.org",
"api-path": "/w/api.php",
},
"wikiversity": {
"root": None,
"pattern": r"[a-z]{2,}\.wikiversity\.org",
"api-path": "/w/api.php", "api-path": "/w/api.php",
}, },
"wikispecies": { "wikispecies": {

View File

@ -325,7 +325,8 @@ BASE_MAP = {
} }
URL_MAP = { URL_MAP = {
"blogspot": "https://www.blogger.com/", "blogspot" : "https://www.blogger.com/",
"wikimedia": "https://www.wikimedia.org/",
} }
_OAUTH = '<a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a>' _OAUTH = '<a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a>'

23
test/results/wikidata.py Normal file
View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
from gallery_dl.extractor import wikimedia
__tests__ = (
{
"#url" : "https://www.wikidata.org/wiki/Title",
"#category": ("wikimedia", "wikidata", "article"),
"#class" : wikimedia.WikimediaArticleExtractor,
},
{
"#url" : "https://en.wikidata.org/wiki/Category:Title",
"#category": ("wikimedia", "wikidata", "category"),
"#class" : wikimedia.WikimediaArticleExtractor,
},
)

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
from gallery_dl.extractor import wikimedia
__tests__ = (
{
"#url" : "https://www.wikivoyage.org/wiki/Title",
"#category": ("wikimedia", "wikivoyage", "article"),
"#class" : wikimedia.WikimediaArticleExtractor,
},
{
"#url" : "https://en.wikivoyage.org/wiki/Category:Title",
"#category": ("wikimedia", "wikivoyage", "category"),
"#class" : wikimedia.WikimediaArticleExtractor,
},
)