diff --git a/program/downloader.py b/program/downloader.py index 474f927..125c1f3 100644 --- a/program/downloader.py +++ b/program/downloader.py @@ -86,74 +86,6 @@ def song(_, message): print(e) -def get_readable_time(seconds: int) -> str: - count = 0 - ping_time = "" - time_list = [] - time_suffix_list = ["s", "m", "h", "days"] - - while count < 4: - count += 1 - remainder, result = divmod( - seconds, 60) if count < 3 else divmod( - seconds, 24) - if seconds == 0 and remainder == 0: - break - time_list.append(int(result)) - seconds = int(remainder) - - for x in range(len(time_list)): - time_list[x] = str(time_list[x]) + time_suffix_list[x] - if len(time_list) == 4: - ping_time += time_list.pop() + ", " - - time_list.reverse() - ping_time += ":".join(time_list) - - return ping_time - - -def time_formatter(milliseconds: int) -> str: - seconds, milliseconds = divmod(int(milliseconds), 1000) - minutes, seconds = divmod(seconds, 60) - hours, minutes = divmod(minutes, 60) - days, hours = divmod(hours, 24) - tmp = ( - ((str(days) + " day(s), ") if days else "") - + ((str(hours) + " hour(s), ") if hours else "") - + ((str(minutes) + " minute(s), ") if minutes else "") - + ((str(seconds) + " second(s), ") if seconds else "") - + ((str(milliseconds) + " millisecond(s), ") if milliseconds else "") - ) - return tmp[:-2] - - -def get_file_extension_from_url(url): - url_path = urlparse(url).path - basename = os.path.basename(url_path) - return basename.split(".")[-1] - - -async def download_song(url): - song_name = f"{randint(6969, 6999)}.mp3" - async with aiohttp.ClientSession() as session: - async with session.get(url) as resp: - if resp.status == 200: - f = await aiofiles.open(song_name, mode="wb") - await f.write(await resp.read()) - await f.close() - return song_name - - -def time_to_seconds(times): - stringt = str(times) - return sum( - int(x) * 60 ** i for i, - x in enumerate( - reversed( - stringt.split(":")))) - - @Client.on_message( command(["vsong", f"vsong@{bn}", "video", f"video@{bn}"]) & ~filters.edited )