[patreon] support '/c/' before creator name in URLs (#6348)

and avoid '/CREATOR/posts' redirects
This commit is contained in:
Mike Fährmann
2024-10-21 14:01:31 +02:00
parent 00436d6027
commit eacd4479a2
2 changed files with 8 additions and 3 deletions

View File

@@ -311,7 +311,7 @@ class PatreonCreatorExtractor(PatreonExtractor):
subcategory = "creator"
pattern = (r"(?:https?://)?(?:www\.)?patreon\.com"
r"/(?!(?:home|join|posts|login|signup)(?:$|[/?#]))"
r"([^/?#]+)(?:/posts)?/?(?:\?([^#]+))?")
r"(?:c/)?([^/?#]+)(?:/posts)?/?(?:\?([^#]+))?")
example = "https://www.patreon.com/USER"
def posts(self):
@@ -341,9 +341,9 @@ class PatreonCreatorExtractor(PatreonExtractor):
user_id = query.get("u")
if user_id:
url = "{}/user/posts?u={}".format(self.root, user_id)
url = "{}/user?u={}".format(self.root, user_id)
else:
url = "{}/{}/posts".format(self.root, creator)
url = "{}/{}".format(self.root, creator)
page = self.request(url, notfound="creator").text
try:

View File

@@ -43,6 +43,11 @@ __tests__ = (
"#exception": exception.NotFoundError,
},
{
"#url" : "https://www.patreon.com/c/koveliana",
"#class" : patreon.PatreonCreatorExtractor,
},
{
"#url" : "https://www.patreon.com/user?u=2931440",
"#class" : patreon.PatreonCreatorExtractor,