1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[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
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
4 changed files with 47 additions and 10 deletions

View File

@ -670,7 +670,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>pixivFANBOX</td>
<td>https://www.fanbox.cc/</td>
<td>Creators, Posts</td>
<td>Creators, Home Feed, Posts, Pixiv Redirects, Supported User Feed</td>
<td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td>
</tr>
<tr>

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"

View File

@ -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": "",
},

View File

@ -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"),