From 07f18c9efa42f3704425001752d6d344adeb6075 Mon Sep 17 00:00:00 2001 From: Hellow Date: Wed, 11 Jan 2023 02:25:17 +0100 Subject: [PATCH] fdasf --- src/goof.py | 4 +++ src/music_kraken/database/objects/song.py | 42 ++++++++++++++++------ src/test.db | Bin 69632 -> 69632 bytes 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/goof.py b/src/goof.py index 56fb076..33b90d5 100644 --- a/src/goof.py +++ b/src/goof.py @@ -83,9 +83,13 @@ cache.push([album_input, song_input, lyrics, additional_song, other_song]) div() song_output_list = cache.pull_songs(song_ref=song_ref) print(len(song_output_list), song_output_list, song_output_list[0].album, sep=" | ") +song = song_output_list[0] print("tracksort", song_output_list[0].tracksort, sep=": ") print("ID3 stuff") print(str(song_output_list[0].metadata)) +print("sources:") +for source in song.sources: + print(source) # getting song by album ref div() diff --git a/src/music_kraken/database/objects/song.py b/src/music_kraken/database/objects/song.py index 0be2301..f8f5e7c 100644 --- a/src/music_kraken/database/objects/song.py +++ b/src/music_kraken/database/objects/song.py @@ -50,13 +50,17 @@ class Metadata: def get_all_metadata(self): return list(self.id3_attributes.items()) - def __setitem__(self, item, value): - self.id3_attributes[item] = value + def __setitem__(self, key, value): + self.id3_attributes[key] = value - def __getitem__(self, item): - if item not in self.data: + def __getitem__(self, key): + if key not in self.id3_attributes: return None - return self.data[item] + return self.id3_attributes[key] + + def delete_item(self, key: str): + if key in self.id3_attributes: + return self.id3_attributes.pop(key) def __str__(self) -> str: rows = [] @@ -173,6 +177,7 @@ class Song(DatabaseObject): self._title = None self._isrc = None self._length = None + self._sources: List[Source] = [] self.metadata = Metadata() @@ -185,11 +190,10 @@ class Song(DatabaseObject): self.artist_names = artist_names self.tracksort: int | None = tracksort - if sources is None: - sources = [] - self.sources: List[Source] = sources - for source in self.sources: - source.add_song(self) + if sources is not None: + fuck_you_garbage_collector = sources[:] + print("constructor", sources) + self.sources = sources if target is None: target = Target() @@ -261,12 +265,28 @@ class Song(DatabaseObject): self.metadata[attribute_map[name].value] = id3_value + def add_source(self, source_obj: Source): + source_obj.add_song(self) + + print(source_obj) + self._sources.append(source_obj) + self.metadata[ID3_MAPPING.FILE_WEBPAGE_URL.value] = source_obj.url + + def set_sources(self, source_list): + self.metadata.delete_item(ID3_MAPPING.FILE_WEBPAGE_URL.value) + self._sources = [] + for source in source_list: + self.add_source(source) + def get_metadata(self): return self.metadata.get_all_metadata() def has_isrc(self) -> bool: return self._isrc is not None + def add_source(self, source: Source): + pass + def get_artist_names(self) -> List[str]: return self.artist_names @@ -287,6 +307,8 @@ class Song(DatabaseObject): length: int = property(fget=get_length, fset=lambda self, value: self.set_simple_metadata("_length", value)) album_id: str = property(fget=get_album_id) + sources: List[Source] = property(fget=lambda self: self._sources, fset=set_sources) + """ All objects dependent on Album diff --git a/src/test.db b/src/test.db index 8a6e3f7f0088b7bfc54625446ff7a9933021eec0..9bcedc1cc672a04435c1f0bb690fae1e93b2ff7e 100644 GIT binary patch delta 2089 zcmc&#J!=#}7{0x|QzMv-jS2>H$bo_6g_)gi5L6T_Oi++5MdvdKN+RS0vDsJ{(8_p! zAccipNDdpTlvdgXD}R7RtSoizYz!o1Iv2Lu;oax!eP(U5wYJ%Mdoi2Zn7o-yZ9jT_ zsVk9jLO2fGPzO{v3)(RZlp`Xw(%fL(KQnc?Ce&bAdJase_?eXkjI;qL*4Sw7ogw~4 zC)meJ%L|?RE6WSg3hqkm0XZXqI*LI_tHH5=ti=WqrC($xt7|jOtWpYDB!dAO;yD_m z0jaP9;j|YXGnHeE`rA`8-ITFAoi|0D!YrT8t1N|C^GaTg9SbsIJkyBJM0`JvWxtB- z^v5jwUA+6=8no_xE|S0x_8j)$n6^A;500T2$15Xw~`Aw`P$ zX1i)Ms-T<+4l!^-`Dm^xK?N>=W6q+*RyoW673|hgS$H{{wX0{g;@Fo`k!XIP9H^!e zv_=wC#HXE!@lj=eyPoNPsA-v^@aZUSUaU8Yy<)xC8l1iUyr_pZrU)_eJB8xN?-b}G zG=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