diff --git a/misskaty/plugins/ytdl_download_new.py b/misskaty/plugins/ytdl_download_new.py
index b0164117..2bf51c8e 100644
--- a/misskaty/plugins/ytdl_download_new.py
+++ b/misskaty/plugins/ytdl_download_new.py
@@ -56,7 +56,7 @@ async def ytsearch(_, message):
img = await get_ytthumb(i["id"])
caption = out
markup = btn
- await message.reply_photo(img, caption=caption, reply_markup=markup)
+ await message.reply_photo(img, caption=caption, reply_markup=markup, quote=True)
@app.on_message(filters.command(["ytdown2"], COMMAND_HANDLER) & ~filters.channel)
@@ -72,7 +72,74 @@ async def ytdownv2(_, message):
img = await get_ytthumb(x.key)
caption = x.caption
markup = x.buttons
- await message.reply_photo(img, caption=caption, reply_markup=markup)
+ await message.reply_photo(img, caption=caption, reply_markup=markup, quote=True)
+
+
+@app.on_callback_query(filters.regex(r"yt_(gen|dl)\|(.*)"))
+async def ytdl_gendl_callback(_, cq: CallbackQuery):
+ if cq.from_user.id != cq.message.reply_to_message.from_user.id:
+ return await cq.answer("Not your task", True)
+ callback = cq.data.split("|")
+ key = callback[1]
+ if callback[0] == "yt_gen":
+ x = await main.Extractor().get_download_button(key)
+ await cq.edit_message_caption(caption=x.caption, reply_markup=x.buttons)
+ else:
+ uid = callback[2]
+ type_ = callback[3]
+ if type_ == "a":
+ format_ = "audio"
+ else:
+ format_ = "video"
+ async with iYTDL(
+ log_group_id=LOG_CHANNEL,
+ cache_path="cache",
+ ffmpeg_location="/usr/bin/mediaextract",
+ delete_media=True,
+ ) as ytdl:
+ upload_key = await ytdl.download(
+ cq.message.reply_to_message.command[1], uid, format_, cq, True, 3
+ )
+ await ytdl.upload(app, upload_key, format_, cq, True)
+
+
+@app.on_callback_query(filters.regex(r"ytdl_scroll\|(.*)"))
+async def ytdl_scroll_callback(_, cq: CallbackQuery):
+ if cq.from_user.id != cq.message.reply_to_message.from_user.id:
+ return await cq.answer("Not your task", True)
+ callback = cq.data.split("|")
+ search_key = callback[1]
+ page = int(callback[2])
+ query = YT_DB[search_key]
+ search = await main.VideosSearch(query).next()
+ i = search["result"][page]
+ out = f"{i['title']}"
+ out += f"\nPublished {i['publishedTime']}\n"
+ out += f"\n❯ Duration: {i['duration']}"
+ out += f"\n❯ Views: {i['viewCount']['short']}"
+ out += f"\n❯ Uploader: {i['channel']['name']}\n\n"
+ scroll_btn = [
+ [
+ InlineKeyboardButton(
+ f"Back", callback_data=f"ytdl_scroll|{search_key}|{page-1}"
+ ),
+ InlineKeyboardButton(
+ f"{page+1}/{len(search['result'])}",
+ callback_data=f"ytdl_scroll|{search_key}|{page+1}",
+ ),
+ ]
+ ]
+ if page == 0:
+ if len(search["result"]) == 1:
+ return await cq.answer("That's the end of list", show_alert=True)
+ scroll_btn = [[scroll_btn.pop().pop()]]
+ elif page == (len(search["result"]) - 1):
+ scroll_btn = [[scroll_btn.pop().pop(0)]]
+ btn = [[InlineKeyboardButton("Download", callback_data=f"yt_gen|{i['id']}")]]
+ btn = InlineKeyboardMarkup(scroll_btn + btn)
+ await cq.edit_message_media(
+ InputMediaPhoto(await get_ytthumb(i["id"]), caption=out), reply_markup=btn
+ )
async def get_ytthumb(videoid: str):