From 8715dd5de7f92e8aca410ee6ec52c285af542c81 Mon Sep 17 00:00:00 2001 From: David Daily Date: Wed, 5 Apr 2023 13:35:27 -0500 Subject: [PATCH] tear out the youtube stuff --- music.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/music.py b/music.py index 66d114f..5ca5ae7 100644 --- a/music.py +++ b/music.py @@ -22,8 +22,6 @@ import requests import time import os from pathlib import Path -from ytmusicapi import YTMusic -ytmusic = YTMusic() logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', @@ -56,9 +54,7 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No results = [] - async with asyncio.TaskGroup() as tg: - sp_info = sp_search(query) - yt_res = yt_search(query) + sp_info = sp_search(query) for i in range(len(sp_info)): """Spotify""" @@ -70,11 +66,7 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No sp_audio = util.get(sp_info, f"/tracks/items/[{i}]/preview_url") sp_link = util.get(sp_info, f"/tracks/items/[{i}]/external_urls/spotify") songlink = "https://song.link/{0}".format(sp_link) - """YouTube""" - 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)]]) - + reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("Spotify", url = sp_link), InlineKeyboardButton("More", url = songlink)]]) description = f"By {sp_artist} on the album {sp_albname}, released {sp_albdate}" if "None" in str(sp_audio): @@ -91,10 +83,6 @@ async def sp_search(query): return sp.search(q=query, limit=num_results) -async def yt_search(query): - return ytmusic.search(query, 'songs', limit=1) - - async def error_handler(update) -> None: """Log the error and send a telegram message to notify the developer.""" # Log the error before we do anything else, so we can see it even if something breaks.