finished database integration and simmilar
This commit is contained in:
@@ -161,9 +161,12 @@ class Database:
|
||||
|
||||
for source in album.source_list:
|
||||
source.type_enum = SourceTypes.ALBUM
|
||||
source.add_song(album)
|
||||
self.push_source(source=source)
|
||||
|
||||
def push_song(self, song: Song):
|
||||
if song.dynamic:
|
||||
return
|
||||
# ADDING THE DATA FOR THE SONG OBJECT
|
||||
"""
|
||||
db_field - object attribute
|
||||
@@ -356,6 +359,7 @@ class Database:
|
||||
Gets a list of sources. if source_ref is passed in the List will most likely only
|
||||
contain one Element if everything goes accordingly.
|
||||
**If neither song_ref nor source_ref are passed in it will return ALL sources**
|
||||
:param artist_ref:
|
||||
:param song_ref:
|
||||
:param source_ref:
|
||||
:param type_str: the thing the source belongs to like eg. "song" or "album"
|
||||
@@ -512,7 +516,6 @@ class Database:
|
||||
)
|
||||
|
||||
if Album not in exclude_relations and song_result['album_id'] is not None:
|
||||
print(dict(song_result))
|
||||
album_obj = self.pull_albums(album_ref=Reference(song_result['album_id']),
|
||||
exclude_relations=new_exclude_relations)
|
||||
if len(album_obj) > 0:
|
||||
|
@@ -5,10 +5,6 @@ import dateutil.tz
|
||||
from mutagen import id3
|
||||
import datetime
|
||||
|
||||
from .parents import (
|
||||
ID3Metadata
|
||||
)
|
||||
|
||||
|
||||
class Mapping(Enum):
|
||||
"""
|
||||
@@ -253,7 +249,7 @@ class MetadataAttribute:
|
||||
"""
|
||||
|
||||
class Metadata:
|
||||
# its a null byte for the later concatenation of text frames
|
||||
# it's a null byte for the later concatenation of text frames
|
||||
NULL_BYTE: str = "\x00"
|
||||
# this is pretty self-explanatory
|
||||
# the key is an enum from Mapping
|
||||
|
@@ -64,13 +64,3 @@ class SongAttribute:
|
||||
self.song_ref = Reference(song_id)
|
||||
|
||||
song_ref_id = property(fget=get_ref_song_id, fset=set_ref_song_id)
|
||||
|
||||
|
||||
class ID3Metadata:
|
||||
def get_metadata(self):
|
||||
pass
|
||||
|
||||
def get_id3_dict(self) -> dict:
|
||||
return {}
|
||||
|
||||
id3_dict: dict = property(fget=get_id3_dict)
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import os
|
||||
from typing import List, Tuple, Dict
|
||||
import datetime
|
||||
from typing import List
|
||||
import pycountry
|
||||
import copy
|
||||
|
||||
from .metadata import (
|
||||
Mapping as ID3_MAPPING,
|
||||
Mapping as id3Mapping,
|
||||
ID3Timestamp,
|
||||
MetadataAttribute
|
||||
)
|
||||
@@ -15,8 +15,7 @@ from ...utils.shared import (
|
||||
from .parents import (
|
||||
DatabaseObject,
|
||||
Reference,
|
||||
SongAttribute,
|
||||
ID3Metadata
|
||||
SongAttribute
|
||||
)
|
||||
from .source import (
|
||||
Source,
|
||||
@@ -83,11 +82,11 @@ class Target(DatabaseObject, SongAttribute):
|
||||
class Lyrics(DatabaseObject, SongAttribute, SourceAttribute, MetadataAttribute):
|
||||
def __init__(
|
||||
self,
|
||||
text: str,
|
||||
language: str,
|
||||
text: str,
|
||||
language: str,
|
||||
id_: str = None,
|
||||
source_list: List[Source] = None
|
||||
) -> None:
|
||||
) -> None:
|
||||
DatabaseObject.__init__(self, id_=id_)
|
||||
SongAttribute.__init__(self)
|
||||
self.text = text
|
||||
@@ -134,7 +133,7 @@ class Song(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
self.album_name: str | None = album_name
|
||||
self.tracksort: int | None = tracksort
|
||||
self.genre: str = genre
|
||||
|
||||
|
||||
if source_list:
|
||||
self.source_list = source_list
|
||||
|
||||
@@ -196,15 +195,14 @@ class Song(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
return str(self.tracksort)
|
||||
|
||||
return f"{self.tracksort}/{len(self.album.tracklist)}"
|
||||
|
||||
|
||||
def get_metadata(self) -> MetadataAttribute.Metadata:
|
||||
metadata = MetadataAttribute.Metadata({
|
||||
ID3_MAPPING.TITLE: [self.title],
|
||||
ID3_MAPPING.ISRC: [self.isrc],
|
||||
ID3_MAPPING.LENGTH: [str(self.length)],
|
||||
ID3_MAPPING.GENRE: [self.genre],
|
||||
ID3_MAPPING.TRACKNUMBER: [self.tracksort_str]
|
||||
id3Mapping.TITLE: [self.title],
|
||||
id3Mapping.ISRC: [self.isrc],
|
||||
id3Mapping.LENGTH: [str(self.length)],
|
||||
id3Mapping.GENRE: [self.genre],
|
||||
id3Mapping.TRACKNUMBER: [self.tracksort_str]
|
||||
})
|
||||
|
||||
metadata.merge_many([s.get_song_metadata() for s in self.source_list])
|
||||
@@ -216,15 +214,17 @@ class Song(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
return metadata
|
||||
|
||||
def set_album(self, album):
|
||||
if album is None:
|
||||
return
|
||||
|
||||
self._album = album
|
||||
if self not in self._album.tracklist:
|
||||
self._album.tracklist.append(self)
|
||||
|
||||
flat_copy = copy.copy(self)
|
||||
flat_copy.dynamic = True
|
||||
self._album.tracklist.append(flat_copy)
|
||||
|
||||
tracksort_str = property(fget=get_tracksort_str)
|
||||
album = property(fget=lambda self: self._album, fset=set_album)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
@@ -313,11 +313,11 @@ class Album(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
|
||||
def get_metadata(self) -> MetadataAttribute.Metadata:
|
||||
return MetadataAttribute.Metadata({
|
||||
ID3_MAPPING.ALBUM: [self.title],
|
||||
ID3_MAPPING.COPYRIGHT: [self.copyright],
|
||||
ID3_MAPPING.LANGUAGE: [self.iso_639_2_language],
|
||||
ID3_MAPPING.ALBUM_ARTIST: [a.name for a in self.artists],
|
||||
ID3_MAPPING.DATE: [self.date.timestamp]
|
||||
id3Mapping.ALBUM: [self.title],
|
||||
id3Mapping.COPYRIGHT: [self.copyright],
|
||||
id3Mapping.LANGUAGE: [self.iso_639_2_language],
|
||||
id3Mapping.ALBUM_ARTIST: [a.name for a in self.artists],
|
||||
id3Mapping.DATE: [self.date.timestamp]
|
||||
})
|
||||
|
||||
def get_copyright(self) -> str:
|
||||
@@ -337,7 +337,6 @@ class Album(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
tracklist = property(fget=lambda self: self._tracklist, fset=set_tracklist)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
All objects dependent on Artist
|
||||
"""
|
||||
@@ -391,7 +390,6 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
def get_features(self) -> Album:
|
||||
feature_release = Album(
|
||||
title="features",
|
||||
copyright_=self.name,
|
||||
album_status="dynamic",
|
||||
is_split=True,
|
||||
albumsort=666,
|
||||
@@ -405,7 +403,6 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
def get_songs(self) -> Album:
|
||||
song_release = Album(
|
||||
title="song collection",
|
||||
copyright_=self.name,
|
||||
album_status="dynamic",
|
||||
is_split=False,
|
||||
albumsort=666,
|
||||
@@ -429,13 +426,12 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
|
||||
:return:
|
||||
"""
|
||||
metadata = MetadataAttribute.Metadata({
|
||||
ID3_MAPPING.ARTIST: [self.name]
|
||||
id3Mapping.ARTIST: [self.name]
|
||||
})
|
||||
metadata.merge_many([s.get_artist_metadata() for s in self.source_list])
|
||||
|
||||
return metadata
|
||||
|
||||
|
||||
discography: List[Album] = property(fget=get_discography)
|
||||
features: Album = property(fget=get_features)
|
||||
songs: Album = property(fget=get_songs)
|
||||
|
@@ -5,7 +5,6 @@ from .metadata import Mapping, MetadataAttribute
|
||||
from .parents import (
|
||||
DatabaseObject,
|
||||
SongAttribute,
|
||||
ID3Metadata
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user