async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) print('sleeping for a sec') xcruz.sleep(1) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`Failed To Fetch Youtube Data... 😔 \nPossible Youtube Blocked server ip \n#error`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("Please wait 🤒🤕🙇") print('sleeping for a sec') xcruz.sleep(1) try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw img = wget.download(thumbnail_url) im = Image.open(img).convert("RGB") output_directory = os.path.join(os.getcwd(), "downloads", str(message.chat.id)) if not os.path.isdir(output_directory): os.makedirs(output_directory) thumb_image_path = f"{output_directory}.jpg" im.save(thumb_image_path, "jpeg") await message.reply_photo(thumb_image_path, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: print(e) try: thumbnail_url = "https://telegra.ph/file/ce37f8203e1903feed544.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Tunggu {wait_time} Menit sebelum permintaan selanjutnya`") return except: pass url = message.text.strip() await message.reply_chat_action("Mengetik") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`Gagal untuk mendeteksi data youtube... \nYoutube memblokir alamat ip video \n#error`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("`Melakukan Proses url Youtube...`") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw img = wget.download(thumbnail_url) im = Image.open(img).convert("RGB") output_directory = os.path.join(os.getcwd(), "downloads", str(message.chat.id)) if not os.path.isdir(output_directory): os.makedirs(output_directory) thumb_image_path = f"{output_directory}.jpg" im.save(thumb_image_path, "jpeg") await message.reply_photo(thumb_image_path, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: print(e) try: thumbnail_url = "https://telegra.ph/file/eb2e063501382d4b96fbf.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message: Message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"**انتظر {wait_time} دقيقة ومن ثم اعد التحميل ... **") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("**فشل التحميل ** 😔") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("يتم البحث عن الفيديو ..") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw img = wget.download(thumbnail_url) im = Image.open(img).convert("RGB") output_directory = os.path.join(os.getcwd(), "downloads", str(message.chat.id)) if not os.path.isdir(output_directory): os.makedirs(output_directory) thumb_image_path = f"{output_directory}.jpg" im.save(thumb_image_path, "jpeg") await message.reply_photo(thumb_image_path, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: print(e) try: thumbnail_url = "https://telegra.ph/file/ce37f8203e1903feed544.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit( f"<code>تحقق من الرابط وأعد ارسالة رحمه لكسمك</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`Failed To Fetch Youtube Data... 😔 \nPossible Youtube Blocked server ip \n#error. SORRY😥.`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("Fetching your Youtube Url 🔄 🔄 🔄" ) try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/b5de84bf2dce1cbedd5d3.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`YouTube හි දත්ත ලබා ගැනීමට අපොහොසත් විය... 😢 \nPossible Youtube Blocked server ip \n#error`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text( "ඔබගේ YouTube Video එක සොයමි,මොහොතක් රැදී සිටින්න...🧐") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/ce37f8203e1903feed544.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "<b>Failed To Download Video... 🥺 \nPossible Youtube Blocked Server IP \n#error</b>" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("<b>Processing Youtube Link... �</b>") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/55f3f1603b06dcadd9f22.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`යූ ටියුබ් දත්ත ලබා ගැනීමට අපොහොසත් විය ... 😔 \nටියුබ් අවහිර කළ සේවාදායකය ip \n#error`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("යූටියුබ් යූආර්එල් සැකසීම ◾️◾️◾️◾️👀") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/44706b57abb809b53c68d.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`A fail tlat mai.. 😔 \nA chhhan chu, he Video Data hi ka hmu thei lo tlat. \n#error`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("YT URL a dik e... © @TGBotSzK") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/d75ec77d3d1a4a7f64548.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`Failed To Fetch Youtube Data... 😔 \nPossible Youtube Blocked server ip \n#error`" ) return buttons = InlineKeyboardMarkup(create_buttons(formats)) sentm = await message.reply_text("Processing Youtube Url 🔎 🔎 🔎") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # TODO fix some 10 sec video for fetching details idk why but its not working # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: await message.reply_text(text=title, reply_markup=buttons) print(e) await sentm.edit( f"<code>Error Occurs Due To Youtube-dl not able To Fetch </code>{title} <code>Details</code> #Error" )
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`ඉන්න {wait_time} ඊළඟ ඉල්ලීමට මිනිත්තු කිහිපයකට පෙර😌`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`යූ ටියුබ් දත්ත ලබා ගැනීමට අපොහොසත් විය ... 😔 \nYoutube සේවාදායකයේ අන්තර්ජාල නියමාවලි අවහිර වි ඇත. \n#දෝෂයකි`" ) return buttons = InlineKeyboardMarkup(create_buttons(formats)) sentm = await message.reply_text("යූටියුබ් යූආර්එල් සැකසීම ▪️▪️▪️👀") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # TODO fix some 10 sec video for fetching details idk why but its not working # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: await message.reply_text(text=title, reply_markup=buttons) print(e) await sentm.edit( f"<code>යූටියුබ්-ඩීඑල් ලබා ගැනීමට නොහැකි වීම නිසා දෝෂයක් ඇතිවිය🤕</code>{title} <code>විස්තර</code> #දෝෂයකි" )
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`A fail tlat mai.. #error`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("Link endik mek ani..") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://1.bp.blogspot.com/-Z3ESW08JfMI/YDKuBGt6XJI/AAAAAAAAAQ8/GpdpSwrEo8UxpAIc9E2K1ISIxRnrHSLoQCLcBGAsYHQ/s1008/PicsArt_09-14-06.20.21.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text(f"`انتظر {wait_time} دقيقه `") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`فشل جلب المعلومات ... \n#error`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("يتم فحص الرابط الان🔎 🔎 🔎") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/ce37f8203e1903feed544.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round((userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text(f"`انتظر {wait_time} كرمال الضغط عليي شوي 🥺`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`افففف منككك ... 😔 \nماقلتلك انا ماتبعتلي يا ارنب روابط لقوائم تشغيل فقط فيدوهات مفردة 😭 \n#error`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("فففف هلكتني وانت تحمل 🥺🥺 خود الفيديو تبعك وريحني😒") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) await sentm.delete() except Exception as e: try: thumbnail_url = "https://telegra.ph/file/922824d2d952a38885bd4.jpg" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit( f"<code>{e}</code> #Error")
async def ytdl(_, message): if message.from_user.id not in Config.AUTH_USERS: await message.delete() a = await message.reply_text(text=Translation.NOT_AUTH_TXT) time.sleep(8) await a.delete() return saved_file_path = os.getcwd() + "/" + "downloads" + "/" + str(message.from_user.id) + "/" if not os.path.isdir(saved_file_path): os.makedirs(saved_file_path) dl_folder = [f for f in os.listdir(saved_file_path)] for f in dl_folder: try: os.remove(os.path.join(saved_file_path, f)) except IndexError: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) except Exception: await message.delete() await message.reply_text( text=Translation.FAILED_LINK, reply_markup=InlineKeyboardMarkup( [ [InlineKeyboardButton("Close", callback_data="close")] ]) ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) start_message = await message.reply_text(text=Translation.PROCESS_START) thumbnail = os.getcwd() + "/" + "thumbnails" + "/" + str(message.from_user.id) + ".jpg" if os.path.exists(thumbnail): try: await message.reply_photo(thumbnail, caption=title, reply_markup=buttons) await start_message.delete() except IndexError: pass else: yt_thumb_image_path = os.getcwd() + "/" + "YouTubeThumb" + "/" if not os.path.isdir(yt_thumb_image_path): os.makedirs(yt_thumb_image_path) yt_folder = [f for f in os.listdir(yt_thumb_image_path)] for f in yt_folder: try: os.remove(os.path.join(yt_thumb_image_path, f)) except IndexError: pass yt_thumb_image = os.getcwd() + "/" + "YouTubeThumb" + "/" + str(message.from_user.id) + ".jpg" try: thumb_url = message.text exp = "^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*" s = re.findall(exp, thumb_url)[0][-1] thumb = f"https://i.ytimg.com/vi/{s}/maxresdefault.jpg" wget.download(thumb, yt_thumb_image, bar=None) await message.reply_photo(yt_thumb_image, caption=title, reply_markup=buttons) await start_message.delete() except Exception: a = await start_message.edit(text=Translation.URL_ERROR) time.sleep(5) await a.delete() return
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round( (userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text( f"`Wait {wait_time} Minutes before next Request`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text( "`Failed To Fetch Youtube Data... 😔 \nPossible Youtube Blocked server ip \n#error`" ) return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text( "🔎 🔎 🔎در حال دریافت کیفیتهای گوناگون ویدیوی درخواستی") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw img = wget.download(thumbnail_url) im = Image.open(img).convert("RGB") output_directory = os.path.join(os.getcwd(), "downloads", str(message.chat.id)) if not os.path.isdir(output_directory): os.makedirs(output_directory) thumb_image_path = f"{output_directory}.jpg" im.save(thumb_image_path, "jpeg") await message.reply_photo(thumb_image_path, caption=title, reply_markup=buttons) joinButton2 = InlineKeyboardMarkup([[ InlineKeyboardButton("تماس برای مشاوره", url="https://t.me/igmdco") ], [InlineKeyboardButton("ثبت اثر", url="http://igmd.co")]]) await message.reply_photo( "http://igmd.co/images/photo_2021-05-02%2005.13.23.jpeg", caption= "انتشار آثار موسیقایی شما در اسپاتیفای . اپل موزیک . آمازون . شزم . اینستاگرام . یوتیوب موزیک و دهها پایگاه جهانی معتبر دیگر . موسیقی خود را به دلار بفروشید و به ریال درآمد کسب کنید . آی جی ام دی , نخستین پایگاه پخش موسیقی ایران در جهان . صدور لیبل معتبر جهانی . همین حالا موسیقی خود را از طریق سایت IGMD ثبت نمایید ", reply_markup=joinButton2) await sentm.delete() except Exception as e: print(e) try: thumbnail_url = "https://telegra.ph/file/ce37f8203e1903feed544.png" await message.reply_photo(thumbnail_url, caption=title, reply_markup=buttons) except Exception as e: await sentm.edit(f"<code>{e}</code> #Error")
async def ytdl(_, message): userLastDownloadTime = user_time.get(message.chat.id) try: if userLastDownloadTime > datetime.now(): wait_time = round((userLastDownloadTime - datetime.now()).total_seconds() / 60, 2) await message.reply_text(f"`✋ Iltimos kuting. Keyingi videoni yuklash uchun so'rovni {wait_time} daqiqadan so'ng qaytadan yuboring...`") return except: pass url = message.text.strip() await message.reply_chat_action("typing") try: title, thumbnail_url, formats = extractYt(url) now = datetime.now() user_time[message.chat.id] = now + \ timedelta(minutes=youtube_next_fetch) except Exception: await message.reply_text("`YouTube video ma'lumotlarini olib bo'lmadi... 😔 \n❗ YouTube ip serverni bloklagan bo'lishi mumkin`") return buttons = InlineKeyboardMarkup(list(create_buttons(formats))) sentm = await message.reply_text("Video ma'lumotlari olinmoqda...") try: # Todo add webp image support in thumbnail by default not supported by pyrogram # https://www.youtube.com/watch?v=lTTajzrSkCw img = wget.download(thumbnail_url) im = Image.open(img).convert("RGB") output_directory = os.path.join(os.getcwd(), "downloads", str(message.chat.id)) if not os.path.isdir(output_directory): os.makedirs(output_directory) thumb_image_path = f"{output_directory}.jpg" im.save(thumb_image_path,"jpeg") if round(diff % 5.00) == 0 or downloaded == total_length: percentage = downloaded * 100 / total_length speed = downloaded / diff elapsed_time = round(diff) * 1000 time_to_completion = round( (total_length - downloaded) / speed) * 1000 estimated_total_time = elapsed_time + time_to_completion try: current_message = """**Download Status** File Size: {} Downloading: {} ETA: {}""".format( url, humanbytes(total_length), humanbytes(downloaded), TimeFormatter(estimated_total_time) ) if current_message != display_message: await bot.edit_message_text( chat_id, message_id, text=current_message ) display_message = current_message except Exception as e: logger.info(str(e)) pass