forked from kenzuya/unshackle
fix(hls): give a variant or media entry listed twice one track
This commit is contained in:
@@ -192,6 +192,7 @@ class HLS:
|
||||
|
||||
All Track objects' URL will be to another M3U(8) document. However, these documents
|
||||
will be Invariant Playlists and contain the list of segments URIs among other metadata.
|
||||
A variant or a media entry that the master lists twice gets one track.
|
||||
"""
|
||||
session_keys = list(self.manifest.session_keys or [])
|
||||
if not session_keys:
|
||||
@@ -236,7 +237,12 @@ class HLS:
|
||||
(raw.get("stream_info") or {}).get("req_video_layout")
|
||||
for raw in (getattr(self.manifest, "data", None) or {}).get("playlists", [])
|
||||
]
|
||||
variants: set[str] = set()
|
||||
for playlist, video_layout in zip(self.manifest.playlists, video_layouts, strict=False):
|
||||
variant = str(playlist)
|
||||
if variant in variants:
|
||||
continue
|
||||
variants.add(variant)
|
||||
video_codec: Video.Codec | None = None
|
||||
audio_codec: Audio.Codec | None = None
|
||||
primary_track_type: type[Audio] | type[Video]
|
||||
@@ -273,7 +279,7 @@ class HLS:
|
||||
|
||||
tracks.add(
|
||||
primary_track_type(
|
||||
id_=hex(crc32(str(playlist).encode()))[2:],
|
||||
id_=hex(crc32(variant.encode()))[2:],
|
||||
url=urljoin(playlist.base_uri, playlist.uri),
|
||||
codec=cast(Any, video_codec or audio_codec),
|
||||
language=language, # HLS manifests do not seem to have language info
|
||||
@@ -302,9 +308,11 @@ class HLS:
|
||||
)
|
||||
)
|
||||
|
||||
entries: set[str] = set()
|
||||
for media in self.manifest.media:
|
||||
if not media.uri:
|
||||
if not media.uri or str(media) in entries:
|
||||
continue
|
||||
entries.add(str(media))
|
||||
|
||||
joc = 0
|
||||
track_type: type[Audio] | type[Subtitle]
|
||||
|
||||
Reference in New Issue
Block a user