feature/move_download_code_to_download #34

Merged
Hazel merged 18 commits from feature/move_download_code_to_download into experimental 2024-05-15 15:24:30 +00:00
Showing only changes of commit 8c369d79e4 - Show all commits

View File

@ -5,6 +5,7 @@ from . import FetchOptions, DownloadOptions
from .results import SearchResults
from ..objects import DatabaseObject as DataObject, Source, Album, Song, Artist, Label
from ..utils.string_processing import fit_to_file_system
from ..utils.config import youtube_settings
from ..utils.enums.source import SourcePages
from ..utils.support_classes.download_result import DownloadResult
@ -197,6 +198,9 @@ class Pages:
return download_result
def _download_song(self, song: Song, naming: dict) -> DownloadOptions:
# pre process the data recursively
song.compile()
# manage the naming
naming: Dict[str, List[str]] = defaultdict(list, naming)
naming["song"].append(song.title_string)
@ -207,10 +211,16 @@ class Pages:
naming["artist"].extend(a.name for a in song.feature_artist_collection)
for a in song.album_collection:
naming["label"].extend([l.title_string for l in a.label_collection])
# removing duplicates from the naming
# removing duplicates from the naming, and process the strings
for key, value in naming.items():
# https://stackoverflow.com/a/17016257
naming[key] = list(dict.fromkeys(items))
naming[key] = [fit_to_file_system(i) for i in naming[key] if i is not None]
# get every possible path
path_format = [*main_settings["download_path"].split("/"), main_settings["download_file"]]
every_possible_path: Set[str] = set()
return DownloadOptions()