[newgrounds] provide fallback URLs for video downloads (#1042)
This commit is contained in:
@@ -39,6 +39,7 @@ class NewgroundsExtractor(Extractor):
|
|||||||
post = self.extract_post(post_url)
|
post = self.extract_post(post_url)
|
||||||
url = post.get("url")
|
url = post.get("url")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
self.log.debug("", exc_info=True)
|
||||||
url = None
|
url = None
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
@@ -159,6 +160,7 @@ class NewgroundsExtractor(Extractor):
|
|||||||
|
|
||||||
if src:
|
if src:
|
||||||
src = src.replace("\\/", "/")
|
src = src.replace("\\/", "/")
|
||||||
|
fallback = ()
|
||||||
date = text.parse_datetime(extr(
|
date = text.parse_datetime(extr(
|
||||||
'itemprop="datePublished" content="', '"'))
|
'itemprop="datePublished" content="', '"'))
|
||||||
else:
|
else:
|
||||||
@@ -168,8 +170,13 @@ class NewgroundsExtractor(Extractor):
|
|||||||
"X-Requested-With": "XMLHttpRequest",
|
"X-Requested-With": "XMLHttpRequest",
|
||||||
"Referer": self.root,
|
"Referer": self.root,
|
||||||
}
|
}
|
||||||
data = self.request(url, headers=headers).json()
|
sources = self.request(url, headers=headers).json()["sources"]
|
||||||
src = data["sources"]["360p"][0]["src"].replace(".360p.", ".")
|
src = sources["360p"][0]["src"].replace(".360p.", ".")
|
||||||
|
fallback = [v[1][0]["src"] for v in sorted(
|
||||||
|
sources.items(),
|
||||||
|
key=lambda x: text.parse_int(x[0][:-1]),
|
||||||
|
reverse=True,
|
||||||
|
)]
|
||||||
date = text.parse_timestamp(src.rpartition("?")[2])
|
date = text.parse_timestamp(src.rpartition("?")[2])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -181,6 +188,7 @@ class NewgroundsExtractor(Extractor):
|
|||||||
"rating" : extr('class="rated-', '"'),
|
"rating" : extr('class="rated-', '"'),
|
||||||
"index" : text.parse_int(index),
|
"index" : text.parse_int(index),
|
||||||
"_index" : index,
|
"_index" : index,
|
||||||
|
"_fallback" : fallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _pagination(self, kind):
|
def _pagination(self, kind):
|
||||||
|
|||||||
Reference in New Issue
Block a user