Add song_fetch error checking
This commit is contained in:
parent
0066166765
commit
f70d2e707c
2 changed files with 20 additions and 3 deletions
|
@ -51,7 +51,23 @@ def _lastfm_getinfo(name: str, artist: str) -> tuple[str, list[str]]: # ( image
|
|||
)
|
||||
|
||||
|
||||
def lastfm_query_search(query: str) -> SongInfo:
|
||||
def _yt_search(query: str) -> tuple[str, str]:
|
||||
ydl_opts = {
|
||||
"format": "bestaudio",
|
||||
"default_search": "ytsearch1",
|
||||
"outtmpl": "%(title)s.%(ext)s",
|
||||
"skip_download": True,
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(query, download=False)
|
||||
|
||||
first = info["entries"][0]
|
||||
|
||||
return first["track"], first["artists"][0]
|
||||
|
||||
|
||||
def query_search(query: str) -> SongInfo | None:
|
||||
name, artist = _lastfm_search(query)
|
||||
|
||||
img_id, tags = _lastfm_getinfo(name, artist)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue