music-kraken-core/src/goof.py

150 lines
3.5 KiB
Python
Raw Normal View History

2022-11-30 15:15:38 +00:00
import music_kraken
2022-12-06 16:55:07 +00:00
from music_kraken import (
Song,
Lyrics,
Target,
2022-12-07 14:51:38 +00:00
Source,
2022-12-12 18:30:18 +00:00
Album,
2023-01-14 13:41:40 +00:00
Artist,
ID3Timestamp
2022-12-06 16:55:07 +00:00
)
2022-11-24 13:13:55 +00:00
2023-01-11 15:30:53 +00:00
from music_kraken.tagging import (
AudioMetadata,
write_metadata,
write_many_metadata
)
import music_kraken.database.new_database as db
2023-01-13 13:37:15 +00:00
import pycountry
2023-01-10 18:21:11 +00:00
def div(msg: str = ""):
print("-" * 50 + msg + "-" * 50)
2022-12-09 17:24:58 +00:00
2022-12-06 22:44:42 +00:00
cache = music_kraken.database.new_database.Database("test.db")
cache.reset()
2022-12-12 18:30:18 +00:00
main_artist = Artist(
name="I'm in a coffin"
)
2022-12-16 15:59:21 +00:00
artist_ref = main_artist.reference
2022-12-12 18:30:18 +00:00
split_artist = Artist(
name="split"
)
feature_artist = Artist(
2022-12-13 15:58:22 +00:00
name="Ghost"
2022-12-12 18:30:18 +00:00
)
2022-12-07 14:51:38 +00:00
album_input = Album(
2023-01-13 13:37:15 +00:00
title="One Final Action",
2023-01-14 13:41:40 +00:00
date=ID3Timestamp(year=1986, month=3, day=1),
2023-01-13 13:37:15 +00:00
language=pycountry.languages.get(alpha_2="en"),
label="cum productions"
2022-12-07 14:51:38 +00:00
)
2022-12-16 17:26:05 +00:00
album_input.artists = [
main_artist,
split_artist
]
2022-12-07 14:51:38 +00:00
2022-12-06 23:02:28 +00:00
song_input = Song(
title="Vein Deep in the Solution",
2022-12-06 22:44:42 +00:00
length=666,
2023-01-10 18:21:11 +00:00
isrc="US-S1Z-99-00001",
2022-12-09 17:24:58 +00:00
tracksort=2,
2023-01-12 18:55:24 +00:00
target=Target(file="song.mp3", path="~/Music"),
2022-12-06 16:55:07 +00:00
lyrics=[
2022-12-06 22:44:42 +00:00
Lyrics(text="these are some depressive lyrics", language="en"),
Lyrics(text="test", language="en")
2022-12-06 16:55:07 +00:00
],
sources=[
2022-12-06 22:44:42 +00:00
Source(src="youtube", url="https://youtu.be/dfnsdajlhkjhsd"),
Source(src="musify", url="https://ln.topdf.de/Music-Kraken/")
2022-12-07 14:51:38 +00:00
],
2023-01-10 18:21:11 +00:00
album=album_input,
main_artist_list=[main_artist],
2023-01-13 13:37:15 +00:00
feature_artist_list=[feature_artist],
)
2022-12-16 17:26:05 +00:00
other_song = Song(
title="this is just another song",
main_artist_list=[feature_artist],
feature_artist_list=[main_artist]
)
2022-12-13 15:58:22 +00:00
print(song_input)
2022-12-07 14:51:38 +00:00
additional_song = Song(
title="A fcking Song",
2022-12-13 10:16:19 +00:00
album=album_input
2022-12-07 14:51:38 +00:00
)
song_ref = song_input.reference
2022-12-06 22:44:42 +00:00
print(song_ref)
2022-12-06 22:44:42 +00:00
lyrics = Lyrics(text="these are some Lyrics that don't belong to any Song", language="en")
2022-12-06 13:45:18 +00:00
2022-12-16 17:26:05 +00:00
cache.push([album_input, song_input, lyrics, additional_song, other_song])
2022-12-07 14:51:38 +00:00
# getting song by song ref
2022-12-09 17:24:58 +00:00
div()
2022-12-07 14:51:38 +00:00
song_output_list = cache.pull_songs(song_ref=song_ref)
2022-12-09 17:24:58 +00:00
print(len(song_output_list), song_output_list, song_output_list[0].album, sep=" | ")
2023-01-11 01:25:17 +00:00
song = song_output_list[0]
2022-12-09 17:24:58 +00:00
print("tracksort", song_output_list[0].tracksort, sep=": ")
2023-01-11 14:28:22 +00:00
print("ID3", dict(song.metadata))
2023-01-10 18:21:11 +00:00
print(str(song_output_list[0].metadata))
2023-01-11 14:28:22 +00:00
print("--src--")
2023-01-11 01:25:17 +00:00
for source in song.sources:
print(source)
2023-01-11 15:30:53 +00:00
# try writing metadata
write_metadata(song)
2023-01-12 15:25:50 +00:00
exit()
2023-01-12 18:55:24 +00:00
2022-12-07 14:51:38 +00:00
# getting song by album ref
2022-12-09 17:24:58 +00:00
div()
2022-12-07 14:51:38 +00:00
song_output_list = cache.pull_songs(album_ref=album_input.reference)
print(len(song_output_list), song_output_list)
2022-12-09 17:24:58 +00:00
for song in song_output_list:
print(song, song.album)
2022-12-08 08:10:26 +00:00
# getting album
2022-12-16 17:26:05 +00:00
div("album")
2022-12-08 08:28:28 +00:00
album_output_list = cache.pull_albums(album_ref=album_input.reference)
album_output = album_output_list[0]
print(album_output)
2022-12-16 17:26:05 +00:00
print(f"--tracklist-{len(album_output)}--")
2022-12-09 17:24:58 +00:00
for track in album_output.tracklist:
print(track.tracksort, track)
2022-12-16 17:26:05 +00:00
print("--artist--")
for artist in album_output.artists:
print(artist)
2022-12-09 17:24:58 +00:00
# getting album by song
div()
album_output_list = cache.pull_albums(song_ref=song_ref)
print(album_output_list)
print("len of album ->", len(album_output_list[0]), album_output_list[0], sep=" | ")
2022-12-16 15:59:21 +00:00
# get artist
2022-12-16 17:26:05 +00:00
div("artist")
2022-12-16 15:59:21 +00:00
artist_output = cache.pull_artists(artist_ref=artist_ref)[0]
print(artist_output)
2022-12-16 17:26:05 +00:00
print("---static---")
print("albums", artist_output.main_albums)
print("main_s", artist_output.main_songs)
print("feat_s", artist_output.feature_songs)
print("---dynamic---")
print("discography", artist_output.discography)
print("songs", artist_output.songs, artist_output.songs.tracklist)
print("features", artist_output.features, artist_output.features.tracklist)