Add UnsupportedMediaType exception and checks for downloaders

This commit is contained in:
Rafael Moraes
2026-01-02 13:31:24 -03:00
parent 5e48032f34
commit 17863b500a
2 changed files with 15 additions and 0 deletions
+10
View File
@@ -27,6 +27,7 @@ from .exceptions import (
MediaFileExists,
NotStreamable,
SyncedLyricsOnly,
UnsupportedMediaType,
)
from .types import DownloadItem, UrlInfo
@@ -86,18 +87,27 @@ class AppleMusicDownloader:
raise NotStreamable(media_metadata["id"])
if media_metadata["type"] in SONG_MEDIA_TYPE:
if not self.song_downloader:
raise UnsupportedMediaType(media_metadata["type"])
download_item = await self.song_downloader.get_download_item(
media_metadata,
playlist_metadata,
)
if media_metadata["type"] in MUSIC_VIDEO_MEDIA_TYPE:
if not self.music_video_downloader:
raise UnsupportedMediaType(media_metadata["type"])
download_item = await self.music_video_downloader.get_download_item(
media_metadata,
playlist_metadata,
)
if media_metadata["type"] in UPLOADED_VIDEO_MEDIA_TYPE:
if not self.uploaded_video_downloader:
raise UnsupportedMediaType(media_metadata["type"])
download_item = await self.uploaded_video_downloader.get_download_item(
media_metadata,
)
+5
View File
@@ -25,3 +25,8 @@ class ExecutableNotFound(GamdlError):
class SyncedLyricsOnly(GamdlError):
def __init__(self):
super().__init__("Only downloading synced lyrics is supported")
class UnsupportedMediaType(GamdlError):
def __init__(self, media_type: str):
super().__init__(f"Unsupported media type: {media_type}")