-
-
Notifications
You must be signed in to change notification settings - Fork 996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[photovogue] added portfolio extractor #1253
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ | |
"paheal", | ||
"patreon", | ||
"photobucket", | ||
"photovogue", | ||
"piczel", | ||
"pinterest", | ||
"pixiv", | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -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)" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This would also allow non-www URLs |
||||||||||
|
||||||||||
|
||||||||||
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/" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
by convention, |
||||||||||
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",), | ||||||||||
Comment on lines
+24
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Tests should either be a single string or a (url, results) tuple. |
||||||||||
) | ||||||||||
|
||||||||||
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() | ||||||||||
Comment on lines
+36
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just personal preference, but I'd prepare url and params before the loop, and then just call This would also get rid of the |
||||||||||
|
||||||||||
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 | ||||||||||
Comment on lines
+46
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just do a Speaking of.
|
||||||||||
|
||||||||||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents of this file are auto-generated by supportedsites.py
Update
CATEGORY_MAP
in there if necessary and run it once.