Skip to content

Commit

Permalink
Enable wbit webui external access and sync option button
Browse files Browse the repository at this point in the history
fix nzb setting set
add nzb sync options button
minor change in name substitute. check readme

Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed May 16, 2024
1 parent 7bda40c commit ad9024d
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 29 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,18 @@ quotes, even if it's `Int`, `Bool` or `List`.
- `USE_SERVICE_ACCOUNTS`: Whether to use Service Accounts or not, with google-api-python-client. For this to work
see [Using Service Accounts](https://github.com/anasty17/mirror-leech-telegram-bot#generate-service-accounts-what-is-service-account)
section below. Default is `False`. `Bool`
- `NAME_SUBSTITUTE`: Add word/letter/sentense/pattern to remove or replace with other words with sensitive case or without. **Note**: Seed will get disbaled while using this option
* Example: 'text : code : s|mirror : leech|tea : : s|clone'
- `NAME_SUBSTITUTE`: Add word/letter/sentense/pattern to remove or replace with other words with sensitive case or without.**Notes**:
1. Seed will get disbaled while using this option
2. Before any character you must add \, those are the characters: `\^$.|?*+()[]{}-`
* Example-1: `text : code : s | mirror : leech | tea : : s | clone`
- text will get replaced by code with sensitive case
- mirror will get replaced by leech
- tea will get removed with sensitive case
- clone will get removed
* Example-2: `\(text\) | \[test\] : test | \\text\\ : text : s`
- `(text)` will get removed
- `[test]` will get replaced by test
- `\text\` will get replaced by text with sensitive case

**3. GDrive Tools**

Expand Down Expand Up @@ -321,6 +327,7 @@ quotes, even if it's `Int`, `Bool` or `List`.
- **Qbittorrent NOTE**: If your facing ram issues then set limit for `MaxConnections`,
decrease `AsyncIOThreadsCount`, set limit of `DiskWriteCacheSize` to `32` and decrease `MemoryWorkingSetLimit`
from qbittorrent.conf or bsetting command.
- Open port 8090 in your vps to access webui from any device. username: mltb, password: mltbmltb

**8. JDownloader**

Expand All @@ -336,6 +343,7 @@ quotes, even if it's `Int`, `Bool` or `List`.
- [READ THIS FOR MORE INFORMATION](https://sabnzbd.org/wiki/configuration/4.2/servers)

- **NOTE**: Enable port 8070 in your vps to access sabnzbd full web interface
- Open port 8070 in your vps to access web interface from any device.

**10. RSS**

Expand Down
28 changes: 16 additions & 12 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,18 +548,22 @@ def get_sabnzb_client():

scheduler = AsyncIOScheduler(timezone=str(get_localzone()), event_loop=bot_loop)

if not qbit_options:
qbit_options = dict(get_qb_client().app_preferences())
del qbit_options["listen_port"]
for k in list(qbit_options.keys()):
if k.startswith("rss"):
del qbit_options[k]
else:
qb_opt = {**qbit_options}
for k, v in list(qb_opt.items()):
if v in ["", "*"]:
del qb_opt[k]
get_qb_client().app_set_preferences(qb_opt)
def get_qb_options():
global qbit_options
if not qbit_options:
qbit_options = dict(get_qb_client().app_preferences())
del qbit_options["listen_port"]
for k in list(qbit_options.keys()):
if k.startswith("rss"):
del qbit_options[k]
else:
qb_opt = {**qbit_options}
for k, v in list(qb_opt.items()):
if v in ["", "*"]:
del qb_opt[k]
get_qb_client().app_set_preferences(qb_opt)

get_qb_options()

aria2 = ariaAPI(ariaClient(host="http://localhost", port=6800, secret=""))
if not aria2_options:
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def beforeStart(self):
else ""
)
if self.nameSub:
self.nameSub = [x.split(" : ") for x in self.nameSub.split("|")]
self.nameSub = [x.split(" : ") for x in self.nameSub.split(" | ")]
self.seed = False
self.extensionFilter = (
self.userDict.get("excluded_extensions") or GLOBAL_EXTENSION_FILTER
Expand Down
12 changes: 9 additions & 3 deletions bot/helper/ext_utils/db_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ async def db_load(self):
)
# Save qbittorrent options
if await self._db.settings.qbittorrent.find_one({"_id": bot_id}) is None:
await self._db.settings.qbittorrent.update_one(
{"_id": bot_id}, {"$set": qbit_options}, upsert=True
)
await self.save_qbit_settings()
# Save nzb config
if await self._db.settings.nzb.find_one({"_id": bot_id}) is None:
async with aiopen("sabnzbd/SABnzbd.ini", "rb+") as pf:
Expand Down Expand Up @@ -136,6 +134,14 @@ async def update_qbittorrent(self, key, value):
)
self._conn.close

async def save_qbit_settings(self):
if self._err:
return
await self._db.settings.qbittorrent.update_one(
{"_id": bot_id}, {"$set": qbit_options}, upsert=True
)
self._conn.close

async def update_private_file(self, path):
if self._err:
return
Expand Down
22 changes: 18 additions & 4 deletions bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
bot,
jd_downloads,
nzb_options,
get_nzb_options,
get_qb_options,
)
from bot.helper.ext_utils.bot_utils import (
setInterval,
Expand Down Expand Up @@ -183,6 +185,7 @@ async def get_buttons(key=None, edit_type=None):
buttons.ibutton("Edit", "botset edit qbit")
else:
buttons.ibutton("View", "botset view qbit")
buttons.ibutton("Sync Qbittorrent", "botset syncqbit")
buttons.ibutton("Back", "botset back")
buttons.ibutton("Close", "botset close")
for x in range(0, len(qbit_options), 10):
Expand All @@ -198,6 +201,7 @@ async def get_buttons(key=None, edit_type=None):
else:
buttons.ibutton("View", "botset view nzb")
buttons.ibutton("Servers", "botset nzbserver")
buttons.ibutton("Sync Sabnzbd", "botset syncnzb")
buttons.ibutton("Back", "botset back")
buttons.ibutton("Close", "botset close")
for x in range(0, len(nzb_options), 10):
Expand Down Expand Up @@ -395,7 +399,7 @@ async def edit_nzb(_, message, pre_message, key):
elif value.startswith("[") and value.endswith("]"):
value = ",".join(eval(value))
res = await nzb_client.set_config("misc", key, value)
value = res["misc"][key]
value = res["config"]["misc"][key]
nzb_options[key] = value
await nzb_client.log_out()
await update_buttons(pre_message, "nzb")
Expand Down Expand Up @@ -668,7 +672,7 @@ async def edit_bot_settings(client, query):
elif data[2] in ["JD_EMAIL", "JD_PASS"]:
jdownloader.device = None
jdownloader.error = "JDownloader Credentials not provided!"
await create_subprocess_exec(["pkill", "-9", "-f", "java"])
await create_subprocess_exec("pkill", "-9", "-f", "java")
elif data[2] == "USENET_SERVERS":
nzb_client = get_sabnzb_client()
for s in config_dict["USENET_SERVERS"]:
Expand Down Expand Up @@ -713,11 +717,21 @@ async def edit_bot_settings(client, query):
await query.answer()
nzb_client = get_sabnzb_client()
res = await nzb_client.set_config_default(data[2])
nzb_options[data[2]] = res["misc"][data[2]]
nzb_options[data[2]] = res["config"]["misc"][data[2]]
await nzb_client.log_out()
await update_buttons(message, "nzb")
if DATABASE_URL:
await DbManager().update_nzb_config()
elif data[1] == "syncnzb":
await query.answer("Syncronization Started. It takes up to 2 sec!", show_alert=True)
await get_nzb_options()
if DATABASE_URL:
await DbManager().update_nzb_config()
elif data[1] == "syncqbit":
await query.answer("Syncronization Started. It takes up to 2 sec!", show_alert=True)
await get_qb_options()
if DATABASE_URL:
await DbManager().save_qbit_settings()
elif data[1] == "emptyaria":
await query.answer()
aria2_options[data[2]] = ""
Expand All @@ -744,7 +758,7 @@ async def edit_bot_settings(client, query):
await query.answer()
nzb_client = get_sabnzb_client()
res = await nzb_client.set_config("misc", data[2], "")
nzb_options[data[2]] = res["misc"][data[2]]
nzb_options[data[2]] = res["config"]["misc"][data[2]]
await nzb_client.log_out()
await update_buttons(message, "nzb")
if DATABASE_URL:
Expand Down
13 changes: 8 additions & 5 deletions bot/modules/users_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,16 +730,19 @@ async def edit_user_settings(client, query):
buttons.ibutton("Remove Name Subtitute", f"userset {user_id} name_sub")
buttons.ibutton("Back", f"userset {user_id} back")
buttons.ibutton("Close", f"userset {user_id} close")
emsg = f"""Word Subtitions. You can add pattern instead of normal text. Timeout: 60 sec
Example: 'text : code : s|mirror : leech|tea : : s|clone'
emsg = r"""Word Subtitions. You can add pattern instead of normal text. Timeout: 60 sec
NOTE: You must add \ before any character, those are the characters: \^$.|?*+()[]{}-
Example-1: text : code : s|mirror : leech|tea : : s|clone
1. text will get replaced by code with sensitive case
2. mirror will get replaced by leech
4. tea will get removed with sensitive case
5. clone will get removed
Your Current Value is {user_dict.get('name_sub') or 'not added yet!'}
Example-2: \(text\) | \[test\] : test | \\text\\ : text : s
1. (text) will get removed
2. [test] will get replaced by test
3. \text\ will get replaced by text with sensitive case
"""
emsg += f"Your Current Value is {user_dict.get('name_sub') or 'not added yet!'}"
await editMessage(
message,
emsg,
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ services:
- "80:80"
- "8080:8080"
- "8070:8070"
- "8090:8090"
5 changes: 4 additions & 1 deletion qBittorrent/config/qBittorrent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TrackerEnabled=true
Accepted=true

[Meta]
MigrationVersion=4
MigrationVersion=6

[Preferences]
Advanced\DisableRecursiveDownload=false
Expand All @@ -51,6 +51,7 @@ Advanced\trackerPortForwarding=true
General\PreventFromSuspendWhenDownloading=true
General\PreventFromSuspendWhenSeeding=true
Search\SearchEnabled=true
WebUI\Address=*
WebUI\BanDuration=3600
WebUI\CSRFProtection=false
WebUI\ClickjackingProtection=false
Expand All @@ -62,3 +63,5 @@ WebUI\MaxAuthenticationFailCount=1000
WebUI\Port=8090
WebUI\SecureCookie=false
WebUI\UseUPnP=false
WebUI\Username=mltb
WebUI\Password_PBKDF2="@ByteArray(1oHtzi25tW8vz8avm8ddZA==:Lk8EsspvZtNgxl/3V4Ie+uabkqZ1JUDmyJnvXHVHw+FOxymZvAN4HSOPuMISpICUOZmCXb1pBTF81efl3ry35Q==)"
2 changes: 1 addition & 1 deletion sabnzbd/SABnzbd.ini
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pause_on_pwrar = 0
ignore_samples = 0
deobfuscate_final_filenames = 1
auto_sort = ""
direct_unpack = 1
direct_unpack = 0
propagation_delay = 0
folder_rename = 1
replace_spaces = 0
Expand Down

0 comments on commit ad9024d

Please sign in to comment.