async def rclone_command_f(client, message): """/rclone command""" LOGGER.info( f"rclone command from chatid:{message.chat.id}, userid:{message.from_user.id}" ) if message.from_user.id == OWNER_ID and message.chat.type == "private": config.read("rclone_bak.conf") sections = list(config.sections()) inline_keyboard = [] for section in sections: ikeyboard = [ pyrogram.InlineKeyboardButton( section, callback_data=(f"rclone_{section}").encode("UTF-8") ) ] inline_keyboard.append(ikeyboard) config.read("rclone.conf") section = config.sections()[0] msg_text = f"""Default section of rclone config is: **{section}**\n\n There are {len(sections)} sections in your rclone.conf file, please choose which section you want to use:""" ikeyboard = [ pyrogram.InlineKeyboardButton( "โผ๏ธ Cancel โผ๏ธ", callback_data=(f"rcloneCancel").encode("UTF-8") ) ] inline_keyboard.append(ikeyboard) reply_markup = pyrogram.InlineKeyboardMarkup(inline_keyboard) await message.reply_text(text=msg_text, reply_markup=reply_markup) else: await message.reply_text("You have no permission!") LOGGER.warning( f"uid={message.from_user.id} have no permission to edit rclone config!" )
async def upload_single_file( message, local_file_name, caption_str, from_user, client, edit_media, yt_thumb ): await asyncio.sleep(EDIT_SLEEP_TIME_OUT) local_file_name = str(Path(local_file_name).resolve()) sent_message = None start_time = time.time() # thumbnail_location = os.path.join( DOWNLOAD_LOCATION, "thumbnails", str(from_user) + ".jpg" ) # LOGGER.info(thumbnail_location) if UPLOAD_AS_DOC.upper() == "TRUE": # todo: this code will be removed in future thumb = None thumb_image_path = None if os.path.exists(thumbnail_location): thumb_image_path = await copy_file( thumbnail_location, os.path.dirname( os.path.abspath(local_file_name)) ) thumb = thumb_image_path message_for_progress_display = message if not edit_media: message_for_progress_display = await message.reply_text( "starting upload of {}".format( os.path.basename(local_file_name)) ) prog = Progress(from_user, client, message_for_progress_display) sent_message = await message.reply_document( document=local_file_name, thumb=thumb, caption=caption_str, parse_mode="html", disable_notification=True, progress=prog.progress_for_pyrogram, progress_args=( f"{os.path.basename(local_file_name)}", start_time, ), ) if edit_media: await message_for_progress_display.delete() if message.message_id != message_for_progress_display.message_id: try: await message_for_progress_display.delete() except FloodWait as gf: time.sleep(gf.x) except Exception as rr: LOGGER.warning(str(rr)) os.remove(local_file_name) if thumb is not None: os.remove(thumb) else: try: message_for_progress_display = message if not edit_media: message_for_progress_display = await message.reply_text( "starting upload of {}".format( os.path.basename(local_file_name)) ) prog = Progress(from_user, client, message_for_progress_display) if local_file_name.upper().endswith(("MKV", "MP4", "WEBM", "M4V", "3GP")): duration = 0 try: metadata = extractMetadata(createParser(local_file_name)) if metadata.has("duration"): duration = metadata.get("duration").seconds except Exception as g_e: LOGGER.info(g_e) width = 0 height = 0 thumb_image_path = None if os.path.exists(thumbnail_location): thumb_image_path = await copy_file( thumbnail_location, os.path.dirname(os.path.abspath(local_file_name)), ) else: if not yt_thumb: thumb_image_path = await take_screen_shot( local_file_name, os.path.dirname(os.path.abspath(local_file_name)), (duration / 2), ) else: req = requests.get(yt_thumb) thumb_image_path = os.path.join( os.path.dirname(os.path.abspath(local_file_name)), str(time.time()) + ".jpg", ) with open(thumb_image_path, "wb") as thum: thum.write(req.content) img = Image.open(thumb_image_path).convert("RGB") img.save(thumb_image_path, format="jpeg") # get the correct width, height, and duration for videos greater than 10MB if os.path.exists(thumb_image_path): metadata = extractMetadata( createParser(thumb_image_path)) if metadata.has("width"): width = metadata.get("width") if metadata.has("height"): height = metadata.get("height") # ref: https://t.me/PyrogramChat/44663 # https://stackoverflow.com/a/21669827/4723940 Image.open(thumb_image_path).convert("RGB").save( thumb_image_path ) img = Image.open(thumb_image_path) # https://stackoverflow.com/a/37631799/4723940 img.resize((320, height)) img.save(thumb_image_path, "JPEG") # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails # thumb = None if thumb_image_path is not None and os.path.isfile(thumb_image_path): thumb = thumb_image_path # send video if edit_media and message.photo: await asyncio.sleep(EDIT_SLEEP_TIME_OUT) sent_message = await message.edit_media( media=InputMediaVideo( media=local_file_name, thumb=thumb, caption=caption_str, parse_mode="html", width=width, height=height, duration=duration, supports_streaming=True, ) # quote=True, ) else: sent_message = await message.reply_video( video=local_file_name, caption=caption_str, parse_mode="html", duration=duration, width=width, height=height, thumb=thumb, supports_streaming=True, disable_notification=True, progress=prog.progress_for_pyrogram, progress_args=( f"{os.path.basename(local_file_name)}", start_time, ), ) if thumb is not None: os.remove(thumb) elif local_file_name.upper().endswith(("MP3", "M4A", "M4B", "FLAC", "WAV")): metadata = extractMetadata(createParser(local_file_name)) duration = 0 title = "" artist = "" if metadata.has("duration"): duration = metadata.get("duration").seconds if metadata.has("title"): title = metadata.get("title") if metadata.has("artist"): artist = metadata.get("artist") thumb_image_path = None if os.path.isfile(thumbnail_location): thumb_image_path = await copy_file( thumbnail_location, os.path.dirname(os.path.abspath(local_file_name)), ) thumb = None if thumb_image_path is not None and os.path.isfile(thumb_image_path): thumb = thumb_image_path # send audio if edit_media and message.photo: await asyncio.sleep(EDIT_SLEEP_TIME_OUT) sent_message = await message.edit_media( media=InputMediaAudio( media=local_file_name, thumb=thumb, caption=caption_str, parse_mode="html", duration=duration, performer=artist, title=title, ) ) else: sent_message = await message.reply_audio( audio=local_file_name, caption=caption_str, parse_mode="html", duration=duration, performer=artist, title=title, thumb=thumb, disable_notification=True, progress=prog.progress_for_pyrogram, progress_args=( f"{os.path.basename(local_file_name)}", start_time, ), ) if thumb is not None: os.remove(thumb) else: thumb_image_path = None if os.path.isfile(thumbnail_location): thumb_image_path = await copy_file( thumbnail_location, os.path.dirname(os.path.abspath(local_file_name)), ) # if a file, don't upload "thumb" # this "diff" is a major derp -_- ๐๐ญ๐ญ thumb = None if thumb_image_path is not None and os.path.isfile(thumb_image_path): thumb = thumb_image_path # # send document if edit_media and message.photo: sent_message = await message.edit_media( media=InputMediaDocument( media=local_file_name, thumb=thumb, caption=caption_str, parse_mode="html", ) ) else: sent_message = await message.reply_document( document=local_file_name, thumb=thumb, caption=caption_str, parse_mode="html", disable_notification=True, progress=prog.progress_for_pyrogram, progress_args=( f"{os.path.basename(local_file_name)}", start_time, ), ) if thumb is not None: os.remove(thumb) except MessageNotModified as oY: LOGGER.info(oY) except FloodWait as g: LOGGER.info(g) time.sleep(g.x) except Exception as e: LOGGER.info(e) await message_for_progress_display.edit_text("**FAILED**\n" + str(e)) else: if message.message_id != message_for_progress_display.message_id: try: if sent_message is not None: await message_for_progress_display.delete() except FloodWait as gf: time.sleep(gf.x) except Exception as rr: LOGGER.warning(str(rr)) await asyncio.sleep(5) os.remove(local_file_name) return sent_message
async def check_progress_for_dl(aria2, gid, event, previous_message): # g_id = event.reply_to_message.from_user.id try: file = aria2.get_download(gid) complete = file.is_complete is_file = file.seeder if not complete: if not file.error_message: msg = "" # sometimes, this weird https://t.me/c/1220993104/392975 # error creeps up # TODO: temporary workaround downloading_dir_name = "N/A" try: # another derp -_- # https://t.me/c/1220993104/423318 downloading_dir_name = str(file.name) except: pass # if is_file is None: msgg = f"Conn: {file.connections} <b>|</b> GID: <code>{gid}</code>" else: msgg = f"P: {file.connections} | S: {file.num_seeders} <b>|</b> GID: <code>{gid}</code>" msg = f"\n`{downloading_dir_name}`" msg += f"\n<b>Speed</b>: {file.download_speed_string()}" msg += f"\n<b>Status</b>: {file.progress_string()} <b>of</b> {file.total_length_string()} <b>|</b> {file.eta_string()} <b>|</b> {msgg}" # msg += f"\nSize: {file.total_length_string()}" # if is_file is None : # msg += f"\n<b>Conn:</b> {file.connections}, GID: <code>{gid}</code>" # else : # msg += f"\n<b>Info:</b>[ P : {file.connections} | S : {file.num_seeders} ], GID: <code>{gid}</code>" # msg += f"\nStatus: {file.status}" # msg += f"\nETA: {file.eta_string()}" # msg += f"\nGID: <code>{gid}</code>" inline_keyboard = [] ikeyboard = [] ikeyboard.append( InlineKeyboardButton( "Cancel รฐลธลกยซ", callback_data=(f"cancel {gid}").encode("UTF-8"))) inline_keyboard.append(ikeyboard) reply_markup = InlineKeyboardMarkup(inline_keyboard) if msg != previous_message: if not file.has_failed: try: await event.edit(msg, reply_markup=reply_markup) except FloodWait as e_e: LOGGER.warning(f"Trying to sleep for {e_e}") time.sleep(e_e.x) except MessageNotModified as e_p: LOGGER.info(e_p) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) previous_message = msg else: LOGGER.info( f"Cancelling downloading of {file.name} may be due to slow torrent" ) await event.edit( f"Download cancelled :\n<code>{file.name}</code>\n\n #MetaDataError" ) file.remove(force=True, files=True) return False else: msg = file.error_message LOGGER.info(msg) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit(f"`{msg}`") return False await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) else: LOGGER.info( f"Downloaded Successfully: `{file.name} ({file.total_length_string()})` รฐลธยคโ" ) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit( f"Downloaded Successfully: `{file.name} ({file.total_length_string()})` รฐลธยคโ" ) return True except aria2p.client.ClientException: await event.edit( f"Download cancelled :\n<code>{file.name} ({file.total_length_string()})</code>" ) except MessageNotModified as ep: LOGGER.info(ep) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) except FloodWait as e: LOGGER.info(e) time.sleep(e.x) except RecursionError: file.remove(force=True, files=True) await event.edit("Download Auto Canceled :\n\n" "Your Torrent/Link is Dead.".format(file.name)) return False except Exception as e: LOGGER.info(str(e)) if "not found" in str(e) or "'file'" in str(e): await event.edit( f"Download cancelled :\n<code>{file.name} ({file.total_length_string()})</code>" ) return False else: LOGGER.info(str(e)) await event.edit( "<u>error</u> :\n<code>{}</code> \n\n#error".format(str(e))) return False
async def check_progress_for_dl(aria2, gid, event, previous_message): # g_id = event.reply_to_message.from_user.id try: file = aria2.get_download(gid) complete = file.is_complete is_file = file.seeder if not complete: if not file.error_message: msg = "" # sometimes, this weird https://t.me/c/1220993104/392975 # error creeps up # TODO: temporary workaround downloading_dir_name = "N/A" try: # another derp -_- # https://t.me/c/1220993104/423318 downloading_dir_name = str(file.name) except: pass # if is_file is None: msgg = f"<b>โ โ โ ๐๐ข๐ก๐ก๐๐๐ง๐๐ข๐ก๐ฆ : {file.connections}</b>" else: msgg = f"<b>โ โ ๐ ๐๐ก๐๐ข :๐ฃ๐๐๐ฅ: {file.connections} || ๐ฆ๐๐๐: {file.num_seeders} </b>\n\n<b>โ โ ๐๏ธ ๐๐๐ :</b> <code>{gid}</code>" msg = f"\n<b> โโโโโโโโโโโโโโโโ โ ๐ฅ ๐๐ข๐ช๐ก๐๐ข๐๐๐๐ก๐.. โ \nโ" msg += f"\n<b>โ โ ๐ ๐ก๐๐ ๐ :</b> `{downloading_dir_name}`\nโ\n<b>โ โ ๐งญ ๐ฆ๐ฃ๐๐๐ :</b> `{file.download_speed_string()}`\nโ" msg += f"\n<b>โ โ ๐พ ๐ง๐ข๐ง๐๐ ๐ฆ๐๐ญ๐ :</b> `{file.total_length_string()}`\n<b>โ" msg += f"\n<b>โ โ โณ ๐๐ผ๐๐ป๐น๐ผ๐ฎ๐ฑ๐ฒ๐ฑ</b> : `{file.progress_string()}`\nโ\n<b>โ โ โฐ ๐๐ง๐ :</b> `{file.eta_string()}`\nโ\n{msgg}\nโ" msg += f"\n<b>โโโโโ โโก๏ธ ๐ง๐๐๐ ๐๐๐ฉ โ" inline_keyboard = [] ikeyboard = [] ikeyboard.append( InlineKeyboardButton( "โ Cancel โ", callback_data=(f"cancel {gid}").encode("UTF-8"))) inline_keyboard.append(ikeyboard) reply_markup = InlineKeyboardMarkup(inline_keyboard) if msg != previous_message: if not file.has_failed: try: await event.edit(msg, reply_markup=reply_markup) except FloodWait as e_e: LOGGER.warning(f"Trying to sleep for {e_e}") time.sleep(e_e.x) except MessageNotModified as e_p: LOGGER.info(e_p) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) previous_message = msg else: LOGGER.info( f" ๐๐๐ก๐๐๐๐๐๐ก๐ ๐๐ข๐ช๐ก๐๐ข๐๐๐๐ก๐ ๐ข๐ {file.name} ๐ ๐๐ฌ ๐๐ ๐๐จ๐ ๐ง๐ข ๐ฆ๐๐ข๐ช ๐ง๐ข๐ฅ๐ฅ๐๐ก๐ง\n\n#Cancelled" ) await event.edit( f"๐๐ข๐ช๐ก๐๐ข๐๐ ๐๐๐ก๐๐๐๐๐๐ โ\n\n๐๐ถ๐น๐ฒ ๐ก๐ฎ๐บ๐ฒ ๐ :<code>{file.name}</code>\n\n#Cancelled" ) file.remove(force=True, files=True) return False else: msg = file.error_message LOGGER.info(msg) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit(f"`{msg}`") return False await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) else: LOGGER.info( f"<b>๐๐ข๐ช๐ก๐๐ข๐๐ ๐๐ข๐ ๐ฃ๐๐๐ง๐๐ ๐ฏ</b>\n\n <b>๐๐ถ๐น๐ฒ ๐ก๐ฎ๐บ๐ฒ</b> ๐:`{file.name}`\n\n<b>๐ง๐ผ๐๐ฎ๐น ๐ฆ๐ถ๐๐ฒ โ</b>: `ใ{file.total_length_string()}ใ`\n\n#Completed" ) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit( f"<b>๐๐ข๐ช๐ก๐๐ข๐๐ ๐๐ข๐ ๐ฃ๐๐๐ง๐๐ ๐ฏ</b>\n\n <b>๐๐ถ๐น๐ฒ ๐ก๐ฎ๐บ๐ฒ</b> ๐:`{file.name}`\n\n<b>๐ง๐ผ๐๐ฎ๐น ๐ฆ๐ถ๐๐ฒ โ</b>: `ใ{file.total_length_string()}ใ`\n\n#Completed" ) return True except aria2p.client.ClientException: await event.edit( f"<b>๐๐ข๐ช๐ก๐๐ข๐๐ ๐๐๐ก๐๐๐๐๐๐ โ</b>\n\n<b>๐๐ถ๐น๐ฒ ๐ก๐ฎ๐บ๐ฒ</b>๐:<code>{file.name}\n\n<b>๐ง๐ผ๐๐ฎ๐น ๐ฆ๐ถ๐๐ฒ โ</b>: ({file.total_length_string()})</code>\n\n#Cancelled" ) except MessageNotModified as ep: LOGGER.info(ep) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) except FloodWait as e: LOGGER.info(e) time.sleep(e.x) except RecursionError: file.remove(force=True, files=True) await event.edit("*๐๐ข๐ช๐ก๐๐ข๐๐ ๐๐จ๐ง๐ข ๐๐๐ก๐๐๐๐๐๐ :**\n\n" "`๐ฌ๐ข๐จ๐ฅ ๐ง๐ข๐ฅ๐ฅ๐๐ก๐ง/๐ ๐๐๐ก๐๐ง ๐๐๐ก๐ ๐๐ฆ ๐๐๐๐.`".format( file.name)) return False except Exception as e: LOGGER.info(str(e)) if "not found" in str(e) or "'file'" in str(e): await event.edit( f"๐๐ข๐ช๐ก๐๐ข๐๐ ๐๐๐ก๐๐๐๐๐๐ โ\n\n๐๐ถ๐น๐ฒ ๐ก๐ฎ๐บ๐ฒ ๐ :<code>{file.name}\n\n๐ง๐ผ๐๐ฎ๐น ๐ฆ๐ถ๐๐ฒ โ:({file.total_length_string()})</code>\n\n#Cancelled" ) return False else: LOGGER.info(str(e)) await event.edit( "<u>โ ๐๐ฅ๐ฅ๐ข๐ฅ โ</u> :\n<code>{}</code> \n\n#error".format(str(e)) ) return False
async def check_progress_for_dl(aria2, gid, event, previous_message): # g_id = event.reply_to_message.from_user.id try: file = aria2.get_download(gid) complete = file.is_complete is_file = file.seeder if not complete: if not file.error_message: msg = "" # sometimes, this weird https://t.me/c/1220993104/392975 # error creeps up # TODO: temporary workaround downloading_dir_name = "N/A" try: # another derp -_- # https://t.me/c/1220993104/423318 downloading_dir_name = str(file.name) except: pass # prog = pyprog.ProgressBar(" ", " ", total=100, bar_length=15, complete_symbol="โ", not_complete_symbol="โ", wrap_bar_prefix=" ใ", wrap_bar_suffix="ใ ", progress_explain="", progress_loc=pyprog.ProgressBar.PROGRESS_LOC_END) old_stdout = sys.stdout new_stdout = io.StringIO() sys.stdout = new_stdout p = file.progress_string() l = len(p) p=p[0:l-1] a = float(p) prog.set_stat(a) prog.update() output = new_stdout.getvalue() sys.stdout = old_stdout prg = output[3:len(output)] i = 0 i = int(i) STR = int(os.environ.get("STR", 30)) msg = f"โญโโโโโโโโ โ ๐ฅ <b>Downloading</b> โ \n" msg += "โ"+"\nโ"+f"{prg}\n" +"โ" msg += f"\nโ<b>FileName</b> ๐: " while(len(downloading_dir_name)>0): st = downloading_dir_name[0:STR] if(i==0): msg += f"{downloading_dir_name[0:STR-15]}" downloading_dir_name = downloading_dir_name[STR-15:len(downloading_dir_name)] i = 1 else: msg += f"\nโ{st}" downloading_dir_name = downloading_dir_name[STR:len(downloading_dir_name)] msg += f"\nโ<b>Speed</b> ๐ : <code>{file.download_speed_string()} </code>" msg += f"\nโ<b>Total Size</b> ๐ : <code>{file.total_length_string()}</code>" if is_file is None : msg += f"\nโ<b>Connections</b> ๐ฌ : <code>{file.connections}</code>" else : msg += f"\nโ<b>Info</b> ๐ : <code>[ P : {file.connections} || S : {file.num_seeders} ]</code>" # msg += f"\n<b>Status</b> : <code>{file.status}</code>" msg += f"\nโ<b>ETA</b> โณ : <code>{file.eta_string()}</code>" +"\nโ" msg += "\nโฐโโโ โ โก๏ธ using engine aria2 โ" inline_keyboard = [] ikeyboard = [] ikeyboard.append( InlineKeyboardButton( "Cancel ๐ซ", callback_data=(f"cancel {gid}").encode("UTF-8") ) ) inline_keyboard.append(ikeyboard) reply_markup = InlineKeyboardMarkup(inline_keyboard) if msg != previous_message: if not file.has_failed: try: await event.edit(msg, reply_markup=reply_markup) except FloodWait as e_e: LOGGER.warning(f"Trying to sleep for {e_e}") time.sleep(e_e.x) except MessageNotModified as e_p: LOGGER.info(e_p) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) previous_message = msg else: LOGGER.info( f"Cancelling downloading of {file.name} may be due to slow torrent" ) await event.edit( f"Download cancelled :\n<code>{file.name}</code>\n\n #MetaDataError" ) file.remove(force=True, files=True) return False else: msg = file.error_message LOGGER.info(msg) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit(f"`{msg}`") return False await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) else: LOGGER.info( f"Downloaded Successfully: `{file.name} ({file.total_length_string()})` ๐ค" ) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit( f"Downloaded Successfully: `{file.name} ({file.total_length_string()})` ๐ค" ) return True except aria2p.client.ClientException: await event.edit( f"Download cancelled :\n<code>{file.name} ({file.total_length_string()})</code>" ) except MessageNotModified as ep: LOGGER.info(ep) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) except FloodWait as e: LOGGER.info(e) time.sleep(e.x) except RecursionError: file.remove(force=True, files=True) await event.edit( "Download Auto Canceled :\n\n" "Your Torrent/Link is Dead.".format(file.name) ) return False except Exception as e: LOGGER.info(str(e)) if "not found" in str(e) or "'file'" in str(e): await event.edit( f"Download cancelled :\n<code>{file.name} ({file.total_length_string()})</code>" ) return False else: LOGGER.info(str(e)) await event.edit( "<u>error</u> :\n<code>{}</code> \n\n#error".format(str(e)) ) return False
async def check_progress_for_dl(aria2, gid, event, previous_message): # g_id = event.reply_to_message.from_user.id try: file = aria2.get_download(gid) complete = file.is_complete is_file = file.seeder if not complete: if not file.error_message: msg = "" # sometimes, this weird https://t.me/c/1220993104/392975 # error creeps up # TODO: temporary workaround downloading_dir_name = "N/A" try: # another derp -_- # https://t.me/c/1220993104/423318 downloading_dir_name = str(file.name) except: pass # if is_file is None: msgg = f"<b>โ โ โ ๐๐ผ๐ป๐ป๐ฒ๐ฐ๐๐ถ๐ผ๐ป๐ : {file.connections}</b>" else: msgg = f"<b>โฉ Info :- P: {file.connections} || S: {file.num_seeders} </b>\n\n<b>๐๏ธ GID :</b> <code>{gid}</code>" msg = f"\n<b> โโโโโโโโโโโโโโโโ โ ๐ฅ ๐๐ผ๐๐ป๐น๐ผ๐ฎ๐ฑ๐ถ๐ป๐ด.. โ \nโ" msg += f"\n<b>โ โ ๐ ๐๐ถ๐น๐ฒ ๐ก๐ฎ๐บ๐ฒ :</b> `{downloading_dir_name}`\nโ\n<b>โ โ ๐งญ ๐ฆ๐ฝ๐ฒ๐ฒ๐ฑ :</b> `{file.download_speed_string()}`\nโ" msg += f"\n<b>โ โ ๐พ ๐ง๐ผ๐๐ฎ๐น ๐ฆ๐ถ๐๐ฒ :</b> `{file.total_length_string()}`\n<b>โ" msg += f"\n<b>โ โ โณ ๐๐ผ๐๐ป๐น๐ผ๐ฎ๐ฑ๐ฒ๐ฑ</b> : `{file.progress_string()}`\nโ\n<b>โ โ โฐ ๐๐ง๐ :</b> `{file.eta_string()}`\nโ\n{msgg}\nโ" msg += f"\n<b>โโโโโ โโก๏ธ ๐๐๐ฉ ๐๐๐ข๐จ๐ โ" inline_keyboard = [] ikeyboard = [] ikeyboard.append( InlineKeyboardButton( "โ Cancel โ", callback_data=(f"cancel {gid}").encode("UTF-8") ) ) inline_keyboard.append(ikeyboard) reply_markup = InlineKeyboardMarkup(inline_keyboard) if msg != previous_message: if not file.has_failed: try: await event.edit(msg, reply_markup=reply_markup) except FloodWait as e_e: LOGGER.warning(f"Trying to sleep for {e_e}") time.sleep(e_e.x) except MessageNotModified as e_p: LOGGER.info(e_p) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) previous_message = msg else: LOGGER.info( f"Cancelling downloading of {file.name} may be due to slow torrent" ) await event.edit( f"**Download cancelled :**\n<code>{file.name}</code>\n\n #MetaDataError" ) file.remove(force=True, files=True) return False else: msg = file.error_message LOGGER.info(msg) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit(f"`{msg}`") return False await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) else: LOGGER.info( f"<b> Downloaded Successfully ๐ฏ</b>: `{file.name} ({file.total_length_string()})` ๐ค" ) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await event.edit( f"<b>Downloaded Successfully ๐ฏ</b>:\n\n <b>File Name</b> ๐: \n`{file.name}`\n\n๐ <b>Total Size โ</b>: `ใ{file.total_length_string()}ใ`" ) return True except aria2p.client.ClientException: await event.edit( f"Download cancelled :\n<code>{file.name} ({file.total_length_string()})</code>" ) except MessageNotModified as ep: LOGGER.info(ep) await asyncio.sleep(EDIT_SLEEP_TIME_OUT) await check_progress_for_dl(aria2, gid, event, previous_message) except FloodWait as e: LOGGER.info(e) time.sleep(e.x) except RecursionError: file.remove(force=True, files=True) await event.edit( "*Download Auto Canceled :**\n\n" "`Your Torrent/Link is Dead.`๐บ".format(file.name) ) return False except Exception as e: LOGGER.info(str(e)) if "not found" in str(e) or "'file'" in str(e): await event.edit( f"Download cancelled :\n<code>{file.name} ({file.total_length_string()})</code>" ) return False else: LOGGER.info(str(e)) await event.edit( "<u>error</u> :\n<code>{}</code> \n\n#error".format(str(e)) ) return False