Compare commits

...

17 Commits

Author SHA1 Message Date
Rafael Moraes e330e11d82 Bump version to 2.9.3 2026-03-08 13:37:46 -03:00
Rafael Moraes bebfcb02d8 Use trex defaults for sample duration/size 2026-03-08 13:35:21 -03:00
Rafael Moraes 29f68f6bc4 Bump version to 2.9.2 2026-03-05 15:08:42 -03:00
Rafael Moraes e77c6b24b4 Merge pull request #277 from LiuqingDu/fix-all-albums
Fix KeyError during artist download pagination
2026-03-05 15:07:16 -03:00
Liuqing Du ba315dcb95 Fix KeyError during artist download pagination 2026-02-28 11:50:52 -06:00
Rafael Moraes 4187fad734 Bump version to 2.9.1 2026-02-25 19:13:13 -03:00
Rafael Moraes f36edf4bbd Add 'Apple Music Classical' to README 2026-02-25 19:12:29 -03:00
Rafael Moraes 50478d427e Add Artist Auto-Select options to README 2026-02-25 19:11:20 -03:00
Rafael Moraes 45461007a9 Add artist auto select flag; rename song codec flag 2026-02-25 19:07:33 -03:00
Rafael Moraes 79a03d4f4c Rename artist_selection to artist_auto_select in CLI 2026-02-25 19:05:07 -03:00
Rafael Moraes beb508529a Rename ArtistDownloadSelection to ArtistAutoSelect 2026-02-25 19:04:52 -03:00
Rafael Moraes 87cf8c7789 Add artist_selection CLI option 2026-02-25 19:01:57 -03:00
Rafael Moraes 9e3f740eec Add ArtistDownloadSelection and auto-select option 2026-02-25 19:01:37 -03:00
Rafael Moraes 7281f5c949 Support song codec priority list 2026-02-25 18:16:34 -03:00
Rafael Moraes d32781b23f Skip wrapper decryption for legacy codecs 2026-02-25 17:52:15 -03:00
Rafael Moraes 5f2c74399e Merge pull request #276 from symphoniacus/fix-classical-url-parsing
fix: add support for Apple Music Classical URLs
2026-02-25 17:48:15 -03:00
symphoniacus d11e937c6a fix: allow Apple Music Classical URLs (classical.music.apple.com) 2026-02-14 19:24:56 +01:00
13 changed files with 326 additions and 164 deletions
+13 -1
View File
@@ -64,6 +64,7 @@ gamdl [OPTIONS] URLS...
- Music Videos
- Artists
- Post Videos
- Apple Music Classical
### Examples
@@ -128,6 +129,7 @@ The file is created automatically on first run. Command-line arguments override
| `--save-cover`, `-s` | Save cover as separate file | `false` |
| `--save-playlist` | Save M3U8 playlist file | `false` |
| **Download Options** | | |
| `--artist-auto-select` | Automatically select artist content to download (artist URLs) | - |
| `--nm3u8dlre-path` | N_m3u8DL-RE executable path | `N_m3u8DL-RE` |
| `--mp4decrypt-path` | mp4decrypt executable path | `mp4decrypt` |
| `--ffmpeg-path` | FFmpeg executable path | `ffmpeg` |
@@ -149,7 +151,7 @@ The file is created automatically on first run. Command-line arguments override
| `--cover-size` | Cover size in pixels | `1200` |
| `--truncate` | Max filename length | - |
| **Song Options** | | |
| `--song-codec` | Song codec | `aac-legacy` |
| `--song-codec-priority` | Comma-separated codec priority | `aac-legacy` |
| `--synced-lyrics-format` | Synced lyrics format | `lrc` |
| `--no-synced-lyrics` | Don't download synced lyrics | `false` |
| `--synced-lyrics-only` | Download only synced lyrics | `false` |
@@ -253,6 +255,16 @@ Use ISO 639-1 language codes (e.g., `en-US`, `es-ES`, `ja-JP`, `pt-BR`). Don't a
- `best` - Up to 1080p with AAC 256kbps
- `ask` - Interactive quality selection
### Artist Auto-Select Options
- `main-albums`
- `compilation-albums`
- `live-albums`
- `singles-eps`
- `all-albums`
- `top-songs`
- `music-videos`
## ⚙️ Wrapper
Use the [wrapper](https://github.com/WorldObservationLog/wrapper) to download songs in ALAC and other experimental codecs without API limitations. Cookies are not required when using the wrapper.
+1 -1
View File
@@ -1 +1 @@
__version__ = "2.9"
__version__ = "2.9.3"
+8 -3
View File
@@ -142,7 +142,7 @@ async def main(config: CliConfig):
song_downloader = AppleMusicSongDownloader(
base_downloader=base_downloader,
interface=song_interface,
codec=config.song_codec,
codec_priority=config.song_codec_piority,
synced_lyrics_format=config.synced_lyrics_format,
no_synced_lyrics=config.no_synced_lyrics,
synced_lyrics_only=config.synced_lyrics_only,
@@ -168,6 +168,7 @@ async def main(config: CliConfig):
song_downloader=song_downloader,
music_video_downloader=music_video_downloader,
uploaded_video_downloader=uploaded_video_downloader,
artist_auto_select=config.artist_auto_select,
)
if not config.synced_lyrics_only:
@@ -197,7 +198,8 @@ async def main(config: CliConfig):
)
if not base_downloader.full_mp4decrypt_path and (
config.song_codec not in (SongCodec.AAC_LEGACY, SongCodec.AAC_HE_LEGACY)
config.song_codec_piority
not in (SongCodec.AAC_LEGACY, SongCodec.AAC_HE_LEGACY)
or config.music_video_remux_mode == RemuxMode.MP4BOX
):
missing_music_video_paths.append(
@@ -210,7 +212,10 @@ async def main(config: CliConfig):
+ "\n".join(missing_music_video_paths)
)
if not config.song_codec.is_legacy() and not config.use_wrapper:
if (
any(not codec.is_legacy() for codec in config.song_codec_piority)
and not config.use_wrapper
):
logger.warning(
"You have chosen an experimental song codec "
"without enabling wrapper. "
+19 -6
View File
@@ -9,9 +9,11 @@ from dataclass_click import argument, option
from ..api import AppleMusicApi
from ..downloader import (
AppleMusicBaseDownloader,
AppleMusicDownloader,
AppleMusicMusicVideoDownloader,
AppleMusicSongDownloader,
AppleMusicUploadedVideoDownloader,
ArtistAutoSelect,
DownloadMode,
RemuxFormatMusicVideo,
RemuxMode,
@@ -35,6 +37,7 @@ song_downloader_sig = inspect.signature(AppleMusicSongDownloader.__init__)
uploaded_video_downloader_sig = inspect.signature(
AppleMusicUploadedVideoDownloader.__init__
)
downloader_sig = inspect.signature(AppleMusicDownloader.__init__)
@dataclass
@@ -135,6 +138,16 @@ class CliConfig:
default=api_sig.parameters["language"].default,
),
]
# Downloader specific options
artist_auto_select: Annotated[
ArtistAutoSelect | None,
option(
"--artist-auto-select",
help="Automatically select artist content to download (only for artist URLs)",
default=downloader_sig.parameters["artist_auto_select"].default,
type=ArtistAutoSelect,
),
]
# Base Downloader specific options
output_path: Annotated[
str,
@@ -362,13 +375,13 @@ class CliConfig:
),
]
# DownloaderSong specific options
song_codec: Annotated[
SongCodec,
song_codec_piority: Annotated[
list[SongCodec],
option(
"--song-codec",
help="Song codec",
default=song_downloader_sig.parameters["codec"].default,
type=SongCodec,
"--song-codec-priority",
help="Comma-separated codec priority",
default=song_downloader_sig.parameters["codec_priority"].default,
type=Csv(SongCodec),
),
]
synced_lyrics_format: Annotated[
+79 -4
View File
@@ -158,16 +158,25 @@ def extract_song(input_path: str) -> SongInfo:
elif box["type"] == "moov":
song_info.moov_data = box["data"]
# Get default sample info from trex (inside moov)
default_sample_duration = 1024
default_sample_size = 0
# Determine which track is the audio track
audio_track_id = (
_extract_audio_track_id(song_info.moov_data) if song_info.moov_data else 1
)
logger.debug(f"Audio track ID: {audio_track_id}")
# Get default sample info from trex (inside moov/mvex)
trex_defaults = (
_extract_trex_defaults(song_info.moov_data, audio_track_id)
if song_info.moov_data
else {"default_sample_duration": 1024, "default_sample_size": 0}
)
default_sample_duration = trex_defaults["default_sample_duration"]
default_sample_size = trex_defaults["default_sample_size"]
logger.debug(
f"Default sample duration: {default_sample_duration}, "
f"default sample size: {default_sample_size}"
)
# Extract encryption scheme info from moov (sinf/schm + sinf/schi/tenc)
if song_info.moov_data:
song_info.encryption_info = _extract_encryption_info(song_info.moov_data)
@@ -1306,6 +1315,72 @@ def _write_udta(f):
_fixup_box_size(f, udta_start, b"udta")
def _extract_trex_defaults(moov_data: bytes, target_track_id: int = 0) -> dict:
"""Extract default sample values from moov/mvex/trex box.
The trex (Track Extends) box provides default values for sample duration,
size, description index, and flags used by track fragments (traf/trun)
when those fields are not explicitly present.
Args:
moov_data: Raw bytes of the moov box.
target_track_id: If > 0, only return defaults for this track.
If 0, return the first trex found.
Returns:
Dict with keys: default_sample_duration, default_sample_size,
default_sample_description_index, default_sample_flags.
"""
defaults = {
"default_sample_duration": 1024,
"default_sample_size": 0,
"default_sample_description_index": 1,
"default_sample_flags": 0,
}
# Find mvex box inside moov
mvex = _find_child_box(moov_data, b"mvex")
if mvex is None:
return defaults
# Iterate trex children inside mvex
offset = 8 # Skip mvex box header
while offset + 8 <= len(mvex):
size = struct.unpack(">I", mvex[offset : offset + 4])[0]
box_type = mvex[offset + 4 : offset + 8]
if size < 8 or offset + size > len(mvex):
break
if box_type == b"trex" and size >= 32:
# trex FullBox: size(4) + type(4) + version(1) + flags(3)
# + track_id(4) + default_sample_description_index(4)
# + default_sample_duration(4) + default_sample_size(4)
# + default_sample_flags(4)
trex_data = mvex[offset : offset + size]
track_id = struct.unpack(">I", trex_data[12:16])[0]
if target_track_id == 0 or track_id == target_track_id:
defaults["default_sample_description_index"] = struct.unpack(
">I", trex_data[16:20]
)[0]
defaults["default_sample_duration"] = struct.unpack(
">I", trex_data[20:24]
)[0]
defaults["default_sample_size"] = struct.unpack(">I", trex_data[24:28])[
0
]
defaults["default_sample_flags"] = struct.unpack(
">I", trex_data[28:32]
)[0]
logger.debug(
f"trex defaults for track {track_id}: "
f"duration={defaults['default_sample_duration']}, "
f"size={defaults['default_sample_size']}"
)
break
offset += size
return defaults
def _extract_encryption_info(moov_data: bytes) -> Optional[EncryptionInfo]:
"""Extract encryption scheme info from the audio track's sinf box.
+20 -1
View File
@@ -11,8 +11,27 @@ ARTIST_MEDIA_TYPE = {"artist", "artists", "library-artists"}
UPLOADED_VIDEO_MEDIA_TYPE = {"post", "uploaded-videos"}
PLAYLIST_MEDIA_TYPE = {"playlist", "playlists", "library-playlists"}
ARTIST_AUTO_SELECT_KEY_MAP = {
"main-albums": ("views", "full-albums"),
"compilation-albums": ("views", "compilation-albums"),
"live-albums": ("views", "live-albums"),
"singles-eps": ("views", "singles"),
"all-albums": ("relationships", "albums"),
"top-songs": ("views", "top-songs"),
"music-videos": ("relationships", "music-videos"),
}
ARTIST_AUTO_SELECT_STR_MAP = {
"main-albums": "Main Albums",
"compilation-albums": "Compilation Albums",
"live-albums": "Live Albums",
"singles-eps": "Singles & EPs",
"all-albums": "All Albums",
"top-songs": "Top Songs",
"music-videos": "Music Videos",
}
VALID_URL_PATTERN = re.compile(
r"https://music\.apple\.com"
r"https://(?:classical\.)?music\.apple\.com"
r"(?:"
r"/(?P<storefront>[a-z]{2})"
r"/(?P<type>artist|album|playlist|song|music-video|post)"
+125 -119
View File
@@ -21,7 +21,7 @@ from .downloader_base import AppleMusicBaseDownloader
from .downloader_music_video import AppleMusicMusicVideoDownloader
from .downloader_song import AppleMusicSongDownloader
from .downloader_uploaded_video import AppleMusicUploadedVideoDownloader
from .enums import DownloadMode, RemuxMode
from .enums import ArtistAutoSelect, DownloadMode, RemuxMode
from .exceptions import (
ExecutableNotFound,
FormatNotAvailable,
@@ -41,6 +41,7 @@ class AppleMusicDownloader:
song_downloader: AppleMusicSongDownloader,
music_video_downloader: AppleMusicMusicVideoDownloader,
uploaded_video_downloader: AppleMusicUploadedVideoDownloader,
artist_auto_select: ArtistAutoSelect | None = None,
skip_music_videos: bool = False,
skip_processing: bool = False,
flat_filter: typing.Callable = None,
@@ -50,6 +51,7 @@ class AppleMusicDownloader:
self.song_downloader = song_downloader
self.music_video_downloader = music_video_downloader
self.uploaded_video_downloader = uploaded_video_downloader
self.artist_auto_select = artist_auto_select
self.skip_music_videos = skip_music_videos
self.skip_processing = skip_processing
self.flat_filter = flat_filter
@@ -150,92 +152,86 @@ class AppleMusicDownloader:
self,
artist_metadata: dict,
) -> list[DownloadItem]:
media_type = await inquirer.select(
message=f'Select which type to download for artist "{artist_metadata["attributes"]["name"]}":',
choices=[
Choice(
name="Main Albums",
value=["views", "full-albums"],
),
Choice(
name="Compilations Albums",
value=["views", "compilation-albums"],
),
Choice(
name="Live Albums",
value=["views", "live-albums"],
),
Choice(
name="Singles & EPs",
value=["views", "singles"],
),
Choice(
name="All Albums",
value=["relationships", "albums"],
),
Choice(
name="Top Songs",
value=["views", "top-songs"],
),
Choice(
name="Music Videos",
value=["relationships", "music-videos"],
),
],
validate=lambda result: artist_metadata.get(result[0], {})
.get(result[1], {})
.get("data"),
invalid_message="The artist doesn't have any items of this type",
).execute_async()
media_type, media_type_key = media_type
artist_metadata[media_type][media_type_key]["data"].extend(
[
extended_data
async for extended_data in self.interface.apple_music_api.extend_api_data(
artist_metadata[media_type][media_type_key],
if not self.artist_auto_select:
available_choices = []
for artist_auto_select_option in list(ArtistAutoSelect):
relation_key, type_key = artist_auto_select_option.path_key
available_choices.append(
Choice(
name=str(artist_auto_select_option),
value=(artist_auto_select_option,),
),
)
]
)
selected_tracks = artist_metadata[media_type][media_type_key]["data"]
if media_type_key in {
"full-albums",
"compilation-albums",
"live-albums",
"singles",
"albums",
(artist_auto_select,) = await inquirer.select(
message=f'Select which type to download for artist "{artist_metadata["attributes"]["name"]}":',
choices=available_choices,
validate=lambda result: artist_metadata.get(result[0].path_key[0], {})
.get(result[0].path_key[1], {})
.get("data"),
).execute_async()
else:
artist_auto_select = self.artist_auto_select
relation_key, type_key = artist_auto_select.path_key
async for extended_data in self.interface.apple_music_api.extend_api_data(
artist_metadata[relation_key][type_key],
):
artist_metadata[relation_key][type_key]["data"].extend(extended_data["data"])
selected_items = artist_metadata[relation_key][type_key]["data"]
select_all = self.artist_auto_select is not None
if artist_auto_select in {
ArtistAutoSelect.MAIN_ALBUMS,
ArtistAutoSelect.COMPILATION_ALBUMS,
ArtistAutoSelect.LIVE_ALBUMS,
ArtistAutoSelect.SINGLES_EPS,
ArtistAutoSelect.ALL_ALBUMS,
}:
return await self.get_artist_albums_download_items(selected_tracks)
elif media_type_key == "top-songs":
return await self.get_artist_songs_download_items(selected_tracks)
elif media_type_key == "music-videos":
return await self.get_artist_music_videos_download_items(selected_tracks)
return await self.get_artist_albums_download_items(
selected_items,
select_all,
)
elif artist_auto_select == ArtistAutoSelect.TOP_SONGS:
return await self.get_artist_songs_download_items(
selected_items,
select_all,
)
elif artist_auto_select == ArtistAutoSelect.MUSIC_VIDEOS:
return await self.get_artist_music_videos_download_items(
selected_items,
select_all,
)
async def get_artist_albums_download_items(
self,
albums_metadata: list[dict],
select_all: bool = False,
) -> list[DownloadItem]:
choices = [
Choice(
name=" | ".join(
[
f'{album["attributes"]["trackCount"]:03d}',
f'{album["attributes"]["releaseDate"]:<10}',
f'{album["attributes"].get("contentRating", "None").title():<8}',
f'{album["attributes"]["name"]}',
]
),
value=album,
)
for album in albums_metadata
if album.get("attributes")
]
selected = await inquirer.select(
message="Select which albums to download: (Track Count | Release Date | Rating | Title)",
choices=choices,
multiselect=True,
).execute_async()
if not select_all:
choices = [
Choice(
name=" | ".join(
[
f'{album["attributes"]["trackCount"]:03d}',
f'{album["attributes"]["releaseDate"]:<10}',
f'{album["attributes"].get("contentRating", "None").title():<8}',
f'{album["attributes"]["name"]}',
]
),
value=album,
)
for album in albums_metadata
if album.get("attributes")
]
selected = await inquirer.select(
message="Select which albums to download: (Track Count | Release Date | Rating | Title)",
choices=choices,
multiselect=True,
).execute_async()
else:
selected = albums_metadata
download_items = []
@@ -259,28 +255,32 @@ class AppleMusicDownloader:
async def get_artist_music_videos_download_items(
self,
music_videos_metadata: list[dict],
select_all: bool = False,
) -> list[DownloadItem]:
choices = [
Choice(
name=" | ".join(
[
self.millis_to_min_sec(
music_video["attributes"]["durationInMillis"]
),
f'{music_video["attributes"].get("contentRating", "None").title():<8}',
music_video["attributes"]["name"],
],
),
value=music_video,
)
for music_video in music_videos_metadata
if music_video.get("attributes")
]
selected = await inquirer.select(
message="Select which music videos to download: (Duration | Rating | Title)",
choices=choices,
multiselect=True,
).execute_async()
if not select_all:
choices = [
Choice(
name=" | ".join(
[
self.millis_to_min_sec(
music_video["attributes"]["durationInMillis"]
),
f'{music_video["attributes"].get("contentRating", "None").title():<8}',
music_video["attributes"]["name"],
],
),
value=music_video,
)
for music_video in music_videos_metadata
if music_video.get("attributes")
]
selected = await inquirer.select(
message="Select which music videos to download: (Duration | Rating | Title)",
choices=choices,
multiselect=True,
).execute_async()
else:
selected = music_videos_metadata
music_video_tasks = [
self.get_single_download_item(
@@ -295,26 +295,32 @@ class AppleMusicDownloader:
async def get_artist_songs_download_items(
self,
songs_metadata: list[dict],
select_all: bool = False,
) -> list[DownloadItem]:
choices = [
Choice(
name=" | ".join(
[
self.millis_to_min_sec(song["attributes"]["durationInMillis"]),
f'{song["attributes"].get("contentRating", "None").title():<8}',
song["attributes"]["name"],
],
),
value=song,
)
for song in songs_metadata
if song.get("attributes")
]
selected = await inquirer.select(
message="Select which songs to download: (Duration | Rating | Title)",
choices=choices,
multiselect=True,
).execute_async()
if not select_all:
choices = [
Choice(
name=" | ".join(
[
self.millis_to_min_sec(
song["attributes"]["durationInMillis"]
),
f'{song["attributes"].get("contentRating", "None").title():<8}',
song["attributes"]["name"],
],
),
value=song,
)
for song in songs_metadata
if song.get("attributes")
]
selected = await inquirer.select(
message="Select which songs to download: (Duration | Rating | Title)",
choices=choices,
multiselect=True,
).execute_async()
else:
selected = songs_metadata
song_tasks = [
self.get_single_download_item(
+22 -24
View File
@@ -13,7 +13,7 @@ class AppleMusicSongDownloader(AppleMusicBaseDownloader):
self,
base_downloader: AppleMusicBaseDownloader,
interface: AppleMusicSongInterface,
codec: SongCodec = SongCodec.AAC_LEGACY,
codec_priority: SongCodec = [SongCodec.AAC_LEGACY],
synced_lyrics_format: SyncedLyricsFormat = SyncedLyricsFormat.LRC,
no_synced_lyrics: bool = False,
synced_lyrics_only: bool = False,
@@ -22,7 +22,7 @@ class AppleMusicSongDownloader(AppleMusicBaseDownloader):
):
self.__dict__.update(base_downloader.__dict__)
self.interface = interface
self.codec = codec
self.codec_priority = codec_priority
self.synced_lyrics_format = synced_lyrics_format
self.no_synced_lyrics = no_synced_lyrics
self.synced_lyrics_only = synced_lyrics_only
@@ -78,33 +78,31 @@ class AppleMusicSongDownloader(AppleMusicBaseDownloader):
if self.synced_lyrics_only:
return download_item
if self.codec.is_legacy():
download_item.stream_info = await self.interface.get_stream_info_legacy(
for codec in self.codec_priority:
download_item.stream_info = await self.interface.get_stream_info(
codec,
song_metadata,
webplayback,
self.codec,
)
if download_item.stream_info:
break
if download_item.stream_info.audio_track.legacy:
download_item.decryption_key = (
await self.interface.get_decryption_key_legacy(
download_item.stream_info,
self.cdm,
)
)
else:
download_item.stream_info = await self.interface.get_stream_info(
song_metadata,
self.codec,
elif (
not self.use_wrapper
and download_item.stream_info
and download_item.stream_info.audio_track.widevine_pssh
):
download_item.decryption_key = await self.interface.get_decryption_key(
download_item.stream_info,
self.cdm,
)
if (
not self.use_wrapper
and download_item.stream_info
and download_item.stream_info.audio_track.widevine_pssh
):
download_item.decryption_key = await self.interface.get_decryption_key(
download_item.stream_info,
self.cdm,
)
else:
download_item.decryption_key = None
download_item.cover_url_template = self.interface.get_cover_url_template(
song_metadata,
@@ -173,11 +171,11 @@ class AppleMusicSongDownloader(AppleMusicBaseDownloader):
encrypted_path: str,
staged_path: str,
decryption_key: DecryptionKeyAv,
codec: SongCodec,
legacy: bool,
media_id: str,
fairplay_key: str,
):
if self.use_wrapper:
if self.use_wrapper and not legacy:
await self.decrypt_amdecrypt(
encrypted_path,
staged_path,
@@ -189,7 +187,7 @@ class AppleMusicSongDownloader(AppleMusicBaseDownloader):
encrypted_path,
staged_path,
decryption_key.audio_track.key,
legacy=codec.is_legacy(),
legacy,
)
def get_lyrics_synced_path(self, final_path: str) -> str:
@@ -232,7 +230,7 @@ class AppleMusicSongDownloader(AppleMusicBaseDownloader):
encrypted_path,
download_item.staged_path,
download_item.decryption_key,
self.codec,
download_item.stream_info.audio_track.legacy,
download_item.media_metadata["id"],
download_item.stream_info.audio_track.fairplay_key,
)
+22
View File
@@ -1,5 +1,10 @@
from enum import Enum
from .constants import (
ARTIST_AUTO_SELECT_KEY_MAP,
ARTIST_AUTO_SELECT_STR_MAP,
)
class DownloadMode(Enum):
YTDLP = "ytdlp"
@@ -14,3 +19,20 @@ class RemuxMode(Enum):
class RemuxFormatMusicVideo(Enum):
M4V = "m4v"
MP4 = "mp4"
class ArtistAutoSelect(Enum):
MAIN_ALBUMS = "main-albums"
COMPILATION_ALBUMS = "compilation-albums"
LIVE_ALBUMS = "live-albums"
SINGLES_EPS = "singles-eps"
ALL_ALBUMS = "all-albums"
TOP_SONGS = "top-songs"
MUSIC_VIDEOS = "music-videos"
@property
def path_key(self) -> tuple[str, str]:
return ARTIST_AUTO_SELECT_KEY_MAP[self.value]
def __str__(self) -> str:
return ARTIST_AUTO_SELECT_STR_MAP[self.value]
+14 -3
View File
@@ -226,6 +226,17 @@ class AppleMusicSongInterface(AppleMusicInterface):
return tags
async def get_stream_info(
self,
codec: SongCodec,
song_metadata: dict | None = None,
webplayback: dict | None = None,
) -> StreamInfoAv | None:
if codec.is_legacy():
return await self._get_stream_info_legacy(webplayback, codec)
else:
return await self._get_stream_info(song_metadata, codec)
async def _get_stream_info(
self,
song_metadata: dict,
codec: SongCodec,
@@ -257,7 +268,7 @@ class AppleMusicSongInterface(AppleMusicInterface):
if playlist is None:
return None
stream_info = StreamInfo()
stream_info = StreamInfo(legacy=False)
stream_info.stream_url = (
f"{m3u8_master_url.rpartition('/')[0]}/{playlist['uri']}"
)
@@ -386,14 +397,14 @@ class AppleMusicSongInterface(AppleMusicInterface):
return key.uri
return None
async def get_stream_info_legacy(
async def _get_stream_info_legacy(
self,
webplayback: dict,
codec: SongCodec,
) -> StreamInfoAv:
flavor = "32:ctrp64" if codec == SongCodec.AAC_HE_LEGACY else "28:ctrp256"
stream_info = StreamInfo()
stream_info = StreamInfo(legacy=True)
stream_info.stream_url = next(
i for i in webplayback["songList"][0]["assets"] if i["flavor"] == flavor
)["URL"]
+1
View File
@@ -121,6 +121,7 @@ class StreamInfo:
codec: str = None
width: int = None
height: int = None
legacy: bool = None
@dataclass
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "gamdl"
version = "2.9"
version = "2.9.3"
description = "A command-line app for downloading Apple Music songs, music videos and post videos."
readme = "README.md"
license = "MIT"
Generated
+1 -1
View File
@@ -214,7 +214,7 @@ wheels = [
[[package]]
name = "gamdl"
version = "2.9"
version = "2.9.3"
source = { virtual = "." }
dependencies = [
{ name = "async-lru" },