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

[patreon] support 'id:<campaign_id>' in place of a user name

https://patreon.com/id:12345
… and remove 'campaign-id' config option
This commit is contained in:
Mike Fährmann 2023-11-04 00:17:41 +01:00
parent 3984a49abf
commit 007c433677
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 18 additions and 20 deletions

View File

@ -2440,20 +2440,6 @@ Description
Note: This requires 1 additional HTTP request per post.
extractor.patreon.campaign-id
-----------------------------
Type
``string``
Default
``"auto"``
Description
Alternative way of specifying the ``campaign_id`` value of a creator
in case the automatic extraction method no longer functions.
Another way of specifying this value is using a ``c`` or ``campaign_id``
URL query parameter, e,g, ``https://www.patreon.com/NAME?c=12345``.
extractor.patreon.files
-----------------------
Type

View File

@ -296,9 +296,8 @@ class PatreonCreatorExtractor(PatreonExtractor):
return self._pagination(url)
def _get_campaign_id(self, query):
campaign_id = self.config("campaign-id")
if campaign_id and campaign_id != "auto":
return str(campaign_id)
if self.creator.startswith("id:"):
return self.creator[3:]
campaign_id = query.get("c") or query.get("campaign_id")
if campaign_id:
@ -316,7 +315,8 @@ class PatreonCreatorExtractor(PatreonExtractor):
data = self._extract_bootstrap(page)
return data["campaign"]["data"]["id"]
except (KeyError, ValueError) as exc:
self.log.debug(data)
if data:
self.log.debug(data)
raise exception.StopExtraction(
"Unable to extract campaign ID (%s: %s)",
exc.__class__.__name__, exc)

View File

@ -14,8 +14,8 @@ __tests__ = (
"#url" : "https://www.patreon.com/koveliana",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
"#range" : "1-25",
"#count" : ">= 25",
"#range" : "1-15",
"#count" : 15,
"attachments" : list,
"comment_count": int,
@ -58,6 +58,18 @@ __tests__ = (
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/user?c=369707",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/id:369707",
"#category": ("", "patreon", "creator"),
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/home",
"#category": ("", "patreon", "user"),