aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/furaffinity.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/furaffinity.py')
-rw-r--r--gallery_dl/extractor/furaffinity.py133
1 files changed, 21 insertions, 112 deletions
diff --git a/gallery_dl/extractor/furaffinity.py b/gallery_dl/extractor/furaffinity.py
index ec9cd94..56721d0 100644
--- a/gallery_dl/extractor/furaffinity.py
+++ b/gallery_dl/extractor/furaffinity.py
@@ -20,7 +20,8 @@ class FuraffinityExtractor(Extractor):
directory_fmt = ("{category}", "{user!l}")
filename_fmt = "{id}{title:? //}.{extension}"
archive_fmt = "{id}"
- cookiedomain = ".furaffinity.net"
+ cookies_domain = ".furaffinity.net"
+ cookies_names = ("a", "b")
root = "https://www.furaffinity.net"
_warning = True
@@ -29,6 +30,9 @@ class FuraffinityExtractor(Extractor):
self.user = match.group(1)
self.offset = 0
+ def _init(self):
+ self.external = self.config("external", False)
+
if self.config("descriptions") == "html":
self._process_description = str.strip
@@ -38,14 +42,12 @@ class FuraffinityExtractor(Extractor):
else:
self._new_layout = None
- def items(self):
-
if self._warning:
- if not self._check_cookies(("a", "b")):
+ if not self.cookies_check(self.cookies_names):
self.log.warning("no 'a' and 'b' session cookies set")
FuraffinityExtractor._warning = False
- external = self.config("external", False)
+ def items(self):
metadata = self.metadata()
for post_id in util.advance(self.posts(), self.offset):
post = self._parse_post(post_id)
@@ -55,7 +57,7 @@ class FuraffinityExtractor(Extractor):
yield Message.Directory, post
yield Message.Url, post["url"], post
- if external:
+ if self.external:
for url in text.extract_iter(
post["_description"], 'href="http', '"'):
yield Message.Queue, "http" + url, post
@@ -217,12 +219,7 @@ class FuraffinityGalleryExtractor(FuraffinityExtractor):
"""Extractor for a furaffinity user's gallery"""
subcategory = "gallery"
pattern = BASE_PATTERN + r"/gallery/([^/?#]+)"
- test = ("https://www.furaffinity.net/gallery/mirlinthloth/", {
- "pattern": r"https://d\d?\.f(uraffinity|acdn)\.net"
- r"/art/mirlinthloth/\d+/\d+.\w+\.\w+",
- "range": "45-50",
- "count": 6,
- })
+ example = "https://www.furaffinity.net/gallery/USER/"
def posts(self):
return self._pagination("gallery")
@@ -233,11 +230,7 @@ class FuraffinityScrapsExtractor(FuraffinityExtractor):
subcategory = "scraps"
directory_fmt = ("{category}", "{user!l}", "Scraps")
pattern = BASE_PATTERN + r"/scraps/([^/?#]+)"
- test = ("https://www.furaffinity.net/scraps/mirlinthloth/", {
- "pattern": r"https://d\d?\.f(uraffinity|acdn)\.net"
- r"/art/[^/]+(/stories)?/\d+/\d+.\w+.",
- "count": ">= 3",
- })
+ example = "https://www.furaffinity.net/scraps/USER/"
def posts(self):
return self._pagination("scraps")
@@ -248,13 +241,7 @@ class FuraffinityFavoriteExtractor(FuraffinityExtractor):
subcategory = "favorite"
directory_fmt = ("{category}", "{user!l}", "Favorites")
pattern = BASE_PATTERN + r"/favorites/([^/?#]+)"
- test = ("https://www.furaffinity.net/favorites/mirlinthloth/", {
- "pattern": r"https://d\d?\.f(uraffinity|acdn)\.net"
- r"/art/[^/]+/\d+/\d+.\w+\.\w+",
- "keyword": {"favorite_id": int},
- "range": "45-50",
- "count": 6,
- })
+ example = "https://www.furaffinity.net/favorites/USER/"
def posts(self):
return self._pagination_favorites()
@@ -271,19 +258,7 @@ class FuraffinitySearchExtractor(FuraffinityExtractor):
subcategory = "search"
directory_fmt = ("{category}", "Search", "{search}")
pattern = BASE_PATTERN + r"/search(?:/([^/?#]+))?/?[?&]([^#]+)"
- test = (
- ("https://www.furaffinity.net/search/?q=cute", {
- "pattern": r"https://d\d?\.f(uraffinity|acdn)\.net"
- r"/art/[^/]+/\d+/\d+.\w+\.\w+",
- "range": "45-50",
- "count": 6,
- }),
- # first page of search results (#2402)
- ("https://www.furaffinity.net/search/?q=leaf&range=1day", {
- "range": "1-3",
- "count": 3,
- }),
- )
+ example = "https://www.furaffinity.net/search/?q=QUERY"
def __init__(self, match):
FuraffinityExtractor.__init__(self, match)
@@ -302,65 +277,7 @@ class FuraffinityPostExtractor(FuraffinityExtractor):
"""Extractor for individual posts on furaffinity"""
subcategory = "post"
pattern = BASE_PATTERN + r"/(?:view|full)/(\d+)"
- test = (
- ("https://www.furaffinity.net/view/21835115/", {
- "pattern": r"https://d\d*\.f(uraffinity|acdn)\.net/(download/)?art"
- r"/mirlinthloth/music/1488278723/1480267446.mirlinthlot"
- r"h_dj_fennmink_-_bude_s_4_ever\.mp3",
- "keyword": {
- "artist" : "mirlinthloth",
- "artist_url" : "mirlinthloth",
- "date" : "dt:2016-11-27 17:24:06",
- "description": "A Song made playing the game Cosmic DJ.",
- "extension" : "mp3",
- "filename" : r"re:\d+\.\w+_dj_fennmink_-_bude_s_4_ever",
- "id" : 21835115,
- "tags" : list,
- "title" : "Bude's 4 Ever",
- "url" : r"re:https://d\d?\.f(uraffinity|acdn)\.net/art",
- "user" : "mirlinthloth",
- "views" : int,
- "favorites" : int,
- "comments" : int,
- "rating" : "General",
- "fa_category": "Music",
- "theme" : "All",
- "species" : "Unspecified / Any",
- "gender" : "Any",
- "width" : 120,
- "height" : 120,
- },
- }),
- # 'external' option (#1492)
- ("https://www.furaffinity.net/view/42166511/", {
- "options": (("external", True),),
- "pattern": r"https://d\d*\.f(uraffinity|acdn)\.net/"
- r"|http://www\.postybirb\.com",
- "count": 2,
- }),
- # no tags (#2277)
- ("https://www.furaffinity.net/view/45331225/", {
- "keyword": {
- "artist": "Kota_Remminders",
- "artist_url": "kotaremminders",
- "date": "dt:2022-01-03 17:49:33",
- "fa_category": "Adoptables",
- "filename": "1641232173.kotaremminders_chidopts1",
- "gender": "Any",
- "height": 905,
- "id": 45331225,
- "rating": "General",
- "species": "Unspecified / Any",
- "tags": [],
- "theme": "All",
- "title": "REMINDER",
- "width": 1280,
- },
- }),
- ("https://furaffinity.net/view/21835115/"),
- ("https://sfw.furaffinity.net/view/21835115/"),
- ("https://www.furaffinity.net/full/21835115/"),
- )
+ example = "https://www.furaffinity.net/view/12345/"
def posts(self):
post_id = self.user
@@ -371,18 +288,14 @@ class FuraffinityPostExtractor(FuraffinityExtractor):
class FuraffinityUserExtractor(FuraffinityExtractor):
"""Extractor for furaffinity user profiles"""
subcategory = "user"
- cookiedomain = None
+ cookies_domain = None
pattern = BASE_PATTERN + r"/user/([^/?#]+)"
- test = (
- ("https://www.furaffinity.net/user/mirlinthloth/", {
- "pattern": r"/gallery/mirlinthloth/$",
- }),
- ("https://www.furaffinity.net/user/mirlinthloth/", {
- "options": (("include", "all"),),
- "pattern": r"/(gallery|scraps|favorites)/mirlinthloth/$",
- "count": 3,
- }),
- )
+ example = "https://www.furaffinity.net/user/USER/"
+
+ def initialize(self):
+ pass
+
+ skip = Extractor.skip
def items(self):
base = "{}/{{}}/{}/".format(self.root, self.user)
@@ -397,11 +310,7 @@ class FuraffinityFollowingExtractor(FuraffinityExtractor):
"""Extractor for a furaffinity user's watched users"""
subcategory = "following"
pattern = BASE_PATTERN + "/watchlist/by/([^/?#]+)"
- test = ("https://www.furaffinity.net/watchlist/by/mirlinthloth/", {
- "pattern": FuraffinityUserExtractor.pattern,
- "range": "176-225",
- "count": 50,
- })
+ example = "https://www.furaffinity.net/watchlist/by/USER/"
def items(self):
url = "{}/watchlist/by/{}/".format(self.root, self.user)