From 4daa0cbbfea7f5bfa60840d0b047639cfd98cb6a Mon Sep 17 00:00:00 2001 From: david Date: Sat, 13 Feb 2021 00:17:41 -0600 Subject: [PATCH] actually fix the slowness of the YTMusic API --- music.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/music.py b/music.py index 76bcf08..cc44a4c 100755 --- a/music.py +++ b/music.py @@ -64,8 +64,8 @@ def inlinequery(update, context: CallbackContext): sp_link = util.get(sp_info, f"/tracks/items/[{i}]/external_urls/spotify") songlink = "https://song.link/{0}".format(sp_link) yt_q = f"{sp_artist} - {sp_title}" - yt_res = ytmusic.search(yt_q, 'songs', limit=1) - if yt_res == 0: + if yt_q == 0: + yt_res = ytmusic.search(yt_q, 'songs', limit=1) yt_id = util.get(yt_res, f"[1]/videoId") yt_link = f"https://music.youtube.com/watch?v={yt_id}" reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("YouTube", url = yt_link), InlineKeyboardButton("Spotify", url = sp_link), InlineKeyboardButton("More", url = songlink)]])