Improve error handling and track selection logic

This commit is contained in:
√(noham)²
2025-12-21 13:13:28 +01:00
parent 8ce6afaa22
commit e14fa2f99e
2 changed files with 17 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ def fetch_drm_keys(kid: str, api_url: str, api_key: str) -> str:
}
data = {"service": "oqee", "kid": kid}
response = requests.post(api_url, headers=headers, json=data, timeout=10)
response.raise_for_status()
return response.json()["key"]

View File

@@ -413,7 +413,21 @@ def select_track(content_dict, quality_spec, content_type):
candidates = []
for key, tracks in content_dict.items():
if filter_part and filter_part.lower() not in key.lower():
if filter_part:
should_skip = True
if content_type == "video" and "x" in key:
# For video, check height
try:
_, height = key.split("x")
if filter_part.endswith("p"):
target_height = filter_part[:-1]
else:
target_height = filter_part
if target_height in height:
should_skip = False
except ValueError:
pass
if should_skip and filter_part.lower() not in key.lower():
continue
candidates.extend(tracks)