music-kraken-core/src/create_custom_objects.py

139 lines
3.3 KiB
Python
Raw Normal View History

2023-01-23 23:16:10 +00:00
import music_kraken
from music_kraken import (
Song,
Lyrics,
Target,
Source,
Album,
Artist,
ID3Timestamp,
SourcePages,
SourceTypes
)
from music_kraken.tagging import (
AudioMetadata,
write_metadata,
write_many_metadata
)
import music_kraken.database.new_database as db
import pycountry
def div(msg: str = ""):
print("-" * 50 + msg + "-" * 50)
cache = music_kraken.database.new_database.Database("test.db")
cache.reset()
2023-01-30 13:41:02 +00:00
def print_song(song_: Song):
print(str(song_.metadata))
print("----src----")
print("song:")
print(song_.source_list)
print("album:")
print(song_.album.source_list)
print("\n")
2023-01-23 23:16:10 +00:00
2023-01-30 13:41:02 +00:00
song = Song(
2023-01-23 23:16:10 +00:00
genre="HS Core",
title="Vein Deep in the Solution",
length=666,
isrc="US-S1Z-99-00001",
tracksort=2,
target=Target(file="song.mp3", path="~/Music"),
lyrics=[
Lyrics(text="these are some depressive lyrics", language="en"),
2023-01-30 13:41:02 +00:00
Lyrics(text="Dies sind depressive Lyrics", language="de")
2023-01-23 23:16:10 +00:00
],
2023-01-30 13:41:02 +00:00
source_list=[
2023-01-23 23:16:10 +00:00
Source(SourcePages.YOUTUBE, "https://youtu.be/dfnsdajlhkjhsd"),
Source(SourcePages.MUSIFY, "https://ln.topdf.de/Music-Kraken/")
],
2023-01-30 13:41:02 +00:00
album=Album(
title="One Final Action",
date=ID3Timestamp(year=1986, month=3, day=1),
language=pycountry.languages.get(alpha_2="en"),
label="cum productions",
source_list=[
Source(SourcePages.ENCYCLOPAEDIA_METALLUM, "https://www.metal-archives.com/albums/I%27m_in_a_Coffin/One_Final_Action/207614")
]
),
main_artist_list=[
Artist(
name="I'm in a coffin",
source_list=[
Source(SourcePages.ENCYCLOPAEDIA_METALLUM, "https://www.metal-archives.com/bands/I%27m_in_a_Coffin/127727")
]
),
Artist(name="some_split_artist")
],
feature_artist_list=[Artist(name="Ruffiction")],
2023-01-23 23:16:10 +00:00
)
2023-01-30 13:41:02 +00:00
print_song(song)
2023-01-23 23:16:10 +00:00
2023-01-30 14:57:01 +00:00
2023-01-23 23:16:10 +00:00
2023-01-30 13:41:02 +00:00
song_ref = song.reference
2023-01-23 23:16:10 +00:00
2023-01-30 13:41:02 +00:00
cache.push([song])
2023-01-30 14:57:01 +00:00
exit()
2023-01-23 23:16:10 +00:00
# getting song by song ref
div()
2023-01-30 13:41:02 +00:00
song_list = cache.pull_songs(song_ref=song_ref)
song_from_db = song_list[0]
2023-01-23 23:16:10 +00:00
# try writing metadata
write_metadata(song)
exit()
# getting song by album ref
div()
song_output_list = cache.pull_songs(album_ref=album_input.reference)
print(len(song_output_list), song_output_list)
for song in song_output_list:
print(song, song.album)
# getting album
div("album")
album_output_list = cache.pull_albums(album_ref=album_input.reference)
album_output = album_output_list[0]
print(album_output)
print(f"--tracklist-{len(album_output)}--")
for track in album_output.tracklist:
print(track.tracksort, track)
print("--artist--")
for artist in album_output.artists:
print(artist)
# 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=" | ")
# get artist
div("artist")
artist_output = cache.pull_artists(artist_ref=artist_ref)[0]
print(artist_output)
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)