diff --git a/votify/downloader/base.py b/votify/downloader/base.py index 50a71f4..9c2a6d6 100644 --- a/votify/downloader/base.py +++ b/votify/downloader/base.py @@ -9,6 +9,7 @@ from pathlib import Path import httpx from async_lru import alru_cache +from ..interface.enums import MediaType from mutagen.flac import Picture from mutagen.mp4 import MP4, MP4Cover from mutagen.oggvorbis import OggVorbis, OggVorbisHeaderError @@ -36,9 +37,11 @@ class SpotifyBaseDownloader: shaka_packager_path: str = "packager", album_folder_template: str = "{album_artist}/{album}", compilation_folder_template: str = "Compilations/{album}", + podcast_folder_template: str = "Podcasts/{album}", no_album_folder_template: str = "{artist}/Unknown Album", single_disc_file_template: str = "{track:02d} {title}", multi_disc_file_template: str = "{disc}-{track:02d} {title}", + podcast_file_template: str = "{track:02d} {title}", no_album_file_template: str = "{title}", playlist_file_template: str = "Playlists/{playlist_artist}/{playlist_title}", date_tag_template: str = "%Y-%m-%dT%H:%M:%SZ", @@ -58,9 +61,11 @@ class SpotifyBaseDownloader: self.shaka_packager_path = shaka_packager_path self.album_folder_template = album_folder_template self.compilation_folder_template = compilation_folder_template + self.podcast_folder_template = podcast_folder_template self.no_album_folder_template = no_album_folder_template self.single_disc_file_template = single_disc_file_template self.multi_disc_file_template = multi_disc_file_template + self.podcast_file_template = podcast_file_template self.no_album_file_template = no_album_file_template self.playlist_file_template = playlist_file_template self.date_tag_template = date_tag_template @@ -115,23 +120,24 @@ class SpotifyBaseDownloader: file_extension: str, playlist_tags: PlaylistTags | None, ) -> str: - if tags.album: - template_folder_parts = ( - self.compilation_folder_template.split("/") - if tags.compilation - else self.album_folder_template.split("/") - ) + if tags.media_type in {MediaType.PODCAST, MediaType.PODCAST_VIDEO}: + template_folder_parts = self.podcast_folder_template.split("/") + template_file_parts = self.podcast_file_template.split("/") else: - template_folder_parts = self.no_album_folder_template.split("/") - - if tags.album: - template_file_parts = ( - self.multi_disc_file_template.split("/") - if isinstance(tags.disc_total, int) and tags.disc_total > 1 - else self.single_disc_file_template.split("/") - ) - else: - template_file_parts = self.no_album_file_template.split("/") + if tags.album: + template_folder_parts = ( + self.compilation_folder_template.split("/") + if tags.compilation + else self.album_folder_template.split("/") + ) + template_file_parts = ( + self.multi_disc_file_template.split("/") + if isinstance(tags.disc_total, int) and tags.disc_total > 1 + else self.single_disc_file_template.split("/") + ) + else: + template_folder_parts = self.no_album_folder_template.split("/") + template_file_parts = self.no_album_file_template.split("/") template_parts = template_folder_parts + template_file_parts formatted_parts = []