Skip to content

Commit

Permalink
Add support for the readable URL format of Weasyl favourites page
Browse files Browse the repository at this point in the history
  • Loading branch information
Deer-Spangle committed Aug 31, 2024
1 parent cf8e04d commit b1b01f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gallery_dl/extractor/weasyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,20 @@ def items(self):
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 = {
Expand Down
7 changes: 7 additions & 0 deletions test/results/weasyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,11 @@
"#count" : ">= 5",
},

{
"#url" : "https://www.weasyl.com/favorites/furoferre",
"#category": ("", "weasyl", "favorite"),
"#class" : weasyl.WeasylFavoriteExtractor,
"#count" : ">= 5",
}

)

0 comments on commit b1b01f5

Please sign in to comment.