Repository navigation
Beta #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Beta #226
Changes from all commits
04be051
c30a2d8
d7bde9c
6f9e85b
98a1731
b27d130
6c80b21
442b3aa
9694eea
c15f83d
de48317
59a338d
e1583b6
0dbe264
e4a0880
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,9 +70,11 @@ def format(self, record: LogRecord) -> str: | |||||||||||||
|
|
||||||||||||||
| LOGGER = getLogger(__name__) | ||||||||||||||
|
|
||||||||||||||
| cpu_no = os.cpu_count() | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): Hard‑coding These fixed values are now fed directly into ffmpeg/ Suggested implementation: LOGGER = getLogger(__name__)
_cpu_count = os.cpu_count() or 1
# Allow overriding detected CPU count via environment, but never exceed the real count
cpu_no = int(os.getenv("CPU_NO", _cpu_count))
if cpu_no > _cpu_count:
cpu_no = _cpu_count
# Default threads: do not exceed detected/overridden CPU count; allow env override
_default_threads = max(1, min(cpu_no, _cpu_count))
threads = int(os.getenv("FFMPEG_THREADS", _default_threads))
if threads > cpu_no:
threads = cpu_no
# Core pinning: allow explicit override, otherwise pin to the first `threads` cores
_cores_override = os.getenv("FFMPEG_CORES")
if _cores_override:
cores = _cores_override
else:
cores = ",".join(str(i) for i in range(min(threads, _cpu_count)))
|
||||||||||||||
| cpu_no = 8 | ||||||||||||||
| threads = 4 | ||||||||||||||
| cores = "0,1,2,3" | ||||||||||||||
|
Comment on lines
+73
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoding CPU-related values like
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| DOWNLOAD_DIR = "/usr/src/app/downloads/" | ||||||||||||||
| DOWNLOAD_DIR = "/app/downloads/" | ||||||||||||||
| intervals = { | ||||||||||||||
| "status": {}, | ||||||||||||||
| "qb": "", | ||||||||||||||
|
|
@@ -94,6 +96,7 @@ def format(self, record: LogRecord) -> str: | |||||||||||||
| rss_dict = {} | ||||||||||||||
| auth_chats = {} | ||||||||||||||
| excluded_extensions = ["aria2", "!qB"] | ||||||||||||||
| included_extensions = [] | ||||||||||||||
| drives_names = [] | ||||||||||||||
| drives_ids = [] | ||||||||||||||
| index_urls = [] | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| from asyncio import create_subprocess_exec, create_subprocess_shell | ||||||
| from asyncio import create_subprocess_exec, create_subprocess_shell, sleep | ||||||
| from os import environ | ||||||
|
|
||||||
| import aiohttp | ||||||
|
|
@@ -14,6 +14,7 @@ | |||||
| drives_ids, | ||||||
| drives_names, | ||||||
| excluded_extensions, | ||||||
| included_extensions, | ||||||
| index_urls, | ||||||
| nzb_options, | ||||||
| qbit_options, | ||||||
|
|
@@ -25,13 +26,14 @@ | |||||
| ) | ||||||
| from bot.helper.ext_utils.db_handler import database | ||||||
|
|
||||||
| from .aeon_client import TgClient | ||||||
| from .config_manager import Config | ||||||
| from .telegram_manager import TgClient | ||||||
| from .torrent_manager import TorrentManager | ||||||
|
|
||||||
|
|
||||||
| async def update_qb_options(): | ||||||
| """Updates qBittorrent options either from current preferences or saved configuration.""" | ||||||
| LOGGER.info("Get qBittorrent options from server") | ||||||
| if not qbit_options: | ||||||
| opt = await TorrentManager.qbittorrent.app.preferences() | ||||||
| qbit_options.update(opt) | ||||||
|
|
@@ -49,6 +51,7 @@ async def update_qb_options(): | |||||
|
|
||||||
| async def update_aria2_options(): | ||||||
| """Updates Aria2c global options either from current settings or saved configuration.""" | ||||||
| LOGGER.info("Get aria2 options from server") | ||||||
| if not aria2_options: | ||||||
| op = await TorrentManager.aria2.getGlobalOption() | ||||||
| aria2_options.update(op) | ||||||
|
|
@@ -58,8 +61,15 @@ async def update_aria2_options(): | |||||
|
|
||||||
| async def update_nzb_options(): | ||||||
| """Updates NZB options from Sabnzbd client configuration.""" | ||||||
| no = (await sabnzbd_client.get_config())["config"]["misc"] | ||||||
| nzb_options.update(no) | ||||||
| LOGGER.info("Get SABnzbd options from server") | ||||||
| while True: | ||||||
| try: | ||||||
| no = (await sabnzbd_client.get_config())["config"]["misc"] | ||||||
| nzb_options.update(no) | ||||||
| except Exception: | ||||||
| await sleep(0.5) | ||||||
| continue | ||||||
| break | ||||||
|
|
||||||
|
|
||||||
| async def load_settings(): | ||||||
|
|
@@ -260,6 +270,11 @@ async def update_variables(): | |||||
| x = x.lstrip(".") | ||||||
| excluded_extensions.append(x.strip().lower()) | ||||||
|
|
||||||
| if Config.INCLUDED_EXTENSIONS: | ||||||
| fx = Config.INCLUDED_EXTENSIONS.split() | ||||||
| for x in fx: | ||||||
| x = x.lstrip(".") | ||||||
| included_extensions.append(x.strip().lower()) | ||||||
| if Config.GDRIVE_ID: | ||||||
| drives_names.append("Main") | ||||||
| drives_ids.append(Config.GDRIVE_ID) | ||||||
|
|
@@ -273,7 +288,7 @@ async def update_variables(): | |||||
| drives_ids.append(temp[1]) | ||||||
| drives_names.append(temp[0].replace("_", " ")) | ||||||
| if len(temp) > 2: | ||||||
| index_urls.append(temp[2].strip("/")) | ||||||
| index_urls.append(temp[2]) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing
Suggested change
|
||||||
| else: | ||||||
| index_urls.append("") | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
chmod 777is insecure as it gives read, write, and execute permissions to everyone on the/appdirectory. This could lead to security vulnerabilities. It's better to use more restrictive permissions. For example, if the application needs to be run by a non-root user, you could change the ownership of the directory and set more appropriate permissions.