Refactor song interface stream logic and imports

This commit is contained in:
Rafael Moraes
2026-05-23 22:57:28 -03:00
parent 5a41dfbdaa
commit 740cad2ee0
+8 -5
View File
@@ -12,7 +12,7 @@ import structlog
from .base import AppleMusicBaseInterface
from .constants import DRM_DEFAULT_KEY_MAPPING, MP4_FORMAT_CODECS, SONG_CODEC_REGEX_MAP
from .enums import MediaRating, MediaType, SongCodec, SyncedLyricsFormat
from .enums import SongCodec, SyncedLyricsFormat
from .exceptions import (
GamdlInterfaceDecryptionNotAvailableError,
GamdlInterfaceFormatNotAvailableError,
@@ -23,7 +23,6 @@ from .types import (
DecryptionKeyAv,
Lyrics,
MediaFileFormat,
MediaTags,
StreamInfo,
StreamInfoAv,
)
@@ -244,9 +243,9 @@ class AppleMusicSongInterface:
) -> StreamInfoAv:
stream_info = None
if is_library and webplayback:
if is_library:
stream_info = await self._get_library_stream_info(webplayback)
elif webplayback or m3u8_master_url:
else:
for codec in self.codec_priority:
if codec.is_web:
stream_info = await self._get_web_stream_info(webplayback, codec)
@@ -464,10 +463,14 @@ class AppleMusicSongInterface:
async def _get_library_stream_info(
self,
webplayback: dict,
webplayback: dict | None,
) -> StreamInfoAv | None:
log = logger.bind(action="get_library_song_stream_info")
if not webplayback:
log.debug("no_webplayback")
return None
stream_info = StreamInfo(drm_free=True)
if len(webplayback["songList"][0]["assets"]) == 0: