query function
This commit is contained in:
parent
07e2ef3543
commit
08339bab68
@ -7,8 +7,8 @@ import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from ..connection import Connection
|
||||
from .support_classes.default_target import DefaultTarget
|
||||
from .support_classes.download_result import DownloadResult
|
||||
from ..utils.support_classes.default_target import DefaultTarget
|
||||
from ..utils.support_classes.download_result import DownloadResult
|
||||
from ..objects import (
|
||||
Song,
|
||||
Source,
|
||||
|
28
src/music_kraken/utils/support_classes/query.py
Normal file
28
src/music_kraken/utils/support_classes/query.py
Normal file
@ -0,0 +1,28 @@
|
||||
from typing import Optional, List
|
||||
|
||||
from ...objects import DatabaseObject, Artist, Album, Song
|
||||
|
||||
class Query:
|
||||
def __init__(
|
||||
self,
|
||||
raw_query: str = "",
|
||||
music_object: DatabaseObject = None
|
||||
) -> None:
|
||||
self.raw_query: str = raw_query
|
||||
self.music_object: Optional[DatabaseObject] = None
|
||||
|
||||
@property
|
||||
def default_search(self) -> List[str]:
|
||||
if self.music_object is None:
|
||||
return [self.raw_query]
|
||||
|
||||
if isinstance(self.music_object, Artist):
|
||||
return [self.music_object.name]
|
||||
|
||||
if isinstance(self.music_object, Song):
|
||||
return [f"{artist.name} - {self.music_object}" for artist in self.music_object.main_artist_collection]
|
||||
|
||||
if isinstance(self.music_object, Album):
|
||||
return [f"{artist.name} - {self.music_object}" for artist in self.music_object.artist_collection]
|
||||
|
||||
return [self.raw_query]
|
Loading…
Reference in New Issue
Block a user