merge #7261: [deviantart] support multiple images for single posts
(#6653)
This commit is contained in:
@@ -1276,7 +1276,34 @@ class DeviantartDeviationExtractor(DeviantartExtractor):
|
||||
|
||||
deviation = self.api.deviation(uuid)
|
||||
deviation["_page"] = page
|
||||
return (deviation,)
|
||||
|
||||
_dev_info = text.extr(
|
||||
page, '\\"deviationExtended\\":', ',\\"deviation\\":', None)
|
||||
# Clean up escaped quotes
|
||||
_json_str = re.sub(
|
||||
r'(?<!\\)\\{1}"', '"', _dev_info).replace("\\'", "'")
|
||||
_extended_info = util.json_loads(_json_str)[self.deviation_id]
|
||||
additional_media = _extended_info.get("additionalMedia") or ()
|
||||
|
||||
if additional_media:
|
||||
self.filename_fmt = ("{category}_{index}_{index_file}_{title}_"
|
||||
"{num:>02}.{extension}")
|
||||
self.archive_fmt = ("g_{_username}_{index}{index_file:?_//}."
|
||||
"{extension}")
|
||||
|
||||
deviation["index_file"] = 0
|
||||
deviation["count"] = 1 + len(additional_media)
|
||||
deviation["num"] = 1
|
||||
yield deviation
|
||||
|
||||
for index, post in enumerate(additional_media):
|
||||
uri = post["media"]["baseUri"].encode().decode("unicode-escape")
|
||||
deviation["content"]["src"] = uri
|
||||
deviation["num"] += 1
|
||||
deviation["index_file"] = post["fileId"]
|
||||
# Download only works on purchased materials - no way to check
|
||||
deviation["is_downloadable"] = False
|
||||
yield deviation
|
||||
|
||||
|
||||
class DeviantartScrapsExtractor(DeviantartExtractor):
|
||||
|
||||
@@ -901,6 +901,25 @@ __tests__ = (
|
||||
"extension": "png",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.deviantart.com/justatest235723/art/1133021832",
|
||||
"#comment" : "mutliple images (#6653)",
|
||||
"#category": ("", "deviantart", "deviation"),
|
||||
"#class" : deviantart.DeviantartDeviationExtractor,
|
||||
"#archive" : False,
|
||||
"#pattern" : (
|
||||
r"https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-235680f0-7746-485c-9022-6042ab1f4d50\.png\?token=ey.+",
|
||||
r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-a47549b4-427d-404d-9a39-64cc07c6b5fb\.png",
|
||||
r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-faac0af6-ef9b-4c49-82af-349ba9f4acf7\.png",
|
||||
r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-34396355-d67d-4069-987f-b80f25495635\.png",
|
||||
),
|
||||
|
||||
"index" : 1133021832,
|
||||
"index_file": {0, 810469878, 810469899, 810469922},
|
||||
"count" : 4,
|
||||
"num" : range(1, 4),
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://deviantart.com/view/904858796/",
|
||||
"#comment" : "/view/ URLs",
|
||||
|
||||
Reference in New Issue
Block a user