mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 04:05:08 +03:00
✨ add search on Tidal
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import click
|
||||
|
||||
from tiddl.utils import TidalResource
|
||||
from tiddl.models.resource import Artist, Album, Playlist, Track, Video
|
||||
|
||||
from ..ctx import Context, passContext
|
||||
|
||||
|
||||
@@ -9,4 +12,33 @@ from ..ctx import Context, passContext
|
||||
def SearchGroup(ctx: Context, query: str):
|
||||
"""Search on Tidal"""
|
||||
|
||||
# TODO: search on Tidal
|
||||
# TODO: give user interactive choice what to select
|
||||
|
||||
api = ctx.obj.getApi()
|
||||
|
||||
search = api.getSearch(query)
|
||||
|
||||
# issue is that we get resource data in search api call,
|
||||
# in download we refetch that data.
|
||||
# it's not that big deal as we refetch one resource at most,
|
||||
# but it should be redesigned
|
||||
|
||||
value = search.topHit.value
|
||||
icon = click.style("\u2bcc", "magenta")
|
||||
|
||||
if isinstance(value, Album):
|
||||
resource = TidalResource(type="album", id=str(value.id))
|
||||
click.echo(f"{icon} Album {value.title}")
|
||||
elif isinstance(value, Artist):
|
||||
resource = TidalResource(type="artist", id=str(value.id))
|
||||
click.echo(f"{icon} Artist {value.name}")
|
||||
elif isinstance(value, Track):
|
||||
resource = TidalResource(type="track", id=str(value.id))
|
||||
click.echo(f"{icon} Track {value.title}")
|
||||
elif isinstance(value, Playlist):
|
||||
resource = TidalResource(type="playlist", id=str(value.uuid))
|
||||
click.echo(f"{icon} Playlist {value.title}")
|
||||
elif isinstance(value, Video):
|
||||
click.echo(f"{icon} Video {value.title} (currently not supported)")
|
||||
|
||||
ctx.obj.resources.append(resource)
|
||||
|
||||
Reference in New Issue
Block a user