[artstation] fix & update 'challenge' extractor
This commit is contained in:
@@ -319,9 +319,9 @@ class ArtstationChallengeExtractor(ArtstationExtractor):
|
|||||||
"{challenge[id]} - {challenge[title]}")
|
"{challenge[id]} - {challenge[title]}")
|
||||||
archive_fmt = "c_{challenge[id]}_{asset_id}"
|
archive_fmt = "c_{challenge[id]}_{asset_id}"
|
||||||
pattern = (r"(?:https?://)?(?:www\.)?artstation\.com"
|
pattern = (r"(?:https?://)?(?:www\.)?artstation\.com"
|
||||||
r"/contests/[^/?#]+/challenges/(\d+)"
|
r"/c(?:hallenges|ontests)/[^/?#]+/c(?:ategori|halleng)es/(\d+)"
|
||||||
r"/?(?:\?sorting=([a-z]+))?")
|
r"/?(?:\?sorting=([a-z]+))?")
|
||||||
example = "https://www.artstation.com/contests/NAME/challenges/12345"
|
example = "https://www.artstation.com/challenges/NAME/categories/12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
ArtstationExtractor.__init__(self, match)
|
ArtstationExtractor.__init__(self, match)
|
||||||
@@ -329,24 +329,28 @@ class ArtstationChallengeExtractor(ArtstationExtractor):
|
|||||||
self.sorting = match[2] or "popular"
|
self.sorting = match[2] or "popular"
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
base = f"{self.root}/contests/_/challenges/{self.challenge_id}"
|
base = self.root + "/api/v2/competition/"
|
||||||
challenge_url = base + ".json"
|
challenge_url = f"{base}challenges/{self.challenge_id}.json"
|
||||||
submission_url = base + "/submissions.json"
|
submission_url = base + "submissions.json"
|
||||||
update_url = self.root + "/contests/submission_updates.json"
|
|
||||||
|
|
||||||
challenge = self.request_json(challenge_url)
|
challenge = self.request_json(challenge_url)
|
||||||
yield Message.Directory, "", {"challenge": challenge}
|
yield Message.Directory, "", {"challenge": challenge}
|
||||||
|
|
||||||
params = {"sorting": self.sorting}
|
params = {
|
||||||
|
"page" : 1,
|
||||||
|
"per_page" : 50,
|
||||||
|
"challenge_id": self.challenge_id,
|
||||||
|
"sort_by" : self.sorting,
|
||||||
|
}
|
||||||
|
|
||||||
for submission in self._pagination(submission_url, params):
|
for submission in self._pagination(submission_url, params):
|
||||||
|
update_url = (f"{base}submissions/{submission['id']}"
|
||||||
params = {"submission_id": submission["id"]}
|
f"/submission_updates.json")
|
||||||
|
params = {"page": 1, "per_page": 50}
|
||||||
for update in self._pagination(update_url, params=params):
|
for update in self._pagination(update_url, params=params):
|
||||||
|
|
||||||
del update["replies"]
|
|
||||||
update["challenge"] = challenge
|
update["challenge"] = challenge
|
||||||
for url in text.extract_iter(
|
for url in util.unique_sequence(text.extract_iter(
|
||||||
update["body_presentation_html"], ' href="', '"'):
|
update["body"], ' href="', '"')):
|
||||||
update["asset_id"] = self._id_from_url(url)
|
update["asset_id"] = self._id_from_url(url)
|
||||||
text.nameext_from_url(url, update)
|
text.nameext_from_url(url, update)
|
||||||
yield Message.Url, self._no_cache(url), update
|
yield Message.Url, self._no_cache(url), update
|
||||||
|
|||||||
@@ -108,10 +108,28 @@ __tests__ = (
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://www.artstation.com/contests/beyond-human/challenges/23?sorting=winners",
|
"#url" : "https://www.artstation.com/challenges/beyond-human/categories/23/submissions",
|
||||||
|
"#class" : artstation.ArtstationChallengeExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://www.artstation.com/contests/beyond-human/challenges/23?sorting=popular",
|
||||||
"#class" : artstation.ArtstationChallengeExtractor,
|
"#class" : artstation.ArtstationChallengeExtractor,
|
||||||
"#range" : "1-30",
|
"#range" : "1-30",
|
||||||
"#count" : 30,
|
"#count" : 30,
|
||||||
|
|
||||||
|
"challenge": {
|
||||||
|
"id" : 23,
|
||||||
|
"headline" : "Imagining Where Future Humans Live",
|
||||||
|
"created_at": "2017-06-26T14:45:43+00:00",
|
||||||
|
"contest" : {
|
||||||
|
"archived" : True,
|
||||||
|
"published": True,
|
||||||
|
"slug" : "beyond-human",
|
||||||
|
"title" : "Beyond Human",
|
||||||
|
"submissions_count": 4258,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user