mirror of
https://github.com/glomatico/gamdl.git
synced 2026-06-13 12:15:18 +03:00
Refactor AppleMusic download flow for synced lyrics only
This commit is contained in:
@@ -337,9 +337,6 @@ class AppleMusicDownloader:
|
||||
|
||||
async def download(self, download_item: DownloadItem | Exception) -> None:
|
||||
try:
|
||||
if isinstance(download_item, Exception):
|
||||
raise download_item
|
||||
|
||||
await self._download(download_item)
|
||||
if not self.base_downloader.skip_processing:
|
||||
await self._final_processing(download_item)
|
||||
@@ -349,8 +346,13 @@ class AppleMusicDownloader:
|
||||
|
||||
async def _download(
|
||||
self,
|
||||
download_item: DownloadItem,
|
||||
download_item: DownloadItem | Exception,
|
||||
) -> None:
|
||||
if isinstance(download_item, Exception):
|
||||
raise download_item
|
||||
if self.song_downloader.synced_lyrics_only:
|
||||
return
|
||||
|
||||
if (
|
||||
Path(download_item.final_path).exists()
|
||||
and not self.base_downloader.overwrite
|
||||
@@ -396,7 +398,7 @@ class AppleMusicDownloader:
|
||||
self,
|
||||
download_item: DownloadItem,
|
||||
) -> None:
|
||||
if Path(download_item.staged_path).exists():
|
||||
if download_item.staged_path and Path(download_item.staged_path).exists():
|
||||
self.base_downloader.move_to_final_path(
|
||||
download_item.staged_path,
|
||||
download_item.final_path,
|
||||
|
||||
@@ -46,8 +46,6 @@ class AppleMusicSongDownloader:
|
||||
song_metadata,
|
||||
self.synced_lyrics_format,
|
||||
)
|
||||
if self.synced_lyrics_only:
|
||||
return download_item
|
||||
|
||||
webplayback = await self.downloader.apple_music_api.get_webplayback(song_id)
|
||||
download_item.media_tags = self.song_interface.get_tags(
|
||||
@@ -64,6 +62,18 @@ class AppleMusicSongDownloader:
|
||||
download_item.playlist_tags,
|
||||
)
|
||||
|
||||
download_item.final_path = self.downloader.get_final_path(
|
||||
download_item.media_tags,
|
||||
".m4a",
|
||||
download_item.playlist_tags,
|
||||
)
|
||||
download_item.synced_lyrics_path = self.get_lyrics_synced_path(
|
||||
download_item.final_path,
|
||||
)
|
||||
|
||||
if self.synced_lyrics_only:
|
||||
return download_item
|
||||
|
||||
if self.codec.is_legacy():
|
||||
download_item.stream_info = (
|
||||
await self.song_interface.get_stream_info_legacy(
|
||||
@@ -106,14 +116,6 @@ class AppleMusicSongDownloader:
|
||||
"staged",
|
||||
"." + download_item.stream_info.file_format.value,
|
||||
)
|
||||
download_item.final_path = self.downloader.get_final_path(
|
||||
download_item.media_tags,
|
||||
".m4a",
|
||||
download_item.playlist_tags,
|
||||
)
|
||||
download_item.synced_lyrics_path = self.get_lyrics_synced_path(
|
||||
download_item.final_path,
|
||||
)
|
||||
cover_file_extension = await self.downloader.get_cover_file_extension(
|
||||
download_item.cover_url_template,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user