fixed exceptions
This commit is contained in:
parent
0423cb3139
commit
635c8b87a4
@ -1,14 +1,5 @@
|
||||
import music_kraken
|
||||
from music_kraken import objects
|
||||
|
||||
from music_kraken.tagging import (
|
||||
AudioMetadata,
|
||||
write_metadata,
|
||||
write_many_metadata
|
||||
)
|
||||
|
||||
import music_kraken.database.old_database as db
|
||||
|
||||
import pycountry
|
||||
import logging
|
||||
|
||||
@ -19,10 +10,7 @@ def div(msg: str = ""):
|
||||
print("-" * 50 + msg + "-" * 50)
|
||||
|
||||
|
||||
cache.reset()
|
||||
|
||||
|
||||
def print_song(song_: Song):
|
||||
def print_song(song_: objects.Song):
|
||||
print(str(song_.metadata))
|
||||
print("----album--")
|
||||
print(song_.album)
|
||||
@ -34,49 +22,56 @@ def print_song(song_: Song):
|
||||
print("\n")
|
||||
|
||||
|
||||
song = Song(
|
||||
song = objects.Song(
|
||||
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"),
|
||||
Lyrics(text="Dies sind depressive Lyrics", language="de")
|
||||
target=[
|
||||
objects.Target(file="song.mp3", path="example")
|
||||
],
|
||||
lyrics_list=[
|
||||
objects.Lyrics(text="these are some depressive lyrics", language="en"),
|
||||
objects.Lyrics(text="Dies sind depressive Lyrics", language="de")
|
||||
],
|
||||
source_list=[
|
||||
Source(SourcePages.YOUTUBE, "https://youtu.be/dfnsdajlhkjhsd"),
|
||||
Source(SourcePages.MUSIFY, "https://ln.topdf.de/Music-Kraken/")
|
||||
objects.Source(objects.SourcePages.YOUTUBE, "https://youtu.be/dfnsdajlhkjhsd"),
|
||||
objects.Source(objects.SourcePages.MUSIFY, "https://ln.topdf.de/Music-Kraken/")
|
||||
],
|
||||
album=Album(
|
||||
album_list=[
|
||||
objects.Album(
|
||||
title="One Final Action",
|
||||
date=ID3Timestamp(year=1986, month=3, day=1),
|
||||
date=objects.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")
|
||||
objects.Source(objects.SourcePages.ENCYCLOPAEDIA_METALLUM, "https://www.metal-archives.com/albums/I%27m_in_a_Coffin/One_Final_Action/207614")
|
||||
]
|
||||
),
|
||||
],
|
||||
main_artist_list=[
|
||||
Artist(
|
||||
objects.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")
|
||||
objects.Source(
|
||||
objects.SourcePages.ENCYCLOPAEDIA_METALLUM,
|
||||
"https://www.metal-archives.com/bands/I%27m_in_a_Coffin/127727"
|
||||
)
|
||||
]
|
||||
),
|
||||
Artist(name="some_split_artist")
|
||||
objects.Artist(name="some_split_artist")
|
||||
],
|
||||
feature_artist_list=[Artist(name="Ruffiction")],
|
||||
feature_artist_list=[objects.Artist(name="Ruffiction")],
|
||||
)
|
||||
|
||||
print_song(song)
|
||||
print(song)
|
||||
|
||||
exit()
|
||||
|
||||
div()
|
||||
song_ref = song.reference
|
||||
cache.push([song])
|
||||
|
||||
|
||||
# getting song by song ref
|
||||
song_list = cache.pull_songs(song_ref=song_ref)
|
||||
|
@ -15,7 +15,6 @@ ID3Timestamp = metadata.ID3Timestamp
|
||||
Source = source.Source
|
||||
SourceTypes = source.SourceTypes
|
||||
SourcePages = source.SourcePages
|
||||
SourceAttribute = source.SourceAttribute
|
||||
|
||||
Song = song.Song
|
||||
Artist = song.Artist
|
||||
|
@ -34,6 +34,7 @@ class Collection:
|
||||
"""
|
||||
self._attribute_to_object_map: Dict[str, Dict[object, DatabaseObject]] = defaultdict(dict)
|
||||
|
||||
if data is not None:
|
||||
self.extend(data, merge_on_conflict=True)
|
||||
|
||||
def sort(self, reverse: bool = False, **kwargs):
|
||||
@ -51,7 +52,7 @@ class Collection:
|
||||
"""
|
||||
|
||||
# if the element type has been defined in the initializer it checks if the type matches
|
||||
if self.element_type is not None and isinstance(element, self.element_type):
|
||||
if self.element_type is not None and not isinstance(element, self.element_type):
|
||||
raise TypeError(f"{type(element)} is not the set type {self.element_type}")
|
||||
|
||||
for name, value in element.indexing_values:
|
||||
|
@ -18,7 +18,7 @@ class Lyrics(DatabaseObject):
|
||||
source_list: List[Source] = None,
|
||||
**kwargs
|
||||
) -> None:
|
||||
DatabaseObject.__init__(_id=_id, dynamic=dynamic)
|
||||
DatabaseObject.__init__(self, _id=_id, dynamic=dynamic)
|
||||
|
||||
self.text: FormattedText = text
|
||||
self.language: pycountry.Languages = language
|
||||
|
@ -20,7 +20,6 @@ from .source import (
|
||||
Source,
|
||||
SourceTypes,
|
||||
SourcePages,
|
||||
SourceAttribute,
|
||||
SourceCollection
|
||||
)
|
||||
from .formatted_text import FormattedText
|
||||
@ -462,7 +461,7 @@ Label
|
||||
"""
|
||||
|
||||
|
||||
class Label(MainObject, SourceAttribute):
|
||||
class Label(MainObject):
|
||||
COLLECTION_ATTRIBUTES = ("album_collection", "current_artist_collection")
|
||||
SIMPLE_ATTRIBUTES = ("name",)
|
||||
|
||||
|
@ -47,7 +47,7 @@ class SourcePages(Enum):
|
||||
return homepage_map[attribute]
|
||||
|
||||
|
||||
class Source(DatabaseObject, MetadataAttribute):
|
||||
class Source(DatabaseObject):
|
||||
"""
|
||||
create somehow like that
|
||||
```python
|
||||
@ -95,14 +95,14 @@ class Source(DatabaseObject, MetadataAttribute):
|
||||
if url.startswith("https://twitter"):
|
||||
return cls(SourcePages.TWITTER, url)
|
||||
|
||||
def get_song_metadata(self) -> MetadataAttribute.Metadata:
|
||||
return MetadataAttribute.Metadata({
|
||||
def get_song_metadata(self) -> Metadata:
|
||||
return Metadata({
|
||||
Mapping.FILE_WEBPAGE_URL: [self.url],
|
||||
Mapping.SOURCE_WEBPAGE_URL: [self.homepage]
|
||||
})
|
||||
|
||||
def get_artist_metadata(self) -> MetadataAttribute.Metadata:
|
||||
return MetadataAttribute.Metadata({
|
||||
def get_artist_metadata(self) -> Metadata:
|
||||
return Metadata({
|
||||
Mapping.ARTIST_WEBPAGE_URL: [self.url]
|
||||
})
|
||||
|
||||
@ -136,9 +136,10 @@ class Source(DatabaseObject, MetadataAttribute):
|
||||
|
||||
class SourceCollection(Collection):
|
||||
def __init__(self, source_list: List[Source]):
|
||||
self._page_to_source_list: Dict[SourcePages, List[Source]] = defaultdict(list)
|
||||
|
||||
super().__init__(data=source_list, element_type=Source)
|
||||
|
||||
self._page_to_source_list: Dict[SourcePages, List[Source]] = defaultdict(list)
|
||||
|
||||
def map_element(self, source: Source):
|
||||
super().map_element(source)
|
||||
|
@ -2,7 +2,7 @@ from typing import (
|
||||
List
|
||||
)
|
||||
|
||||
from ..database import (
|
||||
from ..objects import (
|
||||
Song,
|
||||
Source,
|
||||
Album,
|
||||
|
Loading…
Reference in New Issue
Block a user