Add support for the readable URL format of Weasyl favourites page

This commit is contained in:
Deer-Spangle
2024-08-31 12:56:50 +01:00
parent cf8e04d999
commit b1b01f56af
2 changed files with 14 additions and 1 deletions

View File

@@ -160,14 +160,20 @@ class WeasylJournalsExtractor(WeasylExtractor):
class WeasylFavoriteExtractor(WeasylExtractor):
subcategory = "favorite"
directory_fmt = ("{category}", "{owner_login}", "Favorites")
pattern = BASE_PATTERN + r"favorites\?userid=(\d+)"
pattern = BASE_PATTERN + r"favorites(?:\?userid=(\d+)|\/([\w~-]+))"
example = "https://www.weasyl.com/favorites?userid=12345"
def __init__(self, match):
WeasylExtractor.__init__(self, match)
self.userid = match.group(1)
self.username = match.group(2)
def items(self):
if self.userid is None and self.username is not None:
new_url = self.root + f"/favorites/{self.username}"
page = self.request(new_url).text
self.userid = text.extr(page, '<a class="more" href="/favorites?userid=', '&amp')
owner_login = lastid = None
url = self.root + "/favorites"
params = {

View File

@@ -92,4 +92,11 @@ __tests__ = (
"#count" : ">= 5",
},
{
"#url" : "https://www.weasyl.com/favorites/furoferre",
"#category": ("", "weasyl", "favorite"),
"#class" : weasyl.WeasylFavoriteExtractor,
"#count" : ">= 5",
}
)