[fikfap] support main page post URLs (#9026)
* Update fikfap.py to allow for extracting a single post from the main page
Current post extractor only works on links to posts
on user pages but not on direct links to posts
* include 'singlepost' logic into existing 'post' extractor
---------
Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
This commit is contained in:
@@ -67,20 +67,17 @@ class FikfapExtractor(Extractor):
|
||||
|
||||
class FikfapPostExtractor(FikfapExtractor):
|
||||
subcategory = "post"
|
||||
pattern = BASE_PATTERN + r"/user/(\w+)/post/(\d+)"
|
||||
pattern = BASE_PATTERN + r"/(?:user/\w+/)?post/(\d+)"
|
||||
example = "https://fikfap.com/user/USER/post/12345"
|
||||
|
||||
def posts(self):
|
||||
user, pid = self.groups
|
||||
pid = self.groups[0]
|
||||
|
||||
url = f"{self.root_api}/profile/username/{user}/posts"
|
||||
params = {"amount" : "1", "startId": pid}
|
||||
posts = self.request_api(url, params)
|
||||
url = f"{self.root_api}/posts/{pid}"
|
||||
post = self.request_api(url, None)
|
||||
|
||||
pid = int(pid)
|
||||
for post in posts:
|
||||
if post["postId"] == pid:
|
||||
return (post,)
|
||||
if post["postId"] == int(pid):
|
||||
return (post,)
|
||||
raise exception.NotFoundError("post")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user