[fikfap] improve URL patterns

use '[^/?#]+' for names
This commit is contained in:
Mike Fährmann
2026-02-10 07:54:32 +01:00
parent 52a5e39fc6
commit 640d5f1621
2 changed files with 13 additions and 3 deletions

View File

@@ -67,7 +67,7 @@ class FikfapExtractor(Extractor):
class FikfapPostExtractor(FikfapExtractor): class FikfapPostExtractor(FikfapExtractor):
subcategory = "post" subcategory = "post"
pattern = BASE_PATTERN + r"/(?:user/\w+/)?post/(\d+)" pattern = BASE_PATTERN + r"/(?:user/[^/?#]+/)?post/(\d+)"
example = "https://fikfap.com/user/USER/post/12345" example = "https://fikfap.com/user/USER/post/12345"
def posts(self): def posts(self):
@@ -83,7 +83,7 @@ class FikfapPostExtractor(FikfapExtractor):
class FikfapUserExtractor(FikfapExtractor): class FikfapUserExtractor(FikfapExtractor):
subcategory = "user" subcategory = "user"
pattern = BASE_PATTERN + r"/user/([\w-]+)" pattern = BASE_PATTERN + r"/user/([^/?#]+)"
example = "https://fikfap.com/user/USER" example = "https://fikfap.com/user/USER"
def posts(self): def posts(self):
@@ -105,7 +105,7 @@ class FikfapUserExtractor(FikfapExtractor):
class FikfapHashtagExtractor(FikfapExtractor): class FikfapHashtagExtractor(FikfapExtractor):
subcategory = "hashtag" subcategory = "hashtag"
directory_fmt = ("{category}", "{hashtag}") directory_fmt = ("{category}", "{hashtag}")
pattern = BASE_PATTERN + r"/hash/([\w-]+)" pattern = BASE_PATTERN + r"/hash/([^/?#]+)"
example = "https://fikfap.com/hash/HASH" example = "https://fikfap.com/hash/HASH"
def posts(self): def posts(self):

View File

@@ -113,6 +113,11 @@ __tests__ = (
"userId" : "32f4c8d6-2409-4db8-9e66-d3b5ff0c1a98", "userId" : "32f4c8d6-2409-4db8-9e66-d3b5ff0c1a98",
}, },
{
"#url" : "https://fikfap.com/user/Hot-sauce-34/post/1026309",
"#class" : fikfap.FikfapPostExtractor,
},
{ {
"#url" : "https://fikfap.com/user/alinevs", "#url" : "https://fikfap.com/user/alinevs",
"#class" : fikfap.FikfapUserExtractor, "#class" : fikfap.FikfapUserExtractor,
@@ -149,4 +154,9 @@ __tests__ = (
"hashtag" : "outercourse", "hashtag" : "outercourse",
}, },
{
"#url" : "https://fikfap.com/hash/foo-bar",
"#class" : fikfap.FikfapHashtagExtractor,
},
) )