implemented
DatabaseObject.indexing_values for each data objects
This commit is contained in:
parent
0ffb642ac7
commit
b53548e321
@ -43,6 +43,9 @@ class Song(MainObject, SourceAttribute, MetadataAttribute):
|
|||||||
Inherits from DatabaseObject, SourceAttribute, and MetadataAttribute classes.
|
Inherits from DatabaseObject, SourceAttribute, and MetadataAttribute classes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
COLLECTION_ATTRIBUTES = ("lyrics_collection", "album_collection", "main_artist_collection", "feature_artist_collection", "source_collection")
|
||||||
|
SIMPLE_ATTRIBUTES = ("title", "unified_title", "isrc", "length", "tracksort", "genre")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
_id: str = None,
|
_id: str = None,
|
||||||
@ -74,19 +77,18 @@ class Song(MainObject, SourceAttribute, MetadataAttribute):
|
|||||||
self.tracksort: int = tracksort or 0
|
self.tracksort: int = tracksort or 0
|
||||||
self.genre: str = genre
|
self.genre: str = genre
|
||||||
|
|
||||||
self.source_list = source_list or []
|
self.target_collection: Collection = Collection(
|
||||||
|
data=target_list,
|
||||||
self.target_list = target_list or []
|
element_type=Target
|
||||||
|
)
|
||||||
|
|
||||||
self.lyrics_collection: Collection = Collection(
|
self.lyrics_collection: Collection = Collection(
|
||||||
data=lyrics_list or [],
|
data=lyrics_list,
|
||||||
map_attributes=[],
|
|
||||||
element_type=Lyrics
|
element_type=Lyrics
|
||||||
)
|
)
|
||||||
|
|
||||||
self.album_collection: Collection = Collection(
|
self.album_collection: Collection = Collection(
|
||||||
data=album_list or [],
|
data=album_list,
|
||||||
map_attributes=["title"],
|
|
||||||
element_type=Album
|
element_type=Album
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -180,9 +182,6 @@ class Song(MainObject, SourceAttribute, MetadataAttribute):
|
|||||||
album_list: List[Type['Album']] = property(fget=lambda self: self.album_collection.copy())
|
album_list: List[Type['Album']] = property(fget=lambda self: self.album_collection.copy())
|
||||||
lyrics_list: List[Type[Lyrics]] = property(fget=lambda self: self.lyrics_collection.copy())
|
lyrics_list: List[Type[Lyrics]] = property(fget=lambda self: self.lyrics_collection.copy())
|
||||||
|
|
||||||
COLLECTION_ATTRIBUTES = ("lyrics_collection", "album_collection", "main_artist_collection", "feature_artist_collection")
|
|
||||||
SIMPLE_ATTRIBUTES = ("title", "isrc", "length", "tracksort", "genre")
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
All objects dependent on Album
|
All objects dependent on Album
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Optional
|
from typing import Optional, List, Tuple
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ..utils import shared
|
from ..utils import shared
|
||||||
@ -14,6 +14,8 @@ class Target(DatabaseObject):
|
|||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
SIMPLE_ATTRIBUTES = ("_file", "_path")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
file: str = None,
|
file: str = None,
|
||||||
@ -24,12 +26,14 @@ class Target(DatabaseObject):
|
|||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(_id=_id, dynamic=dynamic)
|
super().__init__(_id=_id, dynamic=dynamic)
|
||||||
self._file: Path = Path(file)
|
self._file: Path = Path(file)
|
||||||
self._path = path
|
self._path: Path = Path(path) if relative_to_music_dir else Path(path)
|
||||||
|
|
||||||
self.is_relative_to_music_dir: bool = relative_to_music_dir
|
self.is_relative_to_music_dir: bool = relative_to_music_dir
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def file_path(self) -> Path:
|
def file_path(self) -> Path:
|
||||||
if self.is_relative_to_music_dir:
|
|
||||||
return Path(shared.MUSIC_DIR, self._path, self._file)
|
|
||||||
return Path(self._path, self._file)
|
return Path(self._path, self._file)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def indexing_values(self) -> List[Tuple[str, object]]:
|
||||||
|
return [('filepath', self.file_path)]
|
||||||
|
Loading…
Reference in New Issue
Block a user