cleaned up console output

This commit is contained in:
Hellow 2023-04-04 17:34:16 +02:00
parent da28616011
commit 5f735c25de
3 changed files with 21 additions and 13 deletions

View File

@ -10,3 +10,5 @@ python-dateutil~=2.8.2
pandoc~=2.3
SQLAlchemy
setuptools~=60.2.0
tqdm~=4.65.0
peewee~=3.15.4

View File

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

View File

@ -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
@ -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,17 +39,18 @@ 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
@ -59,6 +59,7 @@ def write_metadata_to_target(metadata: Metadata, target: Target):
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: