tear out the youtube stuff

This commit is contained in:
David Daily 2023-04-05 13:35:27 -05:00
parent d39d370794
commit 8715dd5de7

View File

@ -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.