From a4dfadddfe150d9b6919e17d00428cc60e2305d3 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Sun, 17 Jan 2021 11:15:12 +0000 Subject: [PATCH] [photovogue] added portfolio extractor --- docs/supportedsites.rst | 1 + gallery_dl/extractor/__init__.py | 1 + gallery_dl/extractor/photovogue.py | 70 ++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 gallery_dl/extractor/photovogue.py diff --git a/docs/supportedsites.rst b/docs/supportedsites.rst index 312f215b0b..205c1aff42 100644 --- a/docs/supportedsites.rst +++ b/docs/supportedsites.rst @@ -94,6 +94,7 @@ Nyafuu Archive https://archive.nyafuu.org/ Boards, Search Results, Patreon https://www.patreon.com/ Creators, Posts, User Profiles `Cookies `__ Pawoo https://pawoo.net/ Images from Statuses, User Profiles `OAuth `__ Photobucket https://photobucket.com/ Albums, individual Images +PhotoVogue https://www.vogue.it/en/photovogue/ User profiles Piczel https://piczel.tv/ Folders, individual Images, User Profiles Pinterest https://www.pinterest.com/ |pinterest-C| Supported Pixiv https://www.pixiv.net/ |pixiv-C| Required diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index 94b379f239..672c566104 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -84,6 +84,7 @@ "paheal", "patreon", "photobucket", + "photovogue", "piczel", "pinterest", "pixiv", diff --git a/gallery_dl/extractor/photovogue.py b/gallery_dl/extractor/photovogue.py new file mode 100644 index 0000000000..8939c529af --- /dev/null +++ b/gallery_dl/extractor/photovogue.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +"""Extractors for https://www.vogue.it/en/photovogue/""" + +from .common import Extractor, Message +from datetime import datetime + +BASE_PATTERN = r"(?:https?://)?(?:www.vogue.it(?:/en)?/photovogue)" + + +class PhotovogueUserExtractor(Extractor): + category = "photovogue" + subcategory = "user" + directory_fmt = ("{category}", "{photographer[id]}_{photographer[name]}") + filename_fmt = "{id}_{title}.{extension}" + archive_fmt = "{id}" + root = "https://www.vogue.it/en/photovogue/" + pattern = BASE_PATTERN + r"/portfolio/\?id=(\d+)" + test = ( + ("https://www.vogue.it/en/photovogue/portfolio/?id=221252",), + ("https://www.vogue.it/photovogue/portfolio/?id=221252",), + ) + + def __init__(self, match): + Extractor.__init__(self, match) + self.user_id = match.group(1) + + def _photos(self): + page = 0 + + while True: + res = self.request( + "https://api.vogue.it/production/photos", + params={ + "count": 50, + "order_by": "DESC", + "page": page, + "photographer_id": self.user_id, + }, + ).json() + + for item in res["items"]: + item["extension"] = "jpg" + item["title"] = item["title"].strip() + item["_mtime"] = datetime.fromisoformat( + item["date"].replace("Z", "+00:00") + ).timestamp() + + yield item + + if not res["has_next"]: + break + + page += 1 + + def items(self): + yield Message.Version, 1 + + yielded_dir = False + + for photo in self._photos(): + if not yielded_dir: + yield Message.Directory, photo + yielded_dir = True + + yield Message.Url, photo["gallery_image"], photo