diff --git a/gamdl/downloader/downloader.py b/gamdl/downloader/downloader.py index f32ff6c..35e2299 100644 --- a/gamdl/downloader/downloader.py +++ b/gamdl/downloader/downloader.py @@ -476,53 +476,45 @@ class AppleMusicDownloader: ): raise MediaFileExists(download_item.final_path) - if download_item.media_metadata["type"] in { - *SONG_MEDIA_TYPE, - *MUSIC_VIDEO_MEDIA_TYPE, - }: + if ( + self.base_downloader.download_mode == DownloadMode.NM3U8DLRE + and not self.base_downloader.full_nm3u8dlre_path + ): + raise ExecutableNotFound("N_m3u8DL-RE") + + if download_item.media_metadata["type"] in MUSIC_VIDEO_MEDIA_TYPE: if ( - not self.base_downloader.use_wrapper - or download_item.media_metadata["type"] in MUSIC_VIDEO_MEDIA_TYPE - or self.song_downloader.codec.is_legacy() + self.music_video_downloader.remux_mode == RemuxMode.FFMPEG + and not self.base_downloader.full_ffmpeg_path ): - if ( - self.base_downloader.remux_mode == RemuxMode.FFMPEG - and not self.base_downloader.full_ffmpeg_path - ): - raise ExecutableNotFound("ffmpeg") - - if ( - self.base_downloader.remux_mode == RemuxMode.MP4BOX - and not self.base_downloader.full_mp4box_path - ): - raise ExecutableNotFound("MP4Box") - - if ( - download_item.media_metadata["type"] in MUSIC_VIDEO_MEDIA_TYPE - or self.base_downloader.remux_mode == RemuxMode.MP4BOX - ) and not self.base_downloader.full_mp4decrypt_path: - raise ExecutableNotFound("mp4decrypt") + raise ExecutableNotFound("ffmpeg") if ( - self.base_downloader.download_mode == DownloadMode.NM3U8DLRE - and not self.base_downloader.full_nm3u8dlre_path + self.music_video_downloader.remux_mode == RemuxMode.MP4BOX + and not self.base_downloader.full_mp4box_path ): - raise ExecutableNotFound("N_m3u8DL-RE") + raise ExecutableNotFound("MP4Box") if ( - not download_item.stream_info - or not download_item.stream_info.audio_track - or not download_item.stream_info.audio_track.stream_url - or ( - ( - not download_item.decryption_key - or not download_item.decryption_key.audio_track - or not download_item.decryption_key.audio_track.key - ) - and not self.base_downloader.use_wrapper + download_item.media_metadata["type"] in MUSIC_VIDEO_MEDIA_TYPE + or self.music_video_downloader.remux_mode == RemuxMode.MP4BOX + ) and not self.base_downloader.full_mp4decrypt_path: + raise ExecutableNotFound("mp4decrypt") + + if ( + not download_item.stream_info + or not download_item.stream_info.audio_track + or not download_item.stream_info.audio_track.stream_url + or ( + ( + not download_item.decryption_key + or not download_item.decryption_key.audio_track + or not download_item.decryption_key.audio_track.key ) - ): - raise FormatNotAvailable(download_item.media_metadata["id"]) + and not self.base_downloader.use_wrapper + ) + ): + raise FormatNotAvailable(download_item.media_metadata["id"]) if download_item.media_metadata["type"] in SONG_MEDIA_TYPE: await self.song_downloader.download(download_item) diff --git a/gamdl/downloader/downloader_base.py b/gamdl/downloader/downloader_base.py index e5df4ed..9e7056d 100644 --- a/gamdl/downloader/downloader_base.py +++ b/gamdl/downloader/downloader_base.py @@ -12,7 +12,7 @@ from ..interface.enums import CoverFormat from ..interface.types import MediaTags, PlaylistTags from ..utils import CustomStringFormatter, async_subprocess from .constants import ILLEGAL_CHAR_REPLACEMENT, ILLEGAL_CHARS_RE, TEMP_PATH_TEMPLATE -from .enums import DownloadMode, RemuxMode +from .enums import DownloadMode from .hardcoded_wvd import HARDCODED_WVD @@ -32,7 +32,6 @@ class AppleMusicBaseDownloader: use_wrapper: bool = False, wrapper_decrypt_ip: str = "127.0.0.1:10020", download_mode: DownloadMode = DownloadMode.YTDLP, - remux_mode: RemuxMode = RemuxMode.FFMPEG, cover_format: CoverFormat = CoverFormat.JPG, album_folder_template: str = "{album_artist}/{album}", compilation_folder_template: str = "Compilations/{album}", @@ -60,7 +59,6 @@ class AppleMusicBaseDownloader: self.use_wrapper = use_wrapper self.wrapper_decrypt_ip = wrapper_decrypt_ip self.download_mode = download_mode - self.remux_mode = remux_mode self.cover_format = cover_format self.album_folder_template = album_folder_template self.compilation_folder_template = compilation_folder_template diff --git a/gamdl/downloader/downloader_music_video.py b/gamdl/downloader/downloader_music_video.py index 5ab4940..67baba9 100644 --- a/gamdl/downloader/downloader_music_video.py +++ b/gamdl/downloader/downloader_music_video.py @@ -18,12 +18,14 @@ class AppleMusicMusicVideoDownloader(AppleMusicBaseDownloader): MusicVideoCodec.H264, MusicVideoCodec.H265, ], + remux_mode: RemuxMode = RemuxMode.FFMPEG, remux_format: RemuxFormatMusicVideo = RemuxFormatMusicVideo.M4V, resolution: MusicVideoResolution = MusicVideoResolution.R1080P, ): self.__dict__.update(base_downloader.__dict__) self.interface = interface self.codec_priority = codec_priority + self.remux_mode = remux_mode self.remux_format = remux_format self.resolution = resolution