Add support for the readable URL format of Weasyl favourites page
This commit is contained in:
@@ -160,14 +160,20 @@ class WeasylJournalsExtractor(WeasylExtractor):
|
|||||||
class WeasylFavoriteExtractor(WeasylExtractor):
|
class WeasylFavoriteExtractor(WeasylExtractor):
|
||||||
subcategory = "favorite"
|
subcategory = "favorite"
|
||||||
directory_fmt = ("{category}", "{owner_login}", "Favorites")
|
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"
|
example = "https://www.weasyl.com/favorites?userid=12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
WeasylExtractor.__init__(self, match)
|
WeasylExtractor.__init__(self, match)
|
||||||
self.userid = match.group(1)
|
self.userid = match.group(1)
|
||||||
|
self.username = match.group(2)
|
||||||
|
|
||||||
def items(self):
|
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=', '&')
|
||||||
|
|
||||||
owner_login = lastid = None
|
owner_login = lastid = None
|
||||||
url = self.root + "/favorites"
|
url = self.root + "/favorites"
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
@@ -92,4 +92,11 @@ __tests__ = (
|
|||||||
"#count" : ">= 5",
|
"#count" : ">= 5",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://www.weasyl.com/favorites/furoferre",
|
||||||
|
"#category": ("", "weasyl", "favorite"),
|
||||||
|
"#class" : weasyl.WeasylFavoriteExtractor,
|
||||||
|
"#count" : ">= 5",
|
||||||
|
}
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user