From 095f278d6f320b83c680843dad8b50e6a1dbe6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 31 Jul 2024 12:32:04 +0200 Subject: [PATCH] [vsco] add 'include' option (#5911) --- docs/configuration.rst | 23 +++++++++++++++++++++++ docs/supportedsites.md | 2 +- gallery_dl/extractor/vsco.py | 23 +++++++++++++++++++++-- test/results/vsco.py | 32 +++++++++++++++++++++++--------- 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 329c67c0..edae1711 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -4300,6 +4300,29 @@ Description or `cookies `__ +extractor.vsco.include +---------------------- +Type + * ``string`` + * ``list`` of ``strings`` +Default + ``"gallery"`` +Example + * ``"avatar,collection"`` + * ``["avatar", "collection"]`` +Description + A (comma-separated) list of subcategories to include + when processing a user profile. + + Possible values are + ``"avatar"``, + ``"gallery"``, + ``"spaces"``, + ``"collection"``, + + It is possible to use ``"all"`` instead of listing all values separately. + + extractor.vsco.videos --------------------- Type diff --git a/docs/supportedsites.md b/docs/supportedsites.md index dfac46be..10580111 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -952,7 +952,7 @@ Consider all listed sites to potentially be NSFW. VSCO https://vsco.co/ - Avatars, Collections, individual Images, Spaces, User Profiles + Avatars, Collections, Galleries, individual Images, Spaces, User Profiles diff --git a/gallery_dl/extractor/vsco.py b/gallery_dl/extractor/vsco.py index c112f4ae..922a591b 100644 --- a/gallery_dl/extractor/vsco.py +++ b/gallery_dl/extractor/vsco.py @@ -115,9 +115,28 @@ class VscoExtractor(Extractor): class VscoUserExtractor(VscoExtractor): - """Extractor for images from a user on vsco.co""" + """Extractor for a vsco user profile""" subcategory = "user" - pattern = USER_PATTERN + r"(?:/gallery|/images(?:/\d+)?)?/?(?:$|[?#])" + pattern = USER_PATTERN + r"/?$" + example = "https://vsco.co/USER" + + def initialize(self): + pass + + def items(self): + base = "{}/{}/".format(self.root, self.user) + return self._dispatch_extractors(( + (VscoAvatarExtractor , base + "avatar"), + (VscoGalleryExtractor , base + "gallery"), + (VscoSpacesExtractor , base + "spaces"), + (VscoCollectionExtractor, base + "collection"), + ), ("gallery",)) + + +class VscoGalleryExtractor(VscoExtractor): + """Extractor for a vsco user's gallery""" + subcategory = "gallery" + pattern = USER_PATTERN + r"/(?:gallery|images)" example = "https://vsco.co/USER/gallery" def images(self): diff --git a/test/results/vsco.py b/test/results/vsco.py index 0553b4c3..c0b32c42 100644 --- a/test/results/vsco.py +++ b/test/results/vsco.py @@ -9,9 +9,29 @@ from gallery_dl.extractor import vsco __tests__ = ( { - "#url" : "https://vsco.co/missuri/gallery", + "#url" : "https://vsco.co/missuri", "#category": ("", "vsco", "user"), "#class" : vsco.VscoUserExtractor, + "#urls" : "https://vsco.co/missuri/gallery", +}, + +{ + "#url" : "https://vsco.co/missuri", + "#category": ("", "vsco", "user"), + "#class" : vsco.VscoUserExtractor, + "#options" : {"include": "all"}, + "#urls" : [ + "https://vsco.co/missuri/avatar", + "https://vsco.co/missuri/gallery", + "https://vsco.co/missuri/spaces", + "https://vsco.co/missuri/collection", + ], +}, + +{ + "#url" : "https://vsco.co/missuri/gallery", + "#category": ("", "vsco", "gallery"), + "#class" : vsco.VscoGalleryExtractor, "#pattern" : r"https://image(-aws.+)?\.vsco\.co/[0-9a-f/]+/[\w-]+\.\w+", "#range" : "1-80", "#count" : 80, @@ -19,14 +39,8 @@ __tests__ = ( { "#url" : "https://vsco.co/missuri/images/1", - "#category": ("", "vsco", "user"), - "#class" : vsco.VscoUserExtractor, -}, - -{ - "#url" : "https://vsco.co/missuri", - "#category": ("", "vsco", "user"), - "#class" : vsco.VscoUserExtractor, + "#category": ("", "vsco", "gallery"), + "#class" : vsco.VscoGalleryExtractor, }, {