async def song(client, message): chat_id = message.chat.id user_id = message.from_user["id"] add_chat_to_db(str(chat_id)) args = get_arg(message) + " " + "song" if args.startswith(" "): await message.reply("Enter a song name. Check /help") return "" status = await message.reply( "🔎Searching song from YouTube 📺.. Please wait some time ⏳️") video_link = yt_search(args) if not video_link: await status.edit("😔Song not found.") return "" yt = YouTube(video_link) audio = yt.streams.filter(only_audio=True).first() try: download = audio.download(filename=f"{str(user_id)}") except Exception as ex: await status.edit("Failed to download song") LOGGER.error(ex) return "" rename = os.rename(download, f"{str(user_id)}.mp3") await app.send_chat_action(message.chat.id, "upload_audio") await app.send_audio( chat_id=message.chat.id, audio=f"{str(user_id)}.mp3", duration=int(yt.length), title=str(yt.title), performer=str(yt.author), reply_to_message_id=message.message_id, ) await status.delete() os.remove(f"{str(user_id)}.mp3")
async def song(client, message): chat_id = message.chat.id user_id = message.from_user["id"] add_chat_to_db(str(chat_id)) args = get_arg(message) + " " + "song" if args.startswith(" "): await message.reply("Masukin nama lagunya bodoh :( , check /help") return "" status = await message.reply("🔎 Mencari... Silahkan tunggu sebentar :)") video_link = yt_search(args) if not video_link: await status.edit("😔Maaf Music tidak di Temukan...") return "" yt = YouTube(video_link) audio = yt.streams.filter(only_audio=True).first() try: download = audio.download(filename=f"{str(user_id)}") except Exception as ex: await status.edit("Failed to download song") LOGGER.error(ex) return "" rename = os.rename(download, f"{str(user_id)}.mp3") await app.send_chat_action(message.chat.id, "upload_audio") await app.send_audio( chat_id=message.chat.id, audio=f"{str(user_id)}.mp3", duration=int(yt.length), title=str(yt.title), performer=str(yt.author), reply_to_message_id=message.message_id, ) await status.delete() os.remove(f"{str(user_id)}.mp3")
async def song(client, message): chat_id = message.chat.id user_id = message.from_user["id"] add_chat_to_db(str(chat_id)) args = get_arg(message) + " " + "song" if args.startswith(" "): await message.reply( "berikan saya judul lagu untuk diunduh. ketik /help") return "" status = await message.reply( "🔎mencari lagu yang anda minta.../n⏳silahkan tunggu beberapa saat") video_link = yt_search(args) if not video_link: await status.edit("😔 lagu tidak di temukan.") return "" yt = YouTube(video_link) audio = yt.streams.filter(only_audio=True).first() try: download = audio.download(filename=f"{str(user_id)}") except Exception as ex: await status.edit("❌ gagal mendownload lagu") LOGGER.error(ex) return "" rename = os.rename(download, f"{str(user_id)}.mp3") await app.send_chat_action(message.chat.id, "upload_audio") await app.send_audio( chat_id=message.chat.id, audio=f"{str(user_id)}.mp3", duration=int(yt.length), title=str(yt.title), performer=str(yt.author), reply_to_message_id=message.message_id, ) await status.delete() os.remove(f"{str(user_id)}.mp3")
async def song(client, message): chat_id = message.chat.id user_id = message.from_user["id"] add_chat_to_db(str(chat_id)) args = get_arg(message) + " " + "msc" if args.startswith(" "): await message.reply("Digite o nome de uma música.") return "" status = await message.reply("🔎Procurando música.. Por favor, aguarde um pouco.") video_link = yt_search(args) if not video_link: await status.edit("😔 Música não encontrada.") return "" yt = YouTube(video_link) audio = yt.streams.filter(only_audio=True).first() try: download = audio.download(filename=f"{str(user_id)}") except Exception as ex: await status.edit("Falha ao baixar música.") LOGGER.error(ex) return "" rename = os.rename(download, f"{str(user_id)}.mp3") await app.send_chat_action(message.chat.id, "upload_audio") await app.send_audio( chat_id=message.chat.id, audio=f"{str(user_id)}.mp3", duration=int(yt.length), title=str(yt.title), performer=str(yt.author), reply_to_message_id=message.message_id, ) await status.delete() os.remove(f"{str(user_id)}.mp3")