From aee2998d666fa990ad5f906d38acd47a530e1532 Mon Sep 17 00:00:00 2001 From: stabbedbybrick <125766685+stabbedbybrick@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:47:14 +0200 Subject: [PATCH] fix(ALL4): Set headers for WEB endpoints --- services/ALL4/__init__.py | 11 ++++------- services/ALL4/config.yaml | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/services/ALL4/__init__.py b/services/ALL4/__init__.py index e845154..3972726 100644 --- a/services/ALL4/__init__.py +++ b/services/ALL4/__init__.py @@ -302,7 +302,9 @@ class ALL4(Service): if web_assets is not None: try: b_manifest, b_token, b_subtitle, data = web_assets - web_tracks = DASH.from_url(b_manifest, self.session).to_tracks("en") + session = self.session + session.headers.update(self.config["headers"]) + web_tracks = DASH.from_url(b_manifest, session).to_tracks("en") web_heights = sorted([int(track.height) for track in web_tracks.videos], reverse=True) except Exception: web_heights = None @@ -312,9 +314,6 @@ class ALL4(Service): sys.exit(1) if not android_heights or android_heights[0] < 1080: - self.log.warning( - "ANDROID data returned None or is missing full quality profile, falling back to WEB data..." - ) lic_token = self.decrypt_token(b_token, client="WEB") return b_manifest, lic_token, b_subtitle, data else: @@ -322,7 +321,6 @@ class ALL4(Service): return a_manifest, lic_token, a_subtitle, data def android_playlist(self, video_id: str) -> tuple: - self.log.info("Requesting ANDROID assets...") url = self.config["android"]["vod"].format(video_id=video_id) headers = {"authorization": self.authorization} @@ -342,9 +340,8 @@ class ALL4(Service): return manifest, token, subtitle, data def web_playlist(self, video_id: str) -> tuple: - self.log.info("Requesting WEB assets...") url = self.config["web"]["vod"].format(programmeId=video_id) - r = self.session.get(url) + r = self.session.get(url, headers=self.config["headers"]) if not r.ok: self.log.warning("Request for WEB endpoint returned %s", r) return diff --git a/services/ALL4/config.yaml b/services/ALL4/config.yaml index 84ae487..1a4cb73 100644 --- a/services/ALL4/config.yaml +++ b/services/ALL4/config.yaml @@ -1,3 +1,7 @@ +headers: + Accept-Language: en-US,en;q=0.8 + User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36 + endpoints: login: https://api.channel4.com/online/v2/auth/token title: https://api.channel4.com/online/v1/views/content-hubs/{title}.json