From 270105e3af586fdcc8ba07a558a5efa44a1a62c4 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sat, 9 Jul 2022 12:56:15 +0200 Subject: [PATCH] pluto.tv: try to find what hls to use in some cases they have several entries for the same show. one is working. one is not. random place in the list --- lib/svtplay_dl/service/plutotv.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/svtplay_dl/service/plutotv.py b/lib/svtplay_dl/service/plutotv.py index f45e393..9e3ac7b 100644 --- a/lib/svtplay_dl/service/plutotv.py +++ b/lib/svtplay_dl/service/plutotv.py @@ -26,6 +26,7 @@ class Plutotv(Service, OpenGraphThumbMixin): episodename = urlmatch.group(4) self._janson() HLSplaylist = None + found = False servicevod = f"https://service-vod.clusters.pluto.tv/v4/vod/slugs/{self.slug}" res = self.http.request("get", servicevod, params=self.query, headers={"Authorization": f"Bearer {self.sessionToken}"}) @@ -34,27 +35,28 @@ class Plutotv(Service, OpenGraphThumbMixin): self.output["title"] = janson2["name"] for season in janson2["seasons"]: for episode in season["episodes"]: - if episode["slug"] == episodename: + if episode["slug"] == episodename and not found: self.output["season"] = episode["season"] self.output["episode"] = episode["number"] for stich in episode["stitched"]["paths"]: if stich["type"] == "hls": - HLSplaylist = stich["path"] + HLSplaylist = f"{self.mediaserver}{stich['path']}?{self.stitcherParams}" + if self.http.request("get", HLSplaylist, headers={"Authorization": f"Bearer {self.sessionToken}"}).status_code < 400: + found = True else: self.output["title"] == janson2["name"] for stich in janson2["stitched"]["paths"]: if stich["type"] == "hls": - HLSplaylist = stich["path"] + HLSplaylist = f"{self.mediaserver}{stich['path']}?{self.stitcherParams}" if not HLSplaylist: yield ServiceError("Can't find video info") return - playlistURL = f"{self.mediaserver}{HLSplaylist}?{self.stitcherParams}" yield from hlsparse( self.config, - self.http.request("get", playlistURL, headers={"Authorization": f"Bearer {self.sessionToken}"}), - playlistURL, + self.http.request("get", HLSplaylist, headers={"Authorization": f"Bearer {self.sessionToken}"}), + HLSplaylist, self.output, filter=True, )