[pixiv] handle tags at the end of new bookmark URLs

This commit is contained in:
Mike Fährmann
2020-02-06 23:42:13 +01:00
parent 109f6c8685
commit b7eb6cecbb

View File

@@ -222,8 +222,8 @@ class PixivFavoriteExtractor(PixivExtractor):
directory_fmt = ("{category}", "bookmarks", directory_fmt = ("{category}", "bookmarks",
"{user_bookmark[id]} {user_bookmark[account]}") "{user_bookmark[id]} {user_bookmark[account]}")
archive_fmt = "f_{user_bookmark[id]}_{id}{num}.{extension}" archive_fmt = "f_{user_bookmark[id]}_{id}{num}.{extension}"
pattern = (r"(?:https?://)?(?:www\.|touch\.)?pixiv\.net/" pattern = (r"(?:https?://)?(?:www\.|touch\.)?pixiv\.net/(?:(?:en/)?"
r"(?:(?:en/)?users/(\d+)/(bookmarks/artworks|following)" r"users/(\d+)/(bookmarks/artworks(?:/([^/?&#]+))?|following)"
r"|bookmark\.php(?:\?([^#]*))?)") r"|bookmark\.php(?:\?([^#]*))?)")
test = ( test = (
("https://www.pixiv.net/en/users/173530/bookmarks/artworks", { ("https://www.pixiv.net/en/users/173530/bookmarks/artworks", {
@@ -233,9 +233,14 @@ class PixivFavoriteExtractor(PixivExtractor):
"url": "e717eb511500f2fa3497aaee796a468ecf685cc4", "url": "e717eb511500f2fa3497aaee796a468ecf685cc4",
}), }),
# bookmarks with specific tag # bookmarks with specific tag
(("https://www.pixiv.net/en/users/3137110"
"/bookmarks/artworks/%E3%81%AF%E3%82%93%E3%82%82%E3%82%93"), {
"url": "379b28275f786d946e01f721e54afe346c148a8c",
}),
# bookmarks with specific tag (legacy url)
(("https://www.pixiv.net/bookmark.php?id=3137110" (("https://www.pixiv.net/bookmark.php?id=3137110"
"&tag=%E3%81%AF%E3%82%93%E3%82%82%E3%82%93&p=1"), { "&tag=%E3%81%AF%E3%82%93%E3%82%82%E3%82%93&p=1"), {
"count": 2, "url": "379b28275f786d946e01f721e54afe346c148a8c",
}), }),
# own bookmarks # own bookmarks
("https://www.pixiv.net/bookmark.php", { ("https://www.pixiv.net/bookmark.php", {
@@ -250,7 +255,7 @@ class PixivFavoriteExtractor(PixivExtractor):
"pattern": PixivUserExtractor.pattern, "pattern": PixivUserExtractor.pattern,
"count": ">= 12", "count": ">= 12",
}), }),
# followed users (#515) # followed users (legacy url) (#515)
("https://www.pixiv.net/bookmark.php?id=173530&type=user", { ("https://www.pixiv.net/bookmark.php?id=173530&type=user", {
"pattern": PixivUserExtractor.pattern, "pattern": PixivUserExtractor.pattern,
"count": ">= 12", "count": ">= 12",
@@ -261,7 +266,7 @@ class PixivFavoriteExtractor(PixivExtractor):
) )
def __init__(self, match): def __init__(self, match):
uid, kind, query = match.groups() uid, kind, self.tag, query = match.groups()
if query: if query:
self.query = text.parse_query(query) self.query = text.parse_query(query)
@@ -286,6 +291,9 @@ class PixivFavoriteExtractor(PixivExtractor):
if "tag" in self.query: if "tag" in self.query:
tag = text.unquote(self.query["tag"]) tag = text.unquote(self.query["tag"])
elif self.tag:
tag = text.unquote(self.tag)
if "rest" in self.query and self.query["rest"] == "hide": if "rest" in self.query and self.query["rest"] == "hide":
restrict = "private" restrict = "private"