From 25eea44d08de6fb869834ceb81ec4563d246f421 Mon Sep 17 00:00:00 2001 From: Hellow Date: Thu, 12 Jan 2023 19:55:24 +0100 Subject: [PATCH] commit --- src/goof.py | 3 ++- src/music_kraken/tagging/id3.py | 17 ++++++++--------- src/test.db | Bin 69632 -> 69632 bytes 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/goof.py b/src/goof.py index c7aab3d..b76b06e 100644 --- a/src/goof.py +++ b/src/goof.py @@ -51,7 +51,7 @@ song_input = Song( length=666, isrc="US-S1Z-99-00001", tracksort=2, - target=Target(file="test/Linkin Park/Hybrid Theory/out.mp3", path="~/Music/test/Linkin Park/Hybrid Theory/"), + target=Target(file="song.mp3", path="~/Music"), lyrics=[ Lyrics(text="these are some depressive lyrics", language="en"), Lyrics(text="test", language="en") @@ -101,6 +101,7 @@ for source in song.sources: write_metadata(song) exit() + # getting song by album ref div() song_output_list = cache.pull_songs(album_ref=album_input.reference) diff --git a/src/music_kraken/tagging/id3.py b/src/music_kraken/tagging/id3.py index 8d0b06d..e55319c 100644 --- a/src/music_kraken/tagging/id3.py +++ b/src/music_kraken/tagging/id3.py @@ -1,4 +1,4 @@ -import mutagen +import mutagen from mutagen.id3 import ID3, Frame from typing import List @@ -21,14 +21,12 @@ class AudioMetadata: if file_location is not None: self.file_location = file_location - def add_song_metadata(self, song: Song): print("adding") for key, value in song.metadata: """ https://www.programcreek.com/python/example/84797/mutagen.id3.ID3 """ - print(key, value) self.frames.add(mutagen.id3.Frames[key](encoding=3, text=value)) def save(self, file_location: str = None): @@ -43,18 +41,19 @@ class AudioMetadata: # 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) - self._file_location = file_location except mutagen.MutagenError: 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(song: Song): +def write_metadata(song: Song, ignore_file_not_found: bool = False): if not song.target.exists_on_disc: - print(song.target.file) - return - + if ignore_file_not_found: + return + raise ValueError(f"{song.target.file} not found") + id3_object = AudioMetadata(file_location=song.target.file) id3_object.add_song_metadata(song=song) id3_object.save() @@ -62,7 +61,7 @@ def write_metadata(song: Song): def write_many_metadata(song_list: List[Song]): for song in song_list: - write_metadata(song=song) + write_metadata(song=song, ignore_file_not_found=True) if __name__ == "__main__": diff --git a/src/test.db b/src/test.db index 9bcedc1cc672a04435c1f0bb690fae1e93b2ff7e..6445b106cad79dbaa4c1f8e661920bcf39a80411 100644 GIT binary patch delta 2554 zcmd5;OK%%h6t+Ea^N^ZbOH~22qN%V%rEuaqGk5L-At7MFB8>_{gTw;CeI{-kJE|Q- zSukZ2sbWKv9jk~vvKlYD=?_4#Wx;|Uz@q#Ejwh-_q?X(zyRm%cJif;{^YCQh;mN`e z*PFMFZhX+Z_4vz2uXj1ie3}&jWGWaiFAZoPJgDH5R6<%N`SInOZ&Wm6E@c@|DL63e z97tvysNAQVVv-Q-duze&_J`YRpNxjvX(45xMGis+2aIY3N~98K;e^N;bJ~e-nv3PT z>#b&)DQ1n85&{z$1}lTvnFPT-^+Hk3TcS9Ad~-dENxRZ$G!k;yAit9-Ih=Lq*QC0g zl+Bn~lX+ksF>LG2q+GtZZ&6&vZd!|^(;$yXXVzJ3lj^J1V)@$LrRCBq#Mk8ln4lh5 zVK^9s6|AGV_l~>Z+}^>sA0F&XCi~;Jd%eMMV=~%zVZ-^}7XD*l^S<8o!(L1)2Z;Ce z&82F&G+cRB_#BwD2za3lD5fcRWeh@&9833LbTBzE{(0s4=Z5h;7lvb}?+tc#@9m6T zOx-ylEi$bM!N=KEdO|*)106Ge4RlPuryu=7x-t5gJ^SJ>5~ZX$cggCL2KkJvtUj4_ zuKc`OZ6)op(I`1htzzDS^pXPO8oj{LJti-dLgiajdyL?=T6H>VxXzStP}sBpmZ}`I z&MX9(TJJ5|!-ray)deQ}uG?&v-j-;yjB~|-i^2kPa&B10fO3-=Cnyyn^!B{#>)t@$ zANM{T4G#8v@B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