mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-05 03:34:51 +00:00
Trying fix ocr and conversrt
This commit is contained in:
parent
4a72e140f2
commit
375be9672c
2 changed files with 47 additions and 45 deletions
|
|
@ -119,8 +119,7 @@ async def ceksub(self: Client, ctx: Message, strings):
|
|||
@use_chat_lang()
|
||||
async def convertsrt(self: Client, ctx: Message, strings):
|
||||
reply = ctx.reply_to_message
|
||||
if not reply or not reply.document and not (reply.document.file_name.endswith(".vtt") or reply.document.file_name.endswith(".ass")):
|
||||
return await ctx.reply_msg(strings("conv_sub_help").format(cmd=ctx.command[0]), del_in=5)
|
||||
if replied and replied.document and (replied.document.file_name and replied.document.file_name.endswith(".vtt") or replied.document.file_name.endswith(".ass")):
|
||||
msg = await ctx.reply_msg(strings("convert_str"), quote=True)
|
||||
if not os.path.exists("downloads"):
|
||||
os.makedirs("downloads")
|
||||
|
|
@ -142,6 +141,8 @@ async def convertsrt(self: Client, ctx: Message, strings):
|
|||
os.remove(f"downloads/{filename}.srt")
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
return await ctx.reply_msg(strings("conv_sub_help").format(cmd=ctx.command[0]), del_in=6)
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex(r"^streamextract#"))
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ __HELP__ = "/ocr [reply to photo] - Read Text From Image"
|
|||
@use_chat_lang()
|
||||
async def ocr(self: Client, ctx: Message, strings):
|
||||
reply = ctx.reply_to_message
|
||||
if not reply or not (reply.document and reply.document.mime_type.startswith("image")) or not reply.sticker:
|
||||
return await ctx.reply_msg(strings("no_photo").format(cmd=ctx.command[0]), quote=True, del_in=6)
|
||||
if reply and (reply.sticker or reply.photo or reply.document and reply.document.mime_type.startswith("image")):
|
||||
msg = await ctx.reply_msg(strings("read_ocr"), quote=True)
|
||||
try:
|
||||
file_path = await reply.download()
|
||||
|
|
@ -52,3 +51,5 @@ async def ocr(self: Client, ctx: Message, strings):
|
|||
await msg.edit_msg(str(e))
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
else:
|
||||
return await ctx.reply_msg(strings("no_photo").format(cmd=ctx.command[0]), quote=True)
|
||||
Loading…
Reference in a new issue