Spaces:
Sleeping
Sleeping
File size: 4,304 Bytes
9aef05f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K | Modifieded By : @DC4_WARRIOR
# the logging things
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
import random
import numpy
import os
from PIL import Image
import time
from config import Config
# the Strings used for this "thing"
from translation import Translation
from pyrogram import Client as Clinton
from database.access import clinton
from hachoir.metadata import extractMetadata
from hachoir.parser import createParser
logging.getLogger("pyrogram").setLevel(logging.WARNING)
from pyrogram import filters
from database.adduser import AddUser
from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot
@Clinton.on_message(filters.private & filters.photo)
async def save_photo(bot, update):
await AddUser(bot, update)
await clinton.set_thumbnail(update.from_user.id, thumbnail=update.photo.file_id)
await bot.send_message(chat_id=update.chat.id, text=Translation.SAVED_CUSTOM_THUMB_NAIL, reply_to_message_id=update.message_id)
@Clinton.on_message(filters.private & filters.command("delthumbnail"))
async def delthumbnail(bot, update):
await AddUser(bot, update)
await clinton.set_thumbnail(update.from_user.id, thumbnail=None)
await bot.send_message(chat_id=update.chat.id, text=Translation.DEL_ETED_CUSTOM_THUMB_NAIL, reply_to_message_id=update.message_id)
@Clinton.on_message(filters.private & filters.command("viewthumbnail") )
async def viewthumbnail(bot, update):
await AddUser(bot, update)
thumbnail = await clinton.get_thumbnail(update.from_user.id)
if thumbnail is not None:
await bot.send_photo(
chat_id=update.chat.id,
photo=thumbnail,
caption=f"Your current saved thumbnail 🦠",
reply_to_message_id=update.message_id)
else:
await update.reply_text(text=f"No Thumbnail found 🤒")
async def Gthumb01(bot, update):
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
db_thumbnail = await clinton.get_thumbnail(update.from_user.id)
if db_thumbnail is not None:
thumbnail = await bot.download_media(message=db_thumbnail, file_name=thumb_image_path)
Image.open(thumbnail).convert("RGB").save(thumbnail)
img = Image.open(thumbnail)
img.resize((100, 100))
img.save(thumbnail, "JPEG")
else:
thumbnail = None
return thumbnail
async def Gthumb02(bot, update, duration, download_directory):
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
db_thumbnail = await clinton.get_thumbnail(update.from_user.id)
if db_thumbnail is not None:
thumbnail = await bot.download_media(message=db_thumbnail, file_name=thumb_image_path)
else:
thumbnail = await take_screen_shot(download_directory, os.path.dirname(download_directory), random.randint(0, duration - 1))
return thumbnail
async def Mdata01(download_directory):
width = 0
height = 0
duration = 0
metadata = extractMetadata(createParser(download_directory))
if metadata is not None:
if metadata.has("duration"):
duration = metadata.get('duration').seconds
if metadata.has("width"):
width = metadata.get("width")
if metadata.has("height"):
height = metadata.get("height")
return width, height, duration
async def Mdata02(download_directory):
width = 0
duration = 0
metadata = extractMetadata(createParser(download_directory))
if metadata is not None:
if metadata.has("duration"):
duration = metadata.get('duration').seconds
if metadata.has("width"):
width = metadata.get("width")
return width, duration
async def Mdata03(download_directory):
duration = 0
metadata = extractMetadata(createParser(download_directory))
if metadata is not None:
if metadata.has("duration"):
duration = metadata.get('duration').seconds
return duration
|