[redgifs] provide 'collection' metadata in a separate field (#4508)

instead of overwriting the actual metadata
This commit is contained in:
Mike Fährmann
2023-09-12 20:27:55 +02:00
parent 1710f1e983
commit ae5e049c4f

View File

@@ -111,8 +111,9 @@ class RedgifsUserExtractor(RedgifsExtractor):
class RedgifsCollectionExtractor(RedgifsExtractor): class RedgifsCollectionExtractor(RedgifsExtractor):
"""Extractor for an individual user collection""" """Extractor for an individual user collection"""
subcategory = "collection" subcategory = "collection"
directory_fmt = ("{category}", "{userName}", "{folderName}") directory_fmt = (
archive_fmt = "{folderId}_{id}" "{category}", "{collection[userName]}", "{collection[folderName]}")
archive_fmt = "{collection[folderId]}_{id}"
pattern = (r"(?:https?://)?(?:www\.)?redgifs\.com/users" pattern = (r"(?:https?://)?(?:www\.)?redgifs\.com/users"
r"/([^/?#]+)/collections/([^/?#]+)") r"/([^/?#]+)/collections/([^/?#]+)")
test = ( test = (
@@ -133,9 +134,9 @@ class RedgifsCollectionExtractor(RedgifsExtractor):
self.collection_id = match.group(2) self.collection_id = match.group(2)
def metadata(self): def metadata(self):
data = {"userName": self.key} collection = self.api.collection_info(self.key, self.collection_id)
data.update(self.api.collection_info(self.key, self.collection_id)) collection["userName"] = self.key
return data return {"collection": collection}
def gifs(self): def gifs(self):
return self.api.collection(self.key, self.collection_id) return self.api.collection(self.key, self.collection_id)