[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:
@@ -2440,20 +2440,6 @@ Description
|
|||||||
Note: This requires 1 additional HTTP request per post.
|
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
|
extractor.patreon.files
|
||||||
-----------------------
|
-----------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -296,9 +296,8 @@ class PatreonCreatorExtractor(PatreonExtractor):
|
|||||||
return self._pagination(url)
|
return self._pagination(url)
|
||||||
|
|
||||||
def _get_campaign_id(self, query):
|
def _get_campaign_id(self, query):
|
||||||
campaign_id = self.config("campaign-id")
|
if self.creator.startswith("id:"):
|
||||||
if campaign_id and campaign_id != "auto":
|
return self.creator[3:]
|
||||||
return str(campaign_id)
|
|
||||||
|
|
||||||
campaign_id = query.get("c") or query.get("campaign_id")
|
campaign_id = query.get("c") or query.get("campaign_id")
|
||||||
if campaign_id:
|
if campaign_id:
|
||||||
@@ -316,7 +315,8 @@ class PatreonCreatorExtractor(PatreonExtractor):
|
|||||||
data = self._extract_bootstrap(page)
|
data = self._extract_bootstrap(page)
|
||||||
return data["campaign"]["data"]["id"]
|
return data["campaign"]["data"]["id"]
|
||||||
except (KeyError, ValueError) as exc:
|
except (KeyError, ValueError) as exc:
|
||||||
self.log.debug(data)
|
if data:
|
||||||
|
self.log.debug(data)
|
||||||
raise exception.StopExtraction(
|
raise exception.StopExtraction(
|
||||||
"Unable to extract campaign ID (%s: %s)",
|
"Unable to extract campaign ID (%s: %s)",
|
||||||
exc.__class__.__name__, exc)
|
exc.__class__.__name__, exc)
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ __tests__ = (
|
|||||||
"#url" : "https://www.patreon.com/koveliana",
|
"#url" : "https://www.patreon.com/koveliana",
|
||||||
"#category": ("", "patreon", "creator"),
|
"#category": ("", "patreon", "creator"),
|
||||||
"#class" : patreon.PatreonCreatorExtractor,
|
"#class" : patreon.PatreonCreatorExtractor,
|
||||||
"#range" : "1-25",
|
"#range" : "1-15",
|
||||||
"#count" : ">= 25",
|
"#count" : 15,
|
||||||
|
|
||||||
"attachments" : list,
|
"attachments" : list,
|
||||||
"comment_count": int,
|
"comment_count": int,
|
||||||
@@ -58,6 +58,18 @@ __tests__ = (
|
|||||||
"#class" : patreon.PatreonCreatorExtractor,
|
"#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",
|
"#url" : "https://www.patreon.com/home",
|
||||||
"#category": ("", "patreon", "user"),
|
"#category": ("", "patreon", "user"),
|
||||||
|
|||||||
Reference in New Issue
Block a user