From 2bf76461ce0d5cad02672f38b6e7b825ba1b0ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 31 Jul 2024 17:21:39 +0200 Subject: [PATCH] [deviantart:following] use OAuth API endpoint (#2511) --- gallery_dl/extractor/deviantart.py | 14 ++++++++++---- test/results/deviantart.py | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 2199cc8a..2dc8ebc4 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -1077,14 +1077,14 @@ class DeviantartGallerySearchExtractor(DeviantartExtractor): class DeviantartFollowingExtractor(DeviantartExtractor): """Extractor for user's watched users""" subcategory = "following" - pattern = BASE_PATTERN + "/about#watching$" + pattern = BASE_PATTERN + "/(?:about#)?watching" example = "https://www.deviantart.com/USER/about#watching" def items(self): - eclipse_api = DeviantartEclipseAPI(self) + api = DeviantartOAuthAPI(self) - for user in eclipse_api.user_watching(self.user, self.offset): - url = "{}/{}".format(self.root, user["username"]) + for user in api.user_friends(self.user): + url = "{}/{}".format(self.root, user["user"]["username"]) user["_extractor"] = DeviantartUserExtractor yield Message.Queue, url, user @@ -1351,6 +1351,12 @@ class DeviantartOAuthAPI(): params = {"username": username, "offset": offset, "limit": 50} return self._pagination(endpoint, params) + def user_friends(self, username, offset=0): + """Get the users list of friends""" + endpoint = "/user/friends/" + username + params = {"limit": 50, "offset": offset, "mature_content": self.mature} + return self._pagination(endpoint, params) + def user_friends_watch(self, username): """Watch a user""" endpoint = "/user/friends/watch/" + username diff --git a/test/results/deviantart.py b/test/results/deviantart.py index 525206df..2aefee94 100644 --- a/test/results/deviantart.py +++ b/test/results/deviantart.py @@ -1003,4 +1003,10 @@ __tests__ = ( "#count" : 50, }, +{ + "#url" : "https://www.deviantart.com/shimoda7/watching", + "#category": ("", "deviantart", "following"), + "#class" : deviantart.DeviantartFollowingExtractor, +}, + )