From e9dc6ff26258a6560ba78f55a39dcbac2bdb00ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 11 Oct 2021 21:10:20 +0200 Subject: [PATCH] [inkbunny] add 'following' extractor (#515) --- gallery_dl/extractor/inkbunny.py | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gallery_dl/extractor/inkbunny.py b/gallery_dl/extractor/inkbunny.py index 74e3f1d5..3d09d791 100644 --- a/gallery_dl/extractor/inkbunny.py +++ b/gallery_dl/extractor/inkbunny.py @@ -205,6 +205,53 @@ class InkbunnyFavoriteExtractor(InkbunnyExtractor): return self.api.search(params) +class InkbunnyFollowingExtractor(InkbunnyExtractor): + """Extractor for inkbunny user watches""" + subcategory = "following" + pattern = (BASE_PATTERN + r"/(?:" + r"watchlist_process\.php\?mode=watching&user_id=(\d+)|" + r"usersviewall\.php\?([^#]+&mode=watching&[^#]+))") + test = ( + (("https://inkbunny.net/watchlist_process.php" + "?mode=watching&user_id=20969"), { + "pattern": InkbunnyUserExtractor.pattern, + "count": ">= 90", + }), + ("https://inkbunny.net/usersviewall.php?rid=ffffffffff" + "&mode=watching&page=1&user_id=20969&orderby=added&namesonly="), + ) + + def __init__(self, match): + InkbunnyExtractor.__init__(self, match) + self.user_id = match.group(1) or \ + text.parse_query(match.group(2)).get("user_id") + + def items(self): + url = self.root + "/watchlist_process.php" + params = {"mode": "watching", "user_id": self.user_id} + + with self.request(url, params=params) as response: + url, _, params = response.url.partition("?") + page = response.text + + params = text.parse_query(params) + params["page"] = text.parse_int(params.get("page"), 1) + data = {"_extractor": InkbunnyUserExtractor} + + while True: + cnt = 0 + for user in text.extract_iter( + page, '