mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
fix(dash): resolve representations by adaptation set, not id alone
Representation ids are only unique within an AdaptationSet, so re-finding a track by id could download a sibling set's stream (audio description in place of dialog). Applies to download_track and extract_dash.
This commit is contained in:
@@ -278,24 +278,22 @@ def extract_dash(track: "Track", session: Union[Session, RnetSession]) -> list[S
|
||||
|
||||
data = track.data["dash"]
|
||||
manifest = data["manifest"]
|
||||
rep_id = data.get("representation_id") or data["representation"].get("id")
|
||||
adaptation_set = data["adaptation_set"]
|
||||
representation = data["representation"]
|
||||
rep_id = data.get("representation_id") or representation.get("id")
|
||||
filtered_period_ids = data.get("filtered_period_ids", [])
|
||||
stored_period = data.get("period")
|
||||
track_url = track.url if isinstance(track.url, str) else track.url[0]
|
||||
|
||||
content_periods = [p for p in manifest.findall("Period") if DASH._is_content_period(p, filtered_period_ids)]
|
||||
|
||||
raw_segments: list[tuple[str, Optional[str]]] = []
|
||||
for period in content_periods:
|
||||
matched_rep = matched_as = None
|
||||
for as_ in period.findall("AdaptationSet"):
|
||||
if DASH.is_trick_mode(as_):
|
||||
continue
|
||||
for rep in as_.findall("Representation"):
|
||||
if rep.get("id") == rep_id:
|
||||
matched_rep, matched_as = rep, as_
|
||||
break
|
||||
if matched_rep is not None:
|
||||
break
|
||||
# rep ids are only unique within an AdaptationSet, so resolve like DASH.download_track
|
||||
if period is stored_period:
|
||||
matched_as, matched_rep = adaptation_set, representation
|
||||
else:
|
||||
matched_as, matched_rep = DASH.resolve_representation(period, rep_id, adaptation_set) or (None, None)
|
||||
if matched_rep is None or matched_as is None:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user