Skip to content

Commit

Permalink
fix(HLS): Ensure playlist.stream_info.codecs exists before use
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Apr 14, 2024
1 parent 43585a7 commit 1db8944
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions devine/core/manifests/hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def to_tracks(self, language: Union[str, Language]) -> Tracks:

try:
# TODO: Any better way to figure out the primary track type?
Video.Codec.from_codecs(playlist.stream_info.codecs)
if playlist.stream_info.codecs:
Video.Codec.from_codecs(playlist.stream_info.codecs)
except ValueError:
primary_track_type = Audio
else:
Expand All @@ -110,7 +111,10 @@ def to_tracks(self, language: Union[str, Language]) -> Tracks:
tracks.add(primary_track_type(
id_=hex(crc32(str(playlist).encode()))[2:],
url=urljoin(playlist.base_uri, playlist.uri),
codec=primary_track_type.Codec.from_codecs(playlist.stream_info.codecs),
codec=(
primary_track_type.Codec.from_codecs(playlist.stream_info.codecs)
if playlist.stream_info.codecs else None
),
language=language, # HLS manifests do not seem to have language info
is_original_lang=True, # TODO: All we can do is assume Yes
bitrate=playlist.stream_info.average_bandwidth or playlist.stream_info.bandwidth,
Expand All @@ -125,7 +129,7 @@ def to_tracks(self, language: Union[str, Language]) -> Tracks:
**(dict(
range_=Video.Range.DV if any(
codec.split(".")[0] in ("dva1", "dvav", "dvhe", "dvh1")
for codec in playlist.stream_info.codecs.lower().split(",")
for codec in (playlist.stream_info.codecs or "").lower().split(",")
) else Video.Range.from_m3u_range_tag(playlist.stream_info.video_range),
width=playlist.stream_info.resolution[0],
height=playlist.stream_info.resolution[1],
Expand Down

0 comments on commit 1db8944

Please sign in to comment.