From 988b557433b8a9b7ef7b1bc581bc4aa358b34731 Mon Sep 17 00:00:00 2001 From: dalgr Date: Tue, 26 Sep 2017 21:56:04 +0200 Subject: [PATCH] Get alt query before entering specific video format --- lib/svtplay_dl/service/svtplay.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/svtplay_dl/service/svtplay.py b/lib/svtplay_dl/service/svtplay.py index f595565..e6f7795 100644 --- a/lib/svtplay_dl/service/svtplay.py +++ b/lib/svtplay_dl/service/svtplay.py @@ -96,32 +96,26 @@ class Svtplay(Service, OpenGraphThumbMixin): for i in janson["videoReferences"]: streams = None alt_streams = None - parse = urlparse(i["url"]) - query = parse_qs(parse.query) + alt = None + query = parse_qs(urlparse(i["url"]).query) + if "alt" in query and len(query["alt"]) > 0: + alt = self.http.get(query["alt"][0]) + if i["format"] == "hls": streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) - - if "alt" in query and len(query["alt"]) > 0: - alt = self.http.get(query["alt"][0]) - if alt: - alt_streams = hlsparse(self.options, self.http.request("get", alt.request.url), alt.request.url) + if alt: + alt_streams = hlsparse(self.options, self.http.request("get", alt.request.url), alt.request.url) elif i["format"] == "hds": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse(self.options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"]) - - if "alt" in query and len(query["alt"]) > 0: - alt = self.http.get(query["alt"][0]) - if alt: - alt_streams = hdsparse(self.options, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url) + if alt: + alt_streams = hdsparse(self.options, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url) elif i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) - - if "alt" in query and len(query["alt"]) > 0: - alt = self.http.get(query["alt"][0]) - if alt: - alt_streams = dashparse(self.options, self.http.request("get", alt.request.url), alt.request.url) + if alt: + alt_streams = dashparse(self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()):