Fix: actually import YoutubeSearch and fix self-variable access

doesn't actually fix the issue where youtube is blocking requests behind a signin requirement but eh
This commit is contained in:
a 2024-10-21 21:40:57 +00:00
parent 81e4db9c4f
commit 9decd6552b

View file

@ -9,6 +9,7 @@ import random # for shuffling the queue
import math # for ceiling function in queue pages
from functools import partial
import logging
from youtube_search import YoutubeSearch
if not path.exists('.logs'):
makedirs('.logs')
@ -339,7 +340,7 @@ class Music(Cog):
logger.debug(f"search_youtube() called for query: {query}")
try:
self.query = query
self.search_results = YoutubeSearch(query, max_results=MAX_RESULTS).to_dict()
self.search_results = YoutubeSearch(query, max_results=self.MAX_RESULTS).to_dict() # this returns a list, funnily enough
except Exception as e:
logger.error("Exception thrown!")
logger.error(f"{e=}")
@ -366,12 +367,12 @@ class Music(Cog):
embeds = []
formatted_results = (
f"Performed a search for `{self.search_results['id']}`.\n"
f"Performed a search for `{self.query}`.\n"
"Which track would you like to play?\n"
"Make your choice using the `play` command, e.g. `.play 1`.\n\n"
)
for i, result in enumerate(self.search_results['entries']):
for i, result in enumerate(self.search_results):
result: dict