Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
Forgot to add playlist limit checker function.

Signed-off-by: Dawn India <[email protected]>
  • Loading branch information
Dawn-India committed Aug 15, 2024
1 parent 0977a75 commit d0f1b2e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ async def get_readable_message(
button = buttons.build_menu(8)
msg += (
"▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n"
f"<b>ᴄᴘᴜ</b>: {cpu_percent()}% | "
f"<b>ꜰʀᴇᴇ</b>: {get_readable_file_size(disk_usage(DOWNLOAD_DIR).free)}\n"
f"<b>ʀᴀᴍ</b>: {virtual_memory().percent}% | "
f"<b>ᴜᴘᴛᴍ</b>: {get_readable_time(time() - botStartTime)}"
f"<b>CPU</b>: {cpu_percent()}% | "
f"<b>FREE</b>: {get_readable_file_size(disk_usage(DOWNLOAD_DIR).free)}\n"
f"<b>RAM</b>: {virtual_memory().percent}% | "
f"<b>UPTM</b>: {get_readable_time(time() - botStartTime)}"
)
return (
msg,
Expand Down
12 changes: 12 additions & 0 deletions bot/helper/ext_utils/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,18 @@ async def check_user_tasks(user_id, maxtask):
return len(all_tasks) >= maxtask


async def list_checker(listener):
try:
if await isAdmin(listener.message):
return
except Exception as e:
LOGGER.error(f"Error while checking if the user is Admin: {e}")
if listener.is_playlist:
if PLAYLIST_LIMIT := config_dict["PLAYLIST_LIMIT"]:
if listener.playlist_count > PLAYLIST_LIMIT:
return f"Playlist limit is {PLAYLIST_LIMIT}\n⚠ Your Playlist has {listener.playlist_count} items."


async def limit_checker(
listener,
isTorrent=False,
Expand Down
12 changes: 12 additions & 0 deletions bot/helper/task_utils/download_utils/yt_dlp_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from bot.helper.ext_utils.task_manager import (
check_running_tasks,
limit_checker,
list_checker,
stop_duplicate_check
)
from bot.helper.task_utils.status_utils.queue_status import QueueStatus
Expand Down Expand Up @@ -406,6 +407,17 @@ async def add_download(self, path, qual, playlist, options):
ymsg
)
return
if list_exceeded := await list_checker(self._listener):
LOGGER.info(
f"Yt-Dlp Limit Exceeded: {self._listener.name} | {get_readable_file_size(self._listener.size)} | {self.playlist_count}"
)
ymsg = await self._listener.onDownloadError(list_exceeded)
await delete_links(self._listener.message)
await auto_delete_message(
self._listener.message,
ymsg
)
return

(
add_to_queue,
Expand Down

0 comments on commit d0f1b2e

Please sign in to comment.