mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-23 03:02:50 +01:00
[pinterest] improvements
- add stop condition for pin-related pins - improve URL patterns - make Pylint happy
This commit is contained in:
parent
2801a0d997
commit
d3f1eed2a6
@ -36,7 +36,14 @@ class PinterestExtractor(Extractor):
|
|||||||
pin_data.update(data)
|
pin_data.update(data)
|
||||||
yield Message.Url, url, pin_data
|
yield Message.Url, url, pin_data
|
||||||
|
|
||||||
def data_from_pin(self, pin):
|
def metadata(self):
|
||||||
|
"""Return general metadata"""
|
||||||
|
|
||||||
|
def pins(self):
|
||||||
|
"""Return all relevant pin-objects"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def data_from_pin(pin):
|
||||||
"""Get image url and metadata from a pin-object"""
|
"""Get image url and metadata from a pin-object"""
|
||||||
img = pin["images"]["orig"]
|
img = pin["images"]["orig"]
|
||||||
url = img["url"]
|
url = img["url"]
|
||||||
@ -48,7 +55,7 @@ class PinterestExtractor(Extractor):
|
|||||||
class PinterestPinExtractor(PinterestExtractor):
|
class PinterestPinExtractor(PinterestExtractor):
|
||||||
"""Extractor for images from a single pin from pinterest.com"""
|
"""Extractor for images from a single pin from pinterest.com"""
|
||||||
subcategory = "pin"
|
subcategory = "pin"
|
||||||
pattern = [BASE_PATTERN + r"/pin/([^/?#&]+)/?$"]
|
pattern = [BASE_PATTERN + r"/pin/([^/?#&]+)(?!.*#related$)"]
|
||||||
test = [
|
test = [
|
||||||
("https://www.pinterest.com/pin/858146903966145189/", {
|
("https://www.pinterest.com/pin/858146903966145189/", {
|
||||||
"url": "afb3c26719e3a530bb0e871c480882a801a4e8a5",
|
"url": "afb3c26719e3a530bb0e871c480882a801a4e8a5",
|
||||||
@ -79,7 +86,7 @@ class PinterestBoardExtractor(PinterestExtractor):
|
|||||||
subcategory = "board"
|
subcategory = "board"
|
||||||
directory_fmt = ["{category}", "{board[owner][username]}", "{board[name]}"]
|
directory_fmt = ["{category}", "{board[owner][username]}", "{board[name]}"]
|
||||||
archive_fmt = "{board[id]}_{id}"
|
archive_fmt = "{board[id]}_{id}"
|
||||||
pattern = [BASE_PATTERN + r"/(?!pin/)([^/?#&]+)/([^/?#&]+)/?$"]
|
pattern = [BASE_PATTERN + r"/(?!pin/)([^/?#&]+)/([^/?#&]+)(?!.*#related$)"]
|
||||||
test = [
|
test = [
|
||||||
("https://www.pinterest.com/g1952849/test-/", {
|
("https://www.pinterest.com/g1952849/test-/", {
|
||||||
"url": "85911dfca313f3f7f48c2aa0bc684f539d1d80a6",
|
"url": "85911dfca313f3f7f48c2aa0bc684f539d1d80a6",
|
||||||
@ -108,7 +115,7 @@ class PinterestRelatedPinExtractor(PinterestPinExtractor):
|
|||||||
"""Extractor for related pins of another pin from pinterest.com"""
|
"""Extractor for related pins of another pin from pinterest.com"""
|
||||||
subcategory = "related-pin"
|
subcategory = "related-pin"
|
||||||
directory_fmt = ["{category}", "related {original_pin[id]}"]
|
directory_fmt = ["{category}", "related {original_pin[id]}"]
|
||||||
pattern = [BASE_PATTERN + r"/pin/([^/?#&]+)/?#related$"]
|
pattern = [BASE_PATTERN + r"/pin/([^/?#&]+).*#related$"]
|
||||||
test = [
|
test = [
|
||||||
("https://www.pinterest.com/pin/858146903966145189/#related", {
|
("https://www.pinterest.com/pin/858146903966145189/#related", {
|
||||||
"range": (1, 50),
|
"range": (1, 50),
|
||||||
@ -129,7 +136,7 @@ class PinterestRelatedBoardExtractor(PinterestBoardExtractor):
|
|||||||
subcategory = "related-board"
|
subcategory = "related-board"
|
||||||
directory_fmt = ["{category}", "{board[owner][username]}",
|
directory_fmt = ["{category}", "{board[owner][username]}",
|
||||||
"{board[name]}", "related"]
|
"{board[name]}", "related"]
|
||||||
pattern = [BASE_PATTERN + r"/(?!pin/)([^/?#&]+)/([^/?#&]+)/?#related$"]
|
pattern = [BASE_PATTERN + r"/(?!pin/)([^/?#&]+)/([^/?#&]+).*#related$"]
|
||||||
test = [
|
test = [
|
||||||
("https://www.pinterest.com/g1952849/test-/#related", {
|
("https://www.pinterest.com/g1952849/test-/#related", {
|
||||||
"range": (1, 50),
|
"range": (1, 50),
|
||||||
@ -244,7 +251,8 @@ class PinterestAPI():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
bookmarks = data["resource"]["options"]["bookmarks"]
|
bookmarks = data["resource"]["options"]["bookmarks"]
|
||||||
if not bookmarks or bookmarks[0] == "-end-":
|
if (not bookmarks or bookmarks[0] == "-end-" or
|
||||||
|
bookmarks[0].startswith("Y2JOb25lO")):
|
||||||
return
|
return
|
||||||
options["bookmarks"] = bookmarks
|
options["bookmarks"] = bookmarks
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
Reference in New Issue
Block a user