From 884f1848d66b0414a45da82262247698a0751364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 18 Feb 2023 13:07:40 +0100 Subject: [PATCH] [redgifs] fix syntax for older Python versions and update docs/supportedsites --- docs/supportedsites.md | 2 +- gallery_dl/extractor/redgifs.py | 20 ++++++++++---------- scripts/supportedsites.py | 3 +++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index 46429d79..d615c01e 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -718,7 +718,7 @@ Consider all sites to be NSFW unless otherwise known. RedGIFs https://redgifs.com/ - individual Images, Search Results, User Profiles + Collections, individual Images, Search Results, User Profiles diff --git a/gallery_dl/extractor/redgifs.py b/gallery_dl/extractor/redgifs.py index e1a06638..eaaef7d8 100644 --- a/gallery_dl/extractor/redgifs.py +++ b/gallery_dl/extractor/redgifs.py @@ -93,7 +93,7 @@ class RedgifsCollectionExtractor(RedgifsExtractor): """Extractor for an individual user collection""" subcategory = "collection" directory_fmt = ("{category}", "{userName}", "{folderName}") - archive_fmt = "{collection_id}_{id}" + archive_fmt = "{folderId}_{id}" pattern = (r"(?:https?://)?(?:www\.)?redgifs\.com/users" r"/([^/?#]+)/collections/([^/?#]+)") test = ( @@ -114,11 +114,9 @@ class RedgifsCollectionExtractor(RedgifsExtractor): self.collection_id = match.group(2) def metadata(self): - return { - "collection_id": self.collection_id, - "userName": self.key, - **self.api.collection_getInfo(self.key, self.collection_id), - } + data = {"userName": self.key} + data.update(self.api.collection_info(self.key, self.collection_id)) + return data def gifs(self): return self.api.collection(self.key, self.collection_id) @@ -191,6 +189,8 @@ class RedgifsImageExtractor(RedgifsExtractor): class RedgifsAPI(): + """https://api.redgifs.com/docs/index.html""" + API_ROOT = "https://api.redgifs.com" def __init__(self, extractor): @@ -212,15 +212,15 @@ class RedgifsAPI(): params = {"order": order} return self._pagination(endpoint, params) - def collection_getInfo(self, user, collection_id): - endpoint = "/v2/users/{}/collections/{}".format(user, collection_id) - return self._call(endpoint) - def collection(self, user, collection_id): endpoint = "/v2/users/{}/collections/{}/gifs".format( user, collection_id) return self._pagination(endpoint) + def collection_info(self, user, collection_id): + endpoint = "/v2/users/{}/collections/{}".format(user, collection_id) + return self._call(endpoint) + def collections(self, user): endpoint = "/v2/users/{}/collections".format(user) return self._pagination(endpoint, key="collections") diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 012f23dc..1d7992fa 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -212,6 +212,9 @@ SUBCATEGORY_MAP = { "reddit": { "home": "Home Feed", }, + "redgifs": { + "collections": "", + }, "sankaku": { "books": "Book Searches", },