commit
e24105eeb3
@ -15,6 +15,7 @@ from git.exc import InvalidGitRepositoryError
|
|||||||
from config import UPSTREAM_REPO, BOT_USERNAME
|
from config import UPSTREAM_REPO, BOT_USERNAME
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def gen_chlog(repo, diff):
|
def gen_chlog(repo, diff):
|
||||||
upstream_repo_url = Repo().remotes[0].config_reader.get("url").replace(".git", "")
|
upstream_repo_url = Repo().remotes[0].config_reader.get("url").replace(".git", "")
|
||||||
ac_br = repo.active_branch.name
|
ac_br = repo.active_branch.name
|
||||||
@ -64,7 +65,7 @@ async def update_repo(_, message: Message):
|
|||||||
system("git pull -f && pip3 install --no-cache-dir -r requirements.txt")
|
system("git pull -f && pip3 install --no-cache-dir -r requirements.txt")
|
||||||
execle(sys.executable, sys.executable, "main.py", environ)
|
execle(sys.executable, sys.executable, "main.py", environ)
|
||||||
return
|
return
|
||||||
await msg.edit("bot is **up-to-date** with [main](https://github.com/levina-lab/video-stream/tree/main)", disable_web_page_preview=True)
|
await msg.edit(f"bot is **up-to-date** with [main]({UPSTREAM_REPO}/tree/main)", disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["restart", f"restart@{BOT_USERNAME}"]) & ~filters.edited)
|
@Client.on_message(command(["restart", f"restart@{BOT_USERNAME}"]) & ~filters.edited)
|
||||||
|
@ -1,50 +1,31 @@
|
|||||||
import logging
|
|
||||||
from config import BOT_USERNAME
|
from config import BOT_USERNAME
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.types import (
|
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
||||||
InlineKeyboardButton,
|
|
||||||
InlineKeyboardMarkup,
|
|
||||||
Message,
|
|
||||||
)
|
|
||||||
from youtube_search import YoutubeSearch
|
from youtube_search import YoutubeSearch
|
||||||
|
|
||||||
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}"]))
|
@Client.on_message(command(["search", f"search@{BOT_USERNAME}"]))
|
||||||
async def ytsearch(_, message: Message):
|
async def ytsearch(_, message: Message):
|
||||||
|
|
||||||
keyboard = InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
"🗑 Close", callback_data="cls",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
if len(message.command) < 2:
|
if len(message.command) < 2:
|
||||||
await message.reply_text("/search **needs an argument !**")
|
return await message.reply_text("/search **needs an argument !**")
|
||||||
return
|
|
||||||
query = message.text.split(None, 1)[1]
|
query = message.text.split(None, 1)[1]
|
||||||
m = await message.reply_text("🔎 **Searching...**")
|
m = await message.reply_text("🔎 **Searching...**")
|
||||||
results = YoutubeSearch(query, max_results=5).to_dict()
|
results = YoutubeSearch(query, max_results=5).to_dict()
|
||||||
i = 0
|
|
||||||
text = ""
|
text = ""
|
||||||
while i < 5:
|
for i in range(5):
|
||||||
|
try:
|
||||||
text += f"🏷 **Name:** __{results[i]['title']}__\n"
|
text += f"🏷 **Name:** __{results[i]['title']}__\n"
|
||||||
text += f"⏱ **Duration:** `{results[i]['duration']}`\n"
|
text += f"⏱ **Duration:** `{results[i]['duration']}`\n"
|
||||||
text += f"👀 **Views:** `{results[i]['views']}`\n"
|
text += f"👀 **Views:** `{results[i]['views']}`\n"
|
||||||
text += f"📣 **Channel:** {results[i]['channel']}\n"
|
text += f"📣 **Channel:** {results[i]['channel']}\n"
|
||||||
text += f"🔗: https://www.youtube.com{results[i]['url_suffix']}\n\n"
|
text += f"🔗: https://www.youtube.com{results[i]['url_suffix']}\n\n"
|
||||||
i += 1
|
except IndexError:
|
||||||
await m.edit(text, reply_markup=keyboard, disable_web_page_preview=True)
|
break
|
||||||
except Exception as e:
|
await m.edit_text(
|
||||||
await m.edit(str(e))
|
text,
|
||||||
|
disable_web_page_preview=True,
|
||||||
|
reply_markup=InlineKeyboardMarkup(
|
||||||
|
[[InlineKeyboardButton("🗑 Close", callback_data="cls")]]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user