diff --git a/README.md b/README.md index ccafdd0..c30ff8a 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,21 @@ [![Stars](https://img.shields.io/github/stars/kaif-00z/AutoAnimeBot?style=flat-square&color=yellow)](https://github.com/kaif-00z/AutoAnimeBot/stargazers) [![Forks](https://img.shields.io/github/forks/kaif-00z/AutoAnimeBot?style=flat-square&color=orange)](https://github.com/kaif-00z/AutoAnimeBotfork) [![Python](https://img.shields.io/badge/Python-v3.10.4-blue)](https://www.python.org/) -[![CodeFactor](https://www.codefactor.io/repository/github/kaif-00z/autoanimebot/badge)](https://www.codefactor.io/repository/github/kaif-00z/autoanimebot) +[![CodeFactor](https://www.codefactor.io/repository/github/kaif-00z/autoanimebot/badge/main)](https://www.codefactor.io/repository/github/kaif-00z/autoanimebot/overview/main) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/kaif-00z/AutoAnimeBot/graphs/commit-activity) [![Contributors](https://img.shields.io/github/contributors/kaif-00z/AutoAnimeBot?style=flat-square&color=green)](https://github.com/kaif-00z/AutoAnimeBot/graphs/contributors) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com) [![License](https://img.shields.io/badge/license-GPLv3-blue)](https://github.com/kaif-00z/AutoAnimeBot/blob/main/LICENSE) [![Sparkline](https://stars.medv.io/kaif-00z/AutoAnimeBot.svg)](https://stars.medv.io/kaif-00z/AutoAnimeBot) -## Description Of Latest Update +## Changelog Of Latest Update - Added Separate Anime Channel Upload -
Click Here To See How Separate Anime Channel Upload Look.sepul1sepul2
- Added Button Upload Support (File Store) -
Click Here To See How Button Upload Look.btnul
+- Added Multi Thread Encoding +- Added Progress Bar of Encoding - Added ForceSub - Added 480p Support - Added Broadcast @@ -28,7 +30,7 @@ ## Contributing - Any Sort of Contributions are Welcomed! -- Try To Resove Any Task From ToDo List! +- Try To Resove Any Task From ToDo List Or Raise A Issue! ## How to deploy?

@@ -66,10 +68,16 @@ - `BACKUP_CHANNEL` - ID of Channel Where Anime Will Be Saved As BackUP if You Are Using Button Upload Option Then Make Sure To SET Backup Channel. +- `FORCESUB_CHANNEL` - ID of Channel Where You Want The User To Join (Make Sure You Promoted The Bot in that channel). + +- `FORCESUB_CHANNEL_LINK` - Link of Channel Via User Join The `FORCESUB_CHANNEL`. + - `THUMBNAIL` - JPG/PNG Link of Thumbnail FIle. - `FFMPEG` - You Can Set Custom Path Of ffmpeg if u want, default is `ffmpeg`. +- `LOG_ON_MAIN` - `True/False` It Will Send LOGS in `MAIN_CHANNEL` rather than `LOG_CHANNEL`, default is `False` + - `SEND_SCHEDULE` - `True/False` Send Schedule of Upcoming Anime of that day at 00:30 **IST**, default is `False`. - `RESTART_EVERDAY` - `True/False` It Will Restart The Bot Everyday At 00:30 **IST**, default is `True`. diff --git a/bot.py b/bot.py index 42e1280..7bfe567 100644 --- a/bot.py +++ b/bot.py @@ -182,8 +182,10 @@ async def anime(data): asyncio.ensure_future(exe.further_work()) continue await reporter.report_error(_btn, log=True) + await reporter.msg.delete() except BaseException: await reporter.report_error(str(format_exc()), log=True) + await reporter.msg.delete() except BaseException: LOGS.error(str(format_exc())) diff --git a/functions/tools.py b/functions/tools.py index ec72047..89cbb17 100644 --- a/functions/tools.py +++ b/functions/tools.py @@ -38,7 +38,7 @@ class Tools: def __init__(self): - pass + self.ffmpeg_threads = int(os.cpu_count() or 0) + 3 async def async_searcher( self, @@ -161,7 +161,7 @@ def hbs(self, size): raised_to_pow += 1 return str(round(size, 2)) + " " + dict_power_n[raised_to_pow] + "B" - def ts(milliseconds: int) -> str: + def ts(self, milliseconds: int) -> str: seconds, milliseconds = divmod(int(milliseconds), 1000) minutes, seconds = divmod(seconds, 60) hours, minutes = divmod(minutes, 60) @@ -204,11 +204,11 @@ async def bash_(cmd, run_code=0): return _x.split(":")[1].split("\n")[0] async def compress(self, dl, out, log_msg): - total_frames = self.frame_counts(dl) + total_frames = await self.frame_counts(dl) if not total_frames: return False, "Unable to Count The Frames!" _progress = f"progress-{time.time()}.txt" - cmd = f'''{Var.FFMPEG} -hide_banner -loglevel quiet -progress """{_progress}""" -i """{dl}""" -metadata "Encoded By"="https://github.com/kaif-00z/AutoAnimeBot/" -map 0:v -map 0:a -map 0:s -c:v libx264 -x265-params 'bframes=8:psy-rd=1:ref=3:aq-mode=3:aq-strength=0.8:deblock=1,1' -pix_fmt yuv420p -crf {Var.CRF} -c:a libopus -b:a 32k -ac 2 -ab 32k -vbr 2 -level 3.1 -threads 16 -preset veryfast """{out}""" -y''' + cmd = f'''{Var.FFMPEG} -hide_banner -loglevel quiet -progress """{_progress}""" -i """{dl}""" -metadata "Encoded By"="https://github.com/kaif-00z/AutoAnimeBot/" -map 0:v -map 0:a -map 0:s -c:v libx264 -x265-params 'bframes=8:psy-rd=1:ref=3:aq-mode=3:aq-strength=0.8:deblock=1,1' -pix_fmt yuv420p -crf {Var.CRF} -c:a libopus -b:a 32k -ac 2 -ab 32k -vbr 2 -level 3.1 -threads {self.ffmpeg_threads} -preset veryfast """{out}""" -y''' process = await asyncio.create_subprocess_shell( cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE ) @@ -231,7 +231,7 @@ async def compress(self, dl, out, log_msg): speed = round(elapse / time_diff, 2) if int(speed) != 0: some_eta = ((int(total_frames) - elapse) / speed) * 1000 - text = f"**Successfully Downloaded The Anime**\n\n **File Name:** ```{dl}```\n\n**STATUS:** \n" + text = f"**Successfully Downloaded The Anime**\n\n **File Name:** ```{dl.split('/')[-1]}```\n\n**STATUS:** \n" progress_str = "`[{0}{1}] {2}%\n\n`".format( "".join("●" for _ in range(math.floor(per / 5))), "".join("" for _ in range(20 - math.floor(per / 5))), @@ -252,6 +252,9 @@ async def compress(self, dl, out, log_msg): ) except MessageNotModifiedError: pass + try: + os.remove(_progress) + except: pass return True, _new_log_msg async def genss(self, file): diff --git a/libs/logger.py b/libs/logger.py index 09fa9ce..4569ba3 100644 --- a/libs/logger.py +++ b/libs/logger.py @@ -68,11 +68,11 @@ async def started_compressing(self): self.msg = await self.msg.edit( f"**Successfully Downloaded The Anime**\n\n **File Name:** ```{self.file_name}```\n\n**STATUS:** `Encoding...`", ) + return self.msg async def started_renaming(self): self.msg = await self.msg.edit( f"**Successfully Downloaded The Anime**\n\n **File Name:** ```{self.file_name}```\n\n**STATUS:** `Renaming...`", - buttons=[[Button.inline("✒️", data="uwu")]], ) async def started_uploading(self): @@ -86,9 +86,11 @@ async def started_gen_ss(self): ) async def all_done(self): - self.msg = await self.msg.edit( - f"**Successfully Completed All Task Related To The Anime**\n\n **File Name:** ```{self.file_name}```\n\n**STATUS:** `DONE`" - ) + try: + self.msg = await self.msg.edit( + f"**Successfully Completed All Task Related To The Anime**\n\n **File Name:** ```{self.file_name}```\n\n**STATUS:** `DONE`" + ) + except: pass # ValueError Sometimes From telethon if Var.LOG_ON_MAIN: await self.msg.delete()