diff --git a/docs/supportedsites.md b/docs/supportedsites.md index ddf4a0d9..29232591 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -670,7 +670,7 @@ Consider all listed sites to potentially be NSFW. pixivFANBOX https://www.fanbox.cc/ - Creators, Posts + Creators, Home Feed, Posts, Pixiv Redirects, Supported User Feed Cookies diff --git a/gallery_dl/extractor/fanbox.py b/gallery_dl/extractor/fanbox.py index 61a39283..2223403e 100644 --- a/gallery_dl/extractor/fanbox.py +++ b/gallery_dl/extractor/fanbox.py @@ -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" diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 022a99d4..1d55291c 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -153,6 +153,7 @@ SUBCATEGORY_MAP = { "art" : "Art", "audio" : "Audio", "doujin" : "Doujin", + "home" : "Home Feed", "image" : "individual Images", "index" : "Site Index", "issue" : "Comic Issues", @@ -192,7 +193,8 @@ SUBCATEGORY_MAP = { "watch-posts": "", }, "fanbox": { - "redirect": "", + "supporting": "Supported User Feed", + "redirect" : "Pixiv Redirects", }, "fapello": { "path": "Videos, Trending Posts, Popular Videos, Top Models", @@ -200,7 +202,6 @@ SUBCATEGORY_MAP = { "hatenablog": { "archive": "Archive", "entry" : "Individual Posts", - "home" : "Home Feed", }, "hentaifoundry": { "story": "", @@ -256,14 +257,10 @@ SUBCATEGORY_MAP = { "gifs": "", }, "raddle": { - "home" : "Home Feed", "usersubmissions": "User Profiles", "post" : "Individual Posts", "shorturl" : "", }, - "reddit": { - "home": "Home Feed", - }, "redgifs": { "collections": "", }, diff --git a/test/results/fanbox.py b/test/results/fanbox.py index b47b72f8..d5910927 100644 --- a/test/results/fanbox.py +++ b/test/results/fanbox.py @@ -131,6 +131,23 @@ __tests__ = ( "#sha1_url": "c92ddd06f2efc4a5fe30ec67e21544f79a5c4062", }, +{ + "#url" : "https://fanbox.cc/", + "#category": ("", "fanbox", "home"), + "#class" : fanbox.FanboxHomeExtractor, + "#auth" : True, + "#range" : "1-10", + "#count" : 10, +}, + +{ + "#url" : "https://fanbox.cc/home/supporting", + "#category": ("", "fanbox", "supporting"), + "#class" : fanbox.FanboxSupportingExtractor, + "#auth" : True, + "#count" : 0, +}, + { "#url" : "https://www.pixiv.net/fanbox/creator/52336352", "#category": ("", "fanbox", "redirect"),