Skip to content

Commit

Permalink
🛠️ Fixes 🛠️
Browse files Browse the repository at this point in the history
  • Loading branch information
kaif-00z committed Aug 26, 2024
1 parent 6b0a022 commit d8be270
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
- <details><summary>Click Here To See How Separate Anime Channel Upload Look.</summary><img src="https://graph.org/file/a0636332545730a4d3d43.jpg" alt="sepul1"/><img src="https://graph.org/file/3eb0b86609469f385f4b5.jpg" alt="sepul2"/></details>
- Added Button Upload Support (File Store)
- <details><summary>Click Here To See How Button Upload Look.</summary><img src="https://graph.org/file/3e9abc9ec7de6a26fd1a1.jpg" alt="btnul"/></details>
- Added Multi Thread Encoding
- Added Progress Bar of Encoding
- Added ForceSub
- Added 480p Support
- Added Broadcast
Expand All @@ -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?
<p><a href="https://www.youtube.com/live/hWf7DN3nN_c"> <img src="https://img.shields.io/badge/See%20Video-black?style=for-the-badge&logo=YouTube" width="160""/></a></p>
Expand Down Expand Up @@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand Down
13 changes: 8 additions & 5 deletions functions/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
Expand All @@ -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))),
Expand All @@ -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):
Expand Down
10 changes: 6 additions & 4 deletions libs/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()

Expand Down

0 comments on commit d8be270

Please sign in to comment.