From baeb7df658bb89bf75a69602c4f437f30f3dbdb2 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sat, 9 Oct 2021 22:35:20 +0700 Subject: [PATCH] some fixes --- bot/ytsearch.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/bot/ytsearch.py b/bot/ytsearch.py index bf2277c..bc11124 100644 --- a/bot/ytsearch.py +++ b/bot/ytsearch.py @@ -1,29 +1,35 @@ -# Copyright (C) 2021 By VeezMusicProject - - -from pyrogram import Client as app +import logging +from pyrogram import Client +from config import BOT_USERNAME from pyrogram.types import Message -from youtube_search import YoutubeSearch -from config import Veez from helpers.filters import command +from youtube_search import YoutubeSearch -@app.on_message(command(["search", f"search@{Veez.BOT_USERNAME}"])) + +logging.basicConfig( + level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" +) +logger = logging.getLogger(__name__) +logging.getLogger("pyrogram").setLevel(logging.WARNING) + + +@Client.on_message(command(["search", f"search@{BOT_USERNAME}"])) async def ytsearch(_, message: Message): - m = await message.reply_text("🔎 **searching url...**") try: if len(message.command) < 2: - await message.reply_text("`/search` needs an argument!") + await message.reply_text("/search **needs an argument !**") return query = message.text.split(None, 1)[1] + m = await message.reply_text("🔎 **Searching...**") results = YoutubeSearch(query, max_results=5).to_dict() i = 0 text = "" while i < 5: - text += f"**Name:** `{results[i]['title']}`\n" - text += f"**Duration:** {results[i]['duration']}\n" - text += f"**Views:** {results[i]['views']}\n" - text += f"**Channel:** {results[i]['channel']}\n" - text += f"https://www.youtube.com{results[i]['url_suffix']}\n\n" + text += f"🏷 **Name:** __{results[i]['title']}__\n" + text += f"⏱ **Duration:** `{results[i]['duration']}`\n" + text += f"👀 **Views:** `{results[i]['views']}`\n" + text += f"📣 **Channel:** {results[i]['channel']}\n" + text += f"🔗: https://www.youtube.com{results[i]['url_suffix']}\n\n" i += 1 await m.edit(text, disable_web_page_preview=True) except Exception as e: