import yt_dlp from config import yt_dlp_opts # Function to search YouTube def search_youtube(query, opts = yt_dlp_opts): with yt_dlp.YoutubeDL(opts) as ydl: info = ydl.extract_info(query, download=False) return info['entries'] def download_audio(url, base_path, opts = yt_dlp_opts): opts['outtmpl'] = f'{base_path}/audios/%(title)s.%(ext)s' if not isinstance(url, list): url = [url] success = False try: with yt_dlp.YoutubeDL(opts) as ydl: ydl.download(url) success = True except: success = False return success