[newgrounds] use generator for fallback URLs
This commit is contained in:
@@ -172,11 +172,7 @@ class NewgroundsExtractor(Extractor):
|
|||||||
}
|
}
|
||||||
sources = self.request(url, headers=headers).json()["sources"]
|
sources = self.request(url, headers=headers).json()["sources"]
|
||||||
src = sources["360p"][0]["src"].replace(".360p.", ".")
|
src = sources["360p"][0]["src"].replace(".360p.", ".")
|
||||||
fallback = [v[1][0]["src"] for v in sorted(
|
fallback = self._video_fallback(sources)
|
||||||
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 {
|
||||||
@@ -191,6 +187,13 @@ class NewgroundsExtractor(Extractor):
|
|||||||
"_fallback" : fallback,
|
"_fallback" : fallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _video_fallback(sources):
|
||||||
|
sources = list(sources.items())
|
||||||
|
sources.sort(key=lambda src: text.parse_int(src[0][:-1]), reverse=True)
|
||||||
|
for src in sources:
|
||||||
|
yield src[1][0]["src"]
|
||||||
|
|
||||||
def _pagination(self, kind):
|
def _pagination(self, kind):
|
||||||
root = self.user_root
|
root = self.user_root
|
||||||
headers = {
|
headers = {
|
||||||
|
|||||||
Reference in New Issue
Block a user