Download plugins/metadata.py from Thaimozhi/RenameBot: direct link, hf CLI and curl.
- Browser
- Download file 6.8 kB
-
https://huggingface.co/spaces/Thaimozhi/RenameBot/resolve/main/plugins/metadata.py
- Command line
-
hf download hf://spaces/Thaimozhi/RenameBot/plugins/metadata.py
-
curl -L -o metadata.py https://huggingface.co/spaces/Thaimozhi/RenameBot/resolve/main/plugins/metadata.py
6.8 kB
| from helper.database import codeflixbots as db | |
| from pyrogram import Client, filters | |
| from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery | |
| from config import Txt | |
| async def metadata(client, message): | |
| user_id = message.from_user.id | |
| # Fetch user metadata from the database | |
| current = await db.get_metadata(user_id) | |
| title = await db.get_title(user_id) | |
| author = await db.get_author(user_id) | |
| artist = await db.get_artist(user_id) | |
| video = await db.get_video(user_id) | |
| audio = await db.get_audio(user_id) | |
| subtitle = await db.get_subtitle(user_id) | |
| # Display the current metadata | |
| text = f""" | |
| **㊋ Yᴏᴜʀ Mᴇᴛᴀᴅᴀᴛᴀ ɪꜱ ᴄᴜʀʀᴇɴᴛʟʏ: {current}** | |
| **◈ Tɪᴛʟᴇ ▹** `{title if title else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Aᴜᴛʜᴏʀ ▹** `{author if author else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Aʀᴛɪꜱᴛ ▹** `{artist if artist else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Aᴜᴅɪᴏ ▹** `{audio if audio else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Sᴜʙᴛɪᴛʟᴇ ▹** `{subtitle if subtitle else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Vɪᴅᴇᴏ ▹** `{video if video else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| """ | |
| # Inline buttons to toggle metadata | |
| buttons = [ | |
| [ | |
| InlineKeyboardButton(f"On{' ✅' if current == 'On' else ''}", callback_data='on_metadata'), | |
| InlineKeyboardButton(f"Off{' ✅' if current == 'Off' else ''}", callback_data='off_metadata') | |
| ], | |
| [ | |
| InlineKeyboardButton("How to Set Metadata", callback_data="metainfo") | |
| ] | |
| ] | |
| keyboard = InlineKeyboardMarkup(buttons) | |
| await message.reply_text(text=text, reply_markup=keyboard, disable_web_page_preview=True) | |
| async def metadata_callback(client, query: CallbackQuery): | |
| user_id = query.from_user.id | |
| data = query.data | |
| if data == "on_metadata": | |
| await db.set_metadata(user_id, "On") | |
| elif data == "off_metadata": | |
| await db.set_metadata(user_id, "Off") | |
| elif data == "metainfo": | |
| await query.message.edit_text( | |
| text=Txt.META_TXT, | |
| disable_web_page_preview=True, | |
| reply_markup=InlineKeyboardMarkup([ | |
| [ | |
| InlineKeyboardButton("Hᴏᴍᴇ", callback_data="home"), | |
| InlineKeyboardButton("close", callback_data="close") | |
| ] | |
| ]) | |
| ) | |
| return | |
| # Fetch updated metadata after toggling | |
| current = await db.get_metadata(user_id) | |
| title = await db.get_title(user_id) | |
| author = await db.get_author(user_id) | |
| artist = await db.get_artist(user_id) | |
| video = await db.get_video(user_id) | |
| audio = await db.get_audio(user_id) | |
| subtitle = await db.get_subtitle(user_id) | |
| # Updated metadata message after toggle | |
| text = f""" | |
| **㊋ Yᴏᴜʀ Mᴇᴛᴀᴅᴀᴛᴀ ɪꜱ ᴄᴜʀʀᴇɴᴛʟʏ: {current}** | |
| **◈ Tɪᴛʟᴇ ▹** `{title if title else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Aᴜᴛʜᴏʀ ▹** `{author if author else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Aʀᴛɪꜱᴛ ▹** `{artist if artist else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Aᴜᴅɪᴏ ▹** `{audio if audio else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Sᴜʙᴛɪᴛʟᴇ ▹** `{subtitle if subtitle else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| **◈ Vɪᴅᴇᴏ ▹** `{video if video else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}` | |
| """ | |
| # Update inline buttons | |
| buttons = [ | |
| [ | |
| InlineKeyboardButton(f"On{' ✅' if current == 'On' else ''}", callback_data='on_metadata'), | |
| InlineKeyboardButton(f"Off{' ✅' if current == 'Off' else ''}", callback_data='off_metadata') | |
| ], | |
| [ | |
| InlineKeyboardButton("How to Set Metadata", callback_data="metainfo") | |
| ] | |
| ] | |
| await query.message.edit_text(text=text, reply_markup=InlineKeyboardMarkup(buttons), disable_web_page_preview=True) | |
| async def title(client, message): | |
| if len(message.command) == 1: | |
| return await message.reply_text( | |
| "**Gɪᴠᴇ Tʜᴇ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /settitle Encoded By @Animes_Cruise**") | |
| title = message.text.split(" ", 1)[1] | |
| await db.set_title(message.from_user.id, title=title) | |
| await message.reply_text("**✅ Tɪᴛʟᴇ Sᴀᴠᴇᴅ**") | |
| async def author(client, message): | |
| if len(message.command) == 1: | |
| return await message.reply_text( | |
| "**Gɪᴠᴇ Tʜᴇ Aᴜᴛʜᴏʀ\n\nExᴀᴍᴩʟᴇ:- /setauthor @Animes_Cruise**") | |
| author = message.text.split(" ", 1)[1] | |
| await db.set_author(message.from_user.id, author=author) | |
| await message.reply_text("**✅ Aᴜᴛʜᴏʀ Sᴀᴠᴇᴅ**") | |
| async def artist(client, message): | |
| if len(message.command) == 1: | |
| return await message.reply_text( | |
| "**Gɪᴠᴇ Tʜᴇ Aʀᴛɪꜱᴛ\n\nExᴀᴍᴩʟᴇ:- /setartist @Animes_Cruise**") | |
| artist = message.text.split(" ", 1)[1] | |
| await db.set_artist(message.from_user.id, artist=artist) | |
| await message.reply_text("**✅ Aʀᴛɪꜱᴛ Sᴀᴠᴇᴅ**") | |
| async def audio(client, message): | |
| if len(message.command) == 1: | |
| return await message.reply_text( | |
| "**Gɪᴠᴇ Tʜᴇ Aᴜᴅɪᴏ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /setaudio @Animes_Cruise**") | |
| audio = message.text.split(" ", 1)[1] | |
| await db.set_audio(message.from_user.id, audio=audio) | |
| await message.reply_text("**✅ Aᴜᴅɪᴏ Sᴀᴠᴇᴅ**") | |
| async def subtitle(client, message): | |
| if len(message.command) == 1: | |
| return await message.reply_text( | |
| "**Gɪᴠᴇ Tʜᴇ Sᴜʙᴛɪᴛʟᴇ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /setsubtitle @Animes_Cruise**") | |
| subtitle = message.text.split(" ", 1)[1] | |
| await db.set_subtitle(message.from_user.id, subtitle=subtitle) | |
| await message.reply_text("**✅ Sᴜʙᴛɪᴛʟᴇ Sᴀᴠᴇᴅ**") | |
| async def video(client, message): | |
| if len(message.command) == 1: | |
| return await message.reply_text( | |
| "**Gɪᴠᴇ Tʜᴇ Vɪᴅᴇᴏ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /setvideo Encoded by @Animes_Cruise**") | |
| video = message.text.split(" ", 1)[1] | |
| await db.set_video(message.from_user.id, video=video) | |
| await message.reply_text("**✅ Vɪᴅᴇᴏ Sᴀᴠᴇᴅ**") | |