draft: rewriting downloading
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Hellow 2024-05-13 21:51:32 +02:00
parent b09d6f2691
commit 8c369d79e4
1 changed files with 11 additions and 1 deletions

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()