This commit is contained in:
Hellow2 2023-03-13 14:39:46 +01:00
parent 292bdfd2fa
commit e445e7b5d1
4 changed files with 21 additions and 11 deletions

View File

@ -5,9 +5,14 @@ from music_kraken.pages import (
EncyclopaediaMetallum
)
"""
results = EncyclopaediaMetallum.search_by_query("#a Only Smile")
artist = results[0]
artist: objects.Artist = EncyclopaediaMetallum.fetch_details(artist)
print(artist.options)
print()
"""
if __name__ == "__main__":
pass

View File

@ -4,7 +4,8 @@ from . import (
source,
parents,
formatted_text,
album
album,
option
)
MusicObject = parents.DatabaseObject
@ -28,3 +29,5 @@ AlbumStatus = album.AlbumStatus
Album = song.Album
FormattedText = formatted_text.FormattedText
Options = option.Options

View File

@ -9,7 +9,8 @@ from ..objects import (
Artist,
Lyrics,
Target,
MusicObject
MusicObject,
Options
)
@ -69,7 +70,7 @@ class Page:
song_str = property(fget=lambda self: self.get_str(self.song))
@classmethod
def search_by_query(cls, query: str) -> List[MusicObject]:
def search_by_query(cls, query: str) -> Options:
"""
# The Query
You can define a new parameter with "#",
@ -84,7 +85,7 @@ class Page:
:return possible_music_objects:
"""
return []
return Options()
@classmethod
def fetch_details(cls, music_object: MusicObject, flat: bool = False) -> MusicObject:

View File

@ -17,7 +17,8 @@ from ..objects import (
Album,
ID3Timestamp,
FormattedText,
Label
Label,
Options
)
from ..utils import (
string_processing
@ -34,7 +35,7 @@ class EncyclopaediaMetallum(Page):
SOURCE_TYPE = SourcePages.ENCYCLOPAEDIA_METALLUM
@classmethod
def search_by_query(cls, query: str) -> List[MusicObject]:
def search_by_query(cls, query: str) -> Options:
query_obj = cls.Query(query)
if query_obj.is_raw:
@ -42,14 +43,14 @@ class EncyclopaediaMetallum(Page):
return cls.advanced_search(query_obj)
@classmethod
def advanced_search(cls, query: Page.Query) -> List[MusicObject]:
def advanced_search(cls, query: Page.Query) -> Options:
if query.song is not None:
return cls.search_for_song(query=query)
return Options(cls.search_for_song(query=query))
if query.album is not None:
return cls.search_for_album(query=query)
return Options(cls.search_for_album(query=query))
if query.artist is not None:
return cls.search_for_artist(query=query)
return []
return Options(cls.search_for_artist(query=query))
return Options
@classmethod
def search_for_song(cls, query: Page.Query) -> List[Song]: