fdasf
This commit is contained in:
parent
0ca8adac6f
commit
07f18c9efa
@ -83,9 +83,13 @@ cache.push([album_input, song_input, lyrics, additional_song, other_song])
|
|||||||
div()
|
div()
|
||||||
song_output_list = cache.pull_songs(song_ref=song_ref)
|
song_output_list = cache.pull_songs(song_ref=song_ref)
|
||||||
print(len(song_output_list), song_output_list, song_output_list[0].album, sep=" | ")
|
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("tracksort", song_output_list[0].tracksort, sep=": ")
|
||||||
print("ID3 stuff")
|
print("ID3 stuff")
|
||||||
print(str(song_output_list[0].metadata))
|
print(str(song_output_list[0].metadata))
|
||||||
|
print("sources:")
|
||||||
|
for source in song.sources:
|
||||||
|
print(source)
|
||||||
|
|
||||||
# getting song by album ref
|
# getting song by album ref
|
||||||
div()
|
div()
|
||||||
|
@ -50,13 +50,17 @@ class Metadata:
|
|||||||
def get_all_metadata(self):
|
def get_all_metadata(self):
|
||||||
return list(self.id3_attributes.items())
|
return list(self.id3_attributes.items())
|
||||||
|
|
||||||
def __setitem__(self, item, value):
|
def __setitem__(self, key, value):
|
||||||
self.id3_attributes[item] = value
|
self.id3_attributes[key] = value
|
||||||
|
|
||||||
def __getitem__(self, item):
|
def __getitem__(self, key):
|
||||||
if item not in self.data:
|
if key not in self.id3_attributes:
|
||||||
return None
|
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:
|
def __str__(self) -> str:
|
||||||
rows = []
|
rows = []
|
||||||
@ -173,6 +177,7 @@ class Song(DatabaseObject):
|
|||||||
self._title = None
|
self._title = None
|
||||||
self._isrc = None
|
self._isrc = None
|
||||||
self._length = None
|
self._length = None
|
||||||
|
self._sources: List[Source] = []
|
||||||
|
|
||||||
self.metadata = Metadata()
|
self.metadata = Metadata()
|
||||||
|
|
||||||
@ -185,11 +190,10 @@ class Song(DatabaseObject):
|
|||||||
self.artist_names = artist_names
|
self.artist_names = artist_names
|
||||||
self.tracksort: int | None = tracksort
|
self.tracksort: int | None = tracksort
|
||||||
|
|
||||||
if sources is None:
|
if sources is not None:
|
||||||
sources = []
|
fuck_you_garbage_collector = sources[:]
|
||||||
self.sources: List[Source] = sources
|
print("constructor", sources)
|
||||||
for source in self.sources:
|
self.sources = sources
|
||||||
source.add_song(self)
|
|
||||||
|
|
||||||
if target is None:
|
if target is None:
|
||||||
target = Target()
|
target = Target()
|
||||||
@ -261,12 +265,28 @@ class Song(DatabaseObject):
|
|||||||
|
|
||||||
self.metadata[attribute_map[name].value] = id3_value
|
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):
|
def get_metadata(self):
|
||||||
return self.metadata.get_all_metadata()
|
return self.metadata.get_all_metadata()
|
||||||
|
|
||||||
def has_isrc(self) -> bool:
|
def has_isrc(self) -> bool:
|
||||||
return self._isrc is not None
|
return self._isrc is not None
|
||||||
|
|
||||||
|
def add_source(self, source: Source):
|
||||||
|
pass
|
||||||
|
|
||||||
def get_artist_names(self) -> List[str]:
|
def get_artist_names(self) -> List[str]:
|
||||||
return self.artist_names
|
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))
|
length: int = property(fget=get_length, fset=lambda self, value: self.set_simple_metadata("_length", value))
|
||||||
album_id: str = property(fget=get_album_id)
|
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
|
All objects dependent on Album
|
||||||
|
BIN
src/test.db
BIN
src/test.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user