yaaay
This commit is contained in:
parent
581a68cf46
commit
0ca8adac6f
Binary file not shown.
16
src/goof.py
16
src/goof.py
@ -10,8 +10,9 @@ from music_kraken import (
|
|||||||
|
|
||||||
import music_kraken.database.new_database as db
|
import music_kraken.database.new_database as db
|
||||||
|
|
||||||
def div(msg:str=""):
|
|
||||||
print("-"*50+msg+"-"*50)
|
def div(msg: str = ""):
|
||||||
|
print("-" * 50 + msg + "-" * 50)
|
||||||
|
|
||||||
|
|
||||||
cache = music_kraken.database.new_database.Database("test.db")
|
cache = music_kraken.database.new_database.Database("test.db")
|
||||||
@ -42,6 +43,7 @@ album_input.artists = [
|
|||||||
song_input = Song(
|
song_input = Song(
|
||||||
title="Vein Deep in the Solution",
|
title="Vein Deep in the Solution",
|
||||||
length=666,
|
length=666,
|
||||||
|
isrc="US-S1Z-99-00001",
|
||||||
tracksort=2,
|
tracksort=2,
|
||||||
target=Target(file="~/Music/genre/artist/album/song.mp3", path="~/Music/genre/artist/album"),
|
target=Target(file="~/Music/genre/artist/album/song.mp3", path="~/Music/genre/artist/album"),
|
||||||
lyrics=[
|
lyrics=[
|
||||||
@ -52,9 +54,9 @@ song_input = Song(
|
|||||||
Source(src="youtube", url="https://youtu.be/dfnsdajlhkjhsd"),
|
Source(src="youtube", url="https://youtu.be/dfnsdajlhkjhsd"),
|
||||||
Source(src="musify", url="https://ln.topdf.de/Music-Kraken/")
|
Source(src="musify", url="https://ln.topdf.de/Music-Kraken/")
|
||||||
],
|
],
|
||||||
album = album_input,
|
album=album_input,
|
||||||
main_artist_list = [main_artist],
|
main_artist_list=[main_artist],
|
||||||
feature_artist_list = [feature_artist]
|
feature_artist_list=[feature_artist]
|
||||||
)
|
)
|
||||||
|
|
||||||
other_song = Song(
|
other_song = Song(
|
||||||
@ -82,7 +84,8 @@ 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=" | ")
|
||||||
print("tracksort", song_output_list[0].tracksort, sep=": ")
|
print("tracksort", song_output_list[0].tracksort, sep=": ")
|
||||||
print("id3", str(song_output_list[0].metadata))
|
print("ID3 stuff")
|
||||||
|
print(str(song_output_list[0].metadata))
|
||||||
|
|
||||||
# getting song by album ref
|
# getting song by album ref
|
||||||
div()
|
div()
|
||||||
@ -103,7 +106,6 @@ print("--artist--")
|
|||||||
for artist in album_output.artists:
|
for artist in album_output.artists:
|
||||||
print(artist)
|
print(artist)
|
||||||
|
|
||||||
|
|
||||||
# getting album by song
|
# getting album by song
|
||||||
div()
|
div()
|
||||||
album_output_list = cache.pull_albums(song_ref=song_ref)
|
album_output_list = cache.pull_albums(song_ref=song_ref)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
class Mapping(Enum):
|
class Mapping(Enum):
|
||||||
|
TITLE = "TIT2"
|
||||||
|
ISRC = "TSRC"
|
||||||
|
LENGTH = "TLEN"
|
||||||
DATE = "TYER"
|
DATE = "TYER"
|
||||||
UNSYNCED_LYRICS = "USLT"
|
UNSYNCED_LYRICS = "USLT"
|
||||||
TRACKNUMBER = "TRCK"
|
TRACKNUMBER = "TRCK"
|
||||||
TOTALTRACKS = "TRCK" # Stored in the same frame with TRACKNUMBER, separated by '/': e.g. '4/9'.
|
TOTALTRACKS = "TRCK" # Stored in the same frame with TRACKNUMBER, separated by '/': e.g. '4/9'.
|
||||||
TITLE = "TIT2"
|
|
||||||
TITLESORTORDER = "TSOT"
|
TITLESORTORDER = "TSOT"
|
||||||
ENCODING_SETTINGS = "TSSE"
|
ENCODING_SETTINGS = "TSSE"
|
||||||
SUBTITLE = "TIT3"
|
SUBTITLE = "TIT3"
|
||||||
@ -34,7 +36,6 @@ class Mapping(Enum):
|
|||||||
ARTIST = "TPE1"
|
ARTIST = "TPE1"
|
||||||
LANGUAGE = "TLAN"
|
LANGUAGE = "TLAN"
|
||||||
ITUNESCOMPILATION = "TCMP"
|
ITUNESCOMPILATION = "TCMP"
|
||||||
ISRC = "TSRC"
|
|
||||||
REMIXED_BY = "TPE4"
|
REMIXED_BY = "TPE4"
|
||||||
RADIO_STATION_OWNER = "TRSO"
|
RADIO_STATION_OWNER = "TRSO"
|
||||||
RADIO_STATION = "TRSN"
|
RADIO_STATION = "TRSN"
|
||||||
|
@ -65,7 +65,6 @@ class Metadata:
|
|||||||
return "\n".join(rows)
|
return "\n".join(rows)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Source(DatabaseObject, SongAttribute):
|
class Source(DatabaseObject, SongAttribute):
|
||||||
"""
|
"""
|
||||||
create somehow like that
|
create somehow like that
|
||||||
@ -170,19 +169,21 @@ class Song(DatabaseObject):
|
|||||||
"""
|
"""
|
||||||
super().__init__(id_=id_)
|
super().__init__(id_=id_)
|
||||||
# attributes
|
# attributes
|
||||||
# self.id_: str | None = id_
|
# *private* attributes
|
||||||
self._title = None
|
self._title = None
|
||||||
|
self._isrc = None
|
||||||
self.mb_id: str | None = mb_id
|
self._length = None
|
||||||
self.album_name: str | None = album_name
|
|
||||||
self.isrc: str | None = isrc
|
|
||||||
self.length_: int | None = length
|
|
||||||
self.artist_names = artist_names
|
|
||||||
self.tracksort: int | None = tracksort
|
|
||||||
|
|
||||||
self.metadata = Metadata()
|
self.metadata = Metadata()
|
||||||
|
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.isrc = isrc
|
||||||
|
self.length = length
|
||||||
|
|
||||||
|
self.mb_id: str | None = mb_id
|
||||||
|
self.album_name: str | None = album_name
|
||||||
|
self.artist_names = artist_names
|
||||||
|
self.tracksort: int | None = tracksort
|
||||||
|
|
||||||
if sources is None:
|
if sources is None:
|
||||||
sources = []
|
sources = []
|
||||||
@ -240,44 +241,51 @@ class Song(DatabaseObject):
|
|||||||
the attribute the same as the defined property, but with one underscore infront:
|
the attribute the same as the defined property, but with one underscore infront:
|
||||||
title -> _title
|
title -> _title
|
||||||
"""
|
"""
|
||||||
|
if value is None:
|
||||||
|
return
|
||||||
|
|
||||||
attribute_map = {
|
attribute_map = {
|
||||||
"_title": ID3_MAPPING.TITLE
|
"_title": ID3_MAPPING.TITLE,
|
||||||
|
"_isrc": ID3_MAPPING.ISRC,
|
||||||
|
"_length": ID3_MAPPING.LENGTH
|
||||||
}
|
}
|
||||||
|
|
||||||
# if this crashes/raises an error the function is
|
# if this crashes/raises an error the function is
|
||||||
# called wrongly. I DO NOT CACH ERRORS DUE TO PERFORMANCE AND DEBUGGING
|
# called wrongly. I DO NOT CATCH ERRORS DUE TO PERFORMANCE AND DEBUGGING
|
||||||
self.__setattr__(name, value)
|
self.__setattr__(name, value)
|
||||||
self.metadata[attribute_map[name].value] = value
|
|
||||||
|
|
||||||
|
# convert value to id3 value if necessary
|
||||||
|
id3_value = value
|
||||||
|
if type(value) == int:
|
||||||
|
id3_value = str(value)
|
||||||
|
|
||||||
|
self.metadata[attribute_map[name].value] = id3_value
|
||||||
|
|
||||||
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 get_artist_names(self) -> List[str]:
|
def get_artist_names(self) -> List[str]:
|
||||||
return self.artist_names
|
return self.artist_names
|
||||||
|
|
||||||
def get_length(self):
|
def get_length(self):
|
||||||
if self.length_ is None:
|
if self._length is None:
|
||||||
return None
|
return None
|
||||||
return int(self.length_)
|
return int(self._length)
|
||||||
|
|
||||||
def set_length(self, length: int):
|
|
||||||
if type(length) != int:
|
|
||||||
raise TypeError(f"length of a song must be of the type int not {type(length)}")
|
|
||||||
self.length_ = length
|
|
||||||
|
|
||||||
def get_album_id(self):
|
def get_album_id(self):
|
||||||
if self.album is None:
|
if self.album is None:
|
||||||
return None
|
return None
|
||||||
return self.album.id
|
return self.album.id
|
||||||
|
|
||||||
title: str = property(fget=lambda self: self._title, fset=lambda self, value: self.set_simple_metadata("_title", value))
|
title: str = property(fget=lambda self: self._title,
|
||||||
|
fset=lambda self, value: self.set_simple_metadata("_title", value))
|
||||||
|
isrc: str = property(fget=lambda self: self._isrc,
|
||||||
|
fset=lambda self, value: self.set_simple_metadata("_isrc", 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)
|
||||||
length: int = property(fget=get_length, fset=set_length)
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
BIN
src/test.db
BIN
src/test.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user