[fanbox] add 'home' and 'supporting' extractors (#5138)

This commit is contained in:
Mike Fährmann
2024-02-14 23:25:39 +01:00
parent 04e4ffc64c
commit c97b92cc35
4 changed files with 47 additions and 10 deletions

View File

@@ -11,7 +11,8 @@ from .. import text
from ..cache import memcache
import re
BASE_PATTERN = (
BASE_PATTERN = r"(?:https?://)?(?:www\.)?fanbox\.cc"
USER_PATTERN = (
r"(?:https?://)?(?:"
r"(?!www\.)([\w-]+)\.fanbox\.cc|"
r"(?:www\.)?fanbox\.cc/@([\w-]+))"
@@ -290,7 +291,7 @@ class FanboxExtractor(Extractor):
class FanboxCreatorExtractor(FanboxExtractor):
"""Extractor for a Fanbox creator's works"""
subcategory = "creator"
pattern = BASE_PATTERN + r"(?:/posts)?/?$"
pattern = USER_PATTERN + r"(?:/posts)?/?$"
example = "https://USER.fanbox.cc/"
def __init__(self, match):
@@ -305,7 +306,7 @@ class FanboxCreatorExtractor(FanboxExtractor):
class FanboxPostExtractor(FanboxExtractor):
"""Extractor for media from a single Fanbox post"""
subcategory = "post"
pattern = BASE_PATTERN + r"/posts/(\d+)"
pattern = USER_PATTERN + r"/posts/(\d+)"
example = "https://USER.fanbox.cc/posts/12345"
def __init__(self, match):
@@ -316,6 +317,28 @@ class FanboxPostExtractor(FanboxExtractor):
return (self._get_post_data(self.post_id),)
class FanboxHomeExtractor(FanboxExtractor):
"""Extractor for your Fanbox home feed"""
subcategory = "home"
pattern = BASE_PATTERN + r"/?$"
example = "https://fanbox.cc/"
def posts(self):
url = "https://api.fanbox.cc/post.listHome?limit=10"
return self._pagination(url)
class FanboxSupportingExtractor(FanboxExtractor):
"""Extractor for your supported Fanbox users feed"""
subcategory = "supporting"
pattern = BASE_PATTERN + r"/home/supporting"
example = "https://fanbox.cc/home/supporting"
def posts(self):
url = "https://api.fanbox.cc/post.listSupporting?limit=10"
return self._pagination(url)
class FanboxRedirectExtractor(Extractor):
"""Extractor for pixiv redirects to fanbox.cc"""
category = "fanbox"