tear out the youtube stuff
This commit is contained in:
parent
d39d370794
commit
8715dd5de7
16
music.py
16
music.py
@ -22,8 +22,6 @@ import requests
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ytmusicapi import YTMusic
|
|
||||||
ytmusic = YTMusic()
|
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
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 = []
|
results = []
|
||||||
|
|
||||||
async with asyncio.TaskGroup() as tg:
|
sp_info = sp_search(query)
|
||||||
sp_info = sp_search(query)
|
|
||||||
yt_res = yt_search(query)
|
|
||||||
|
|
||||||
for i in range(len(sp_info)):
|
for i in range(len(sp_info)):
|
||||||
"""Spotify"""
|
"""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_audio = util.get(sp_info, f"/tracks/items/[{i}]/preview_url")
|
||||||
sp_link = util.get(sp_info, f"/tracks/items/[{i}]/external_urls/spotify")
|
sp_link = util.get(sp_info, f"/tracks/items/[{i}]/external_urls/spotify")
|
||||||
songlink = "https://song.link/{0}".format(sp_link)
|
songlink = "https://song.link/{0}".format(sp_link)
|
||||||
"""YouTube"""
|
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("Spotify", url = sp_link), InlineKeyboardButton("More", url = songlink)]])
|
||||||
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)]])
|
|
||||||
|
|
||||||
description = f"By {sp_artist} on the album {sp_albname}, released {sp_albdate}"
|
description = f"By {sp_artist} on the album {sp_albname}, released {sp_albdate}"
|
||||||
|
|
||||||
if "None" in str(sp_audio):
|
if "None" in str(sp_audio):
|
||||||
@ -91,10 +83,6 @@ async def sp_search(query):
|
|||||||
return sp.search(q=query, limit=num_results)
|
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:
|
async def error_handler(update) -> None:
|
||||||
"""Log the error and send a telegram message to notify the developer."""
|
"""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.
|
# Log the error before we do anything else, so we can see it even if something breaks.
|
||||||
|
Loading…
Reference in New Issue
Block a user