[furaffinity:favorite] support URLs with custom start position
This commit is contained in:
@@ -168,8 +168,10 @@ class FuraffinityExtractor(Extractor):
|
|||||||
return
|
return
|
||||||
num += 1
|
num += 1
|
||||||
|
|
||||||
def _pagination_favorites(self):
|
def _pagination_favorites(self, start=None):
|
||||||
path = f"/favorites/{self.user}/"
|
path = f"/favorites/{self.user}/"
|
||||||
|
if start is not None:
|
||||||
|
path += start
|
||||||
|
|
||||||
while path:
|
while path:
|
||||||
page = self.request(self.root + path).text
|
page = self.request(self.root + path).text
|
||||||
@@ -271,11 +273,11 @@ class FuraffinityFavoriteExtractor(FuraffinityExtractor):
|
|||||||
"""Extractor for a furaffinity user's favorites"""
|
"""Extractor for a furaffinity user's favorites"""
|
||||||
subcategory = "favorite"
|
subcategory = "favorite"
|
||||||
directory_fmt = ("{category}", "{user!l}", "Favorites")
|
directory_fmt = ("{category}", "{user!l}", "Favorites")
|
||||||
pattern = BASE_PATTERN + r"/favorites/([^/?#]+)"
|
pattern = BASE_PATTERN + r"/favorites/([^/?#]+)(/\d+/(?:next|prev))?"
|
||||||
example = "https://www.furaffinity.net/favorites/USER/"
|
example = "https://www.furaffinity.net/favorites/USER/"
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
return self._pagination_favorites()
|
return self._pagination_favorites(self.groups[1])
|
||||||
|
|
||||||
def _parse_post(self, post_id):
|
def _parse_post(self, post_id):
|
||||||
if post := FuraffinityExtractor._parse_post(self, post_id):
|
if post := FuraffinityExtractor._parse_post(self, post_id):
|
||||||
|
|||||||
@@ -53,6 +53,19 @@ __tests__ = (
|
|||||||
"favorite_id": int,
|
"favorite_id": int,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://www.furaffinity.net/favorites/mirlinthloth/46682246/next?",
|
||||||
|
"#comment" : "custom start location",
|
||||||
|
"#class" : furaffinity.FuraffinityFavoriteExtractor,
|
||||||
|
"#auth" : False,
|
||||||
|
"#range" : "1-3",
|
||||||
|
"#results" : (
|
||||||
|
"https://d.furaffinity.net/art/kacey/1263424668/1263424668.kacey_mine.jpg",
|
||||||
|
"https://d.furaffinity.net/art/leomon32/1254250660/1254250660.leomon32_high_in_the_sky.jpg",
|
||||||
|
"https://d.furaffinity.net/art/firefoxzero/1262442028/1262442028.firefoxzero_resolute_model_4.png",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://www.furaffinity.net/search/?q=cute",
|
"#url" : "https://www.furaffinity.net/search/?q=cute",
|
||||||
"#category": ("", "furaffinity", "search"),
|
"#category": ("", "furaffinity", "search"),
|
||||||
|
|||||||
Reference in New Issue
Block a user