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 EncyclopaediaMetallum
) )
"""
results = EncyclopaediaMetallum.search_by_query("#a Only Smile") results = EncyclopaediaMetallum.search_by_query("#a Only Smile")
artist = results[0] artist = results[0]
artist: objects.Artist = EncyclopaediaMetallum.fetch_details(artist) artist: objects.Artist = EncyclopaediaMetallum.fetch_details(artist)
print(artist.options) print(artist.options)
print() print()
"""
if __name__ == "__main__":
pass

View File

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

View File

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

View File

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