From ccac55897c907e9bbe7237cb118538069746e790 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Fri, 8 Mar 2024 15:45:52 +0000 Subject: [PATCH] refactor(ClearKey): Only use User-Agent if none set in from_m3u_key --- devine/core/drm/clearkey.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/devine/core/drm/clearkey.py b/devine/core/drm/clearkey.py index b5bf743..dfec042 100644 --- a/devine/core/drm/clearkey.py +++ b/devine/core/drm/clearkey.py @@ -81,6 +81,10 @@ class ClearKey: if not session: session = Session() + if not session.headers.get("User-Agent"): + # commonly needed default for HLS playlists + session.headers["User-Agent"] = "smartexoplayer/1.1.0 (Linux;Android 8.0.0) ExoPlayerLib/2.13.3" + if m3u_key.uri.startswith("data:"): media_types, data = m3u_key.uri[5:].split(",") media_types = media_types.split(";") @@ -89,12 +93,7 @@ class ClearKey: key = data else: url = urljoin(m3u_key.base_uri, m3u_key.uri) - res = session.get( - url=url, - headers={ - "User-Agent": "smartexoplayer/1.1.0 (Linux;Android 8.0.0) ExoPlayerLib/2.13.3" - } - ) + res = session.get(url) res.raise_for_status() if not res.content: raise EOFError("Unexpected Empty Response by M3U Key URI.")