From 5f735c25de7768ead4357b9327435acd0f795e3a Mon Sep 17 00:00:00 2001 From: Hellow Date: Tue, 4 Apr 2023 17:34:16 +0200 Subject: [PATCH] cleaned up console output --- requirements.txt | 4 +++- src/actual_donwload.py | 9 +++++++-- src/music_kraken/tagging/id3.py | 21 +++++++++++---------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/requirements.txt b/requirements.txt index 341b3d7..199b902 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,6 @@ pycountry~=22.3.5 python-dateutil~=2.8.2 pandoc~=2.3 SQLAlchemy -setuptools~=60.2.0 \ No newline at end of file +setuptools~=60.2.0 +tqdm~=4.65.0 +peewee~=3.15.4 \ No newline at end of file diff --git a/src/actual_donwload.py b/src/actual_donwload.py index 9a84d18..7b5ccfe 100644 --- a/src/actual_donwload.py +++ b/src/actual_donwload.py @@ -1,6 +1,6 @@ import music_kraken from music_kraken import pages -from music_kraken.objects import Song, Target, Source, SourcePages +from music_kraken.objects import Song, Target, Source, SourcePages, Album def search_pages(): @@ -43,6 +43,11 @@ def download_audio(): pages.Musify.download_song(song) +def real_download(): + search = pages.Search() + search.search_url("https://musify.club/release/children-of-the-night-2018-1079829") + search.download_chosen() + if __name__ == "__main__": - music_kraken.cli() + real_download() diff --git a/src/music_kraken/tagging/id3.py b/src/music_kraken/tagging/id3.py index 20d02e1..b402281 100644 --- a/src/music_kraken/tagging/id3.py +++ b/src/music_kraken/tagging/id3.py @@ -1,11 +1,11 @@ import mutagen from mutagen.id3 import ID3, Frame - +from pathlib import Path from typing import List import logging from ..utils.shared import ( - TAGGING_LOGGER as logger + TAGGING_LOGGER as LOGGER ) from ..objects import Song, Target, Metadata @@ -18,7 +18,7 @@ class AudioMetadata: if file_location is not None: self.file_location = file_location - + def add_metadata(self, metadata: Metadata): for value in metadata: """ @@ -29,10 +29,9 @@ class AudioMetadata: def add_song_metadata(self, song: Song): self.add_metadata(song.metadata) + def save(self, file_location: Path = None): + LOGGER.debug(f"saving following frames: {self.frames.pprint()}") - def save(self, file_location: str = None): - print("saving") - print(self.frames.pprint()) if file_location is not None: self.file_location = file_location @@ -40,25 +39,27 @@ class AudioMetadata: raise Exception("no file target provided to save the data to") self.frames.save(self.file_location, v2_version=4) - def set_file_location(self, file_location): + def set_file_location(self, file_location: Path): # try loading the data from the given file. if it doesn't succeed the frame remains empty try: self.frames.load(file_location, v2_version=4) - logger.info(f"loaded following from \"{file_location}\"\n{self.frames.pprint()}") + LOGGER.debug(f"loaded following from \"{file_location}\"\n{self.frames.pprint()}") except mutagen.MutagenError: - logger.warning(f"couldn't find any metadata at: \"{self.file_location}\"") + LOGGER.warning(f"couldn't find any metadata at: \"{self.file_location}\"") self._file_location = file_location file_location = property(fget=lambda self: self._file_location, fset=set_file_location) + def write_metadata_to_target(metadata: Metadata, target: Target): if not target.exists: return - + id3_object = AudioMetadata(file_location=target.file_path) id3_object.add_metadata(metadata) id3_object.save() + def write_metadata(song: Song, ignore_file_not_found: bool = True): target: Target for target in song.target: