From 55425eebc585dd085f6ff1ee759ce08b0d9578d2 Mon Sep 17 00:00:00 2001 From: big Date: Tue, 6 Aug 2024 15:17:21 +0200 Subject: [PATCH 01/21] Version 1.5 --- manifest.json | 59 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/manifest.json b/manifest.json index 98e6884..30a3a81 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "homepage": "https://github.com/nzbgetcom/Extension-AccessOwnership", "kind": "POST-PROCESSING", "displayName": "AccessOwnership", - "version": "1.4", + "version": "1.5", "nzbgetMinVersion": "24", "author": "Lennong", "license": "GNU", @@ -12,7 +12,10 @@ "queueEvents": "", "requirements": [ "This extension is compatible with NZBGet v24+.", - "This extension requires Python3.8 and up to be installed on your system." + "This extension requires Python3.8 and up to be installed on your system.", + "This extension is supported on [Linux, MacOS].", + "", + "Start initial configuration of this extension by save and reload one time!" ], "description": [ "This script modifies access permissions & ownership on downloaded files." @@ -21,10 +24,10 @@ { "name": "DestDir", "displayName": "DestDir", - "value": "", + "value": "${DestDir}", "description": [ "Destination directory for downloads.", - "Set the same 'DestDir' value as set under the 'PATHS' settings.", + "Keep as is or manually set the same 'DestDir' value as set under the 'PATHS' settings.", "", "NOTE: Enable this extension in the 'Extensions' setting under 'EXTENSION SCRIPTS' after this extension is configured and saved." ], @@ -44,22 +47,24 @@ { "name": "Owner", "displayName": "Owner", - "value": 1000, + "value": "", "description": [ - "Sets Owner (uid) to downloaded files. Use positive integers only, starting with '0' and up.", + "Sets Owner [UID] to downloaded files. Use positive integers only, starting with '0' and up.", "", - "Default = '1000'." + "NOTE: Use 'Detect UID and GID' function to detect UID for user that runs this instance of NZBGet.", + "NOTE: If use other UID, only use UID present in system or set UID will not be applied on downloaded files." ], "select": ["UID"] }, { "name": "Group", "displayName": "Group", - "value": 1000, + "value": "", "description": [ - "Set Group (gid) to downloaded files. Use positive integers only, starting with '0' and up.", + "Set Group [GID] to downloaded files. Use positive integers only, starting with '0' and up.", "", - "Default = '1000'." + "NOTE: Use 'Detect UID and GID' function to detect GID for user that runs this instance of NZBGet.", + "NOTE: If use other GID, only use GID present in system or set GID will not be applied on downloaded files." ], "select": ["GID"] }, @@ -102,11 +107,12 @@ "section": "Categories", "name": "Owner", "displayName": "Owner", - "value": 1000, + "value": "", "description": [ - "Sets Owner (uid) to downloaded files in this category. Use positive integers only, starting with '0' and up.", + "Sets Owner [UID] to downloaded files in this category. Use positive integers only, starting with '0' and up.", "", - "Default = '1000'." + "NOTE: Use 'Detect UID and GID' function to detect UID for user that runs this instance of NZBGet.", + "NOTE: If use other UID, only use UID present in system or set UID will not be applied on downloaded files." ], "select": ["UID"] }, @@ -114,25 +120,38 @@ "section": "Categories", "name": "Group", "displayName": "Group", - "value": 1000, + "value": "", "description": [ - "Sets Group (gid) to downloaded files in this category. Use positive integers only, starting with '0' and up.", + "Sets Group [GID] to downloaded files in this category. Use positive integers only, starting with '0' and up.", "", - "Default = '1000'." + "NOTE: Use 'Detect UID and GID' function to detect GID for user that runs this instance of NZBGet.", + "NOTE: If use other GID, only use GID present in system or set GID will not be applied on downloaded files." ], "select": ["GID"] } ], "commands": [ + { + "name": "Detect", + "action": "Detect now", + "displayName": "Detect UID and GID", + "description": [ + "Detects users Owner[UID] and Group[GID]", + "", + "NOTE: Use this tool to detect Detects UID and GID for settings:", + "OWNER: detects UID for user that runs this instance of NZBGet", + "GROUP: detects GID for user that runs this instance of NZBGet" + ] + }, { "name": "Test", - "action": "Check now", - "displayName": "Test", + "action": "Test now", + "displayName": "Test Settings", "description": [ "Click to test the settings:", "", - "CATEGORIES: extension coorelates with main program", - "PATHS: extension coorelates with main program", + "CATEGORIES: extension coorelates with main settings", + "PATHS: extension coorelates with main settings", "ACCESS: extension checks validity of mask input", "OWNER: extension checks validity of UID input and present UID in system", "GROUP: extension checks validity of GID input and present GID in system" From 3b37fe709f9e0864ded91bbf3217a527c78549c3 Mon Sep 17 00:00:00 2001 From: big Date: Tue, 6 Aug 2024 15:17:53 +0200 Subject: [PATCH 02/21] Version 1.5 --- main.py | 126 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 75 insertions(+), 51 deletions(-) diff --git a/main.py b/main.py index cc18d2c..36292f8 100644 --- a/main.py +++ b/main.py @@ -9,11 +9,10 @@ import grp # Exit codes used by NZBGet -POSTPROCESS_SUCCESS=93 -POSTPROCESS_ERROR=94 +SCRIPT_SUCCESS=93 +SCRIPT_ERROR=94 # Debug messages from Extension -#check_OS= check_SETTINGS="Check instructions in the extension settings" # Check if all required script config options are present in config file @@ -21,14 +20,36 @@ for optname in required_options: if (not optname in os.environ): print('[ERROR] Option %s is missing in configuration file. Please check script settings' % optname[6:]) - sys.exit(POSTPROCESS_ERROR) + sys.exit(SCRIPT_ERROR) # Check if the script is executed from settings page with a custom command command = os.environ.get("NZBCP_COMMAND") +detect_mode = command == "Detect" test_mode = command == "Test" -if command != None and not test_mode: +if command != None and not any((detect_mode,test_mode)): print('[ERROR] Invalid command ' + command) - sys.exit(COMMAND_ERROR) + sys.exit(SCRIPT_ERROR) + +# Detecting users Owner[UID] and Group[GID], executed from settings page +if detect_mode: + if pwd.getpwuid(os.getuid())[2] is not None: + print("User UID is detected:",[pwd.getpwuid(os.getuid())[2]],) + else: + print("Cannot detect logged in users UID") + check = SCRIPT_ERROR + + if pwd.getpwuid(os.getuid())[3] is not None: + print("Group GID is detected:",[pwd.getpwuid(os.getuid())[3]],) + else: + print("Cannot detect logged in users GID") + check = SCRIPT_ERROR + + try: + check + except NameError: + sys.exit(SCRIPT_SUCCESS) + else: + sys.exit(check) # Counters for added Categories countCategory = 1 @@ -40,81 +61,85 @@ if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: countCategoryExt +=1 - +# Testing the validity of settings, executed from settings page if test_mode: if not os.environ.get("NZBPO_DestDir") == os.environ.get("NZBOP_DestDir"): print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],check_SETTINGS) - check = POSTPROCESS_ERROR - if not re.match('^[0-7]{3}+$', os.environ.get("NZBPO_Access")): + check = SCRIPT_ERROR + if not re.match('^[0-7]{3}$', os.environ.get("NZBPO_Access")): print("Default Category: Invalid Access[mask]:",[os.environ.get("NZBPO_Access")],check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR - if not re.match('^[0-9]*$', os.environ.get("NZBPO_Owner")): + if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Owner")): print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR else: try: pwd.getpwuid(int(os.environ.get("NZBPO_Owner"))) except KeyError: print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR - if not re.match('^[0-9]*$', os.environ.get("NZBPO_Group")): + if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Group")): print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR else: try: grp.getgrgid(int(os.environ.get("NZBPO_Group"))) except KeyError: - print("Default Category: Invalid Group[UID]: Group[UID]",[os.environ.get("NZBPO_Group")],"Group not in system.",check_SETTINGS) - check = POSTPROCESS_ERROR + print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",check_SETTINGS) + check = SCRIPT_ERROR for i in range(1, countCategoryExt): + if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: catextname = os.environ["NZBPO_CategoryExt" + str(i) + ".Name"]; catextdestdir = os.environ["NZBPO_CategoryExt" + str(i) + ".DestDir"]; catextaccess = os.environ["NZBPO_CategoryExt" + str(i) + ".Access"]; catextowner = os.environ["NZBPO_CategoryExt" + str(i) + ".Owner"]; catextgroup = os.environ["NZBPO_CategoryExt" + str(i) + ".Group"]; - if not re.match('^[0-7]{3}+$', catextaccess): + + if not re.match('^[0-7]{3}$', catextaccess): print(catextname,"Category: Invalid Access[mask]:",[catextaccess],check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR - if not re.match('^[0-9]*$', catextowner): + if not re.match('^[0-9]{1,}$', catextowner): print(catextname,"Category: Invalid Owner[UID]:",[catextowner],check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR else: try: pwd.getpwuid(int(catextowner)) except KeyError: print(catextname,"Category: Invalid Owner[UID]:",[catextowner],"User not in system.",check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR - if not re.match('^[0-9]*$', catextgroup): + if not re.match('^[0-9]{1,}$', catextgroup): print(catextname,"Category: Invalid Group[UID]:",[catextgroup],check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR else: try: grp.getgrgid(int(catextgroup)) except KeyError: print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.",check_SETTINGS) - check = POSTPROCESS_ERROR - - countCategoryName = 1 + check = SCRIPT_ERROR + for i in range(1, countCategory): - if catextname == os.environ.get("NZBOP_Category" + str(i) + ".Name") is not None: + if catextname == os.environ.get("NZBOP_Category" + str(i) + ".Name"): if not catextdestdir == os.environ.get("NZBOP_Category" + str(i) + ".DestDir"): print(catextname,"Category: Invalid Path:",[catextdestdir],check_SETTINGS) - check = POSTPROCESS_ERROR - else: - countCategoryName +=1 - if countCategoryName >= countCategoryExt: - print(catextname,"Category: Invalid CategoryExt Name:",[catextname],"Name not same as in CATEGORIES",check_SETTINGS) - check = POSTPROCESS_ERROR + check = SCRIPT_ERROR + + catnames = [] + for i in range(1, countCategory): + catname = os.environ.get("NZBOP_Category" + str(i) + ".Name") + catnames.append(catname) + if not catextname in catnames: + print(catextname,"Category: Invalid CategoryExt Name:",[catextname],"Name not same as in CATEGORIES.",check_SETTINGS) + check = SCRIPT_ERROR try: check except NameError: - sys.exit(POSTPROCESS_SUCCESS) + sys.exit(SCRIPT_SUCCESS) else: sys.exit(check) @@ -141,40 +166,39 @@ group = os.environ['NZBPO_GROUP']; -# If download is an added category, set the related destination dir +# If download is an added category, read in the related values and dir if not category == "": for i in range(1, countCategoryExt): - if category == os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name"): - destdir = os.environ["NZBPO_CategoryExt" + str(i) + ".DestDir"]; - access = os.environ["NZBPO_CategoryExt" + str(i) + ".Access"]; - owner = os.environ["NZBPO_CategoryExt" + str(i) + ".Owner"]; - group = os.environ["NZBPO_CategoryExt" + str(i) + ".Group"]; - + if category == os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name"): + destdir = os.environ["NZBPO_CategoryExt" + str(i) + ".DestDir"]; + access = os.environ["NZBPO_CategoryExt" + str(i) + ".Access"]; + owner = os.environ["NZBPO_CategoryExt" + str(i) + ".Owner"]; + group = os.environ["NZBPO_CategoryExt" + str(i) + ".Group"]; # Check if input values are valid -if not re.match('^[0-7]{3}+$', access): +if not re.match('^[0-7]{3}$', access): print(category,"Category: Invalid Access[mask]:",[access],check_SETTINGS) - sys.exit(POSTPROCESS_ERROR) + sys.exit(SCRIPT_ERROR) -if not re.match('^[0-9]*$', owner): +if not re.match('^[0-9]{1,}$', owner): print(category,"Category: Invalid Owner[UID]:",[owner],check_SETTINGS) - sys.exit(POSTPROCESS_ERROR) + sys.exit(SCRIPT_ERROR) else: try: pwd.getpwuid(int(owner)) except KeyError: print(category,"Category: Invalid Owner[UID]:",[owner],"User not in system.",check_SETTINGS) - sys.exit(POSTPROCESS_ERROR) + sys.exit(SCRIPT_ERROR) -if not re.match('^[0-9]*$', group): +if not re.match('^[0-9]{1,}$', group): print(category,"Category: Invalid Group[UID]:",[group],check_SETTINGS) - sys.exit(POSTPROCESS_ERROR) + sys.exit(SCRIPT_ERROR) else: try: grp.getgrgid(int(group)) except KeyError: print(category,"Category: Invalid Group[UID]:",[group],"Group not in system.",check_SETTINGS) - sys.exit(POSTPROCESS_ERROR) + sys.exit(SCRIPT_ERROR) # Apply chmod & chown to files in destination dir @@ -193,4 +217,4 @@ for f in files : os.chown(os.path.join(root,f), int(owner), int(group)) -sys.exit(POSTPROCESS_SUCCESS) +sys.exit(SCRIPT_SUCCESS) From f398cd8b3a9a39e40f7184eca128a271edc874ea Mon Sep 17 00:00:00 2001 From: big Date: Tue, 6 Aug 2024 15:20:21 +0200 Subject: [PATCH 03/21] Version 1.5 --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e025fd5..10661c4 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,14 @@ This extension requires Python3.8 and above to be installed on your system. ## AccessOwnership This extension modifies access permissions & ownership on downloaded files.
Supports multiple categories and to configure access permissions & ownership separately for each category.
-Built in testfunction to test entered values. +Built in function to test entered values. +Built in function to get UID and GID for NZBGet instance. ## OS Support (so far) Linux / Debian12 +MacOS / 14 ## Installation -For manual installation, unpack 'Extension-AccessOwnership-1.4.zip' into NZBget's scripts folder.
+For manual installation, unpack 'Extension-AccessOwnership-1.5.zip' into NZBget's scripts folder.
Follow instructions here:
https://nzbget.com/documentation/extension-scripts From 7b1eb104917431e1401413eccdb803586f26f165 Mon Sep 17 00:00:00 2001 From: big Date: Tue, 6 Aug 2024 15:21:13 +0200 Subject: [PATCH 04/21] Version 1.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10661c4..ff4eb05 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Built in function to test entered values. Built in function to get UID and GID for NZBGet instance. ## OS Support (so far) -Linux / Debian12 +Linux / Debian12
MacOS / 14 ## Installation From 3d2c2392e9ff39a41161b5cd0e7f389cdc4ef5db Mon Sep 17 00:00:00 2001 From: big Date: Tue, 6 Aug 2024 15:21:59 +0200 Subject: [PATCH 05/21] Version 1.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff4eb05..5b23130 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This extension requires Python3.8 and above to be installed on your system. ## AccessOwnership This extension modifies access permissions & ownership on downloaded files.
Supports multiple categories and to configure access permissions & ownership separately for each category.
-Built in function to test entered values. +Built in function to test entered values.
Built in function to get UID and GID for NZBGet instance. ## OS Support (so far) From af65930d2b04c289031301b0d444823ec3aff1b6 Mon Sep 17 00:00:00 2001 From: big Date: Fri, 25 Oct 2024 20:07:40 +0200 Subject: [PATCH 06/21] Create tasks.yml --- .github/workflows/tasks.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/tasks.yml diff --git a/.github/workflows/tasks.yml b/.github/workflows/tasks.yml new file mode 100644 index 0000000..b11d71b --- /dev/null +++ b/.github/workflows/tasks.yml @@ -0,0 +1,15 @@ +name: extension tasks + +on: + push: + branches: + - main + tags: + - "v*" + +jobs: + prospector: + uses: nzbgetcom/nzbget-extensions/.github/workflows/prospector.yml@main + + manifest: + uses: nzbgetcom/nzbget-extensions/.github/workflows/manifest.yml@main From 36ed8d0df635669ab651fb2bbc0d3be576c7a12d Mon Sep 17 00:00:00 2001 From: big Date: Fri, 25 Oct 2024 20:24:23 +0200 Subject: [PATCH 07/21] Update main.py --- main.py | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/main.py b/main.py index 36292f8..07a67f0 100644 --- a/main.py +++ b/main.py @@ -13,12 +13,12 @@ SCRIPT_ERROR=94 # Debug messages from Extension -check_SETTINGS="Check instructions in the extension settings" +CHECK_SETTINGS="Check instructions in the extension settings" # Check if all required script config options are present in config file required_options = ('NZBPO_DESTDIR', 'NZBPO_ACCESS', 'NZBPO_OWNER', 'NZBPO_GROUP') for optname in required_options: - if (not optname in os.environ): + if (optname not in os.environ): print('[ERROR] Option %s is missing in configuration file. Please check script settings' % optname[6:]) sys.exit(SCRIPT_ERROR) @@ -26,7 +26,7 @@ command = os.environ.get("NZBCP_COMMAND") detect_mode = command == "Detect" test_mode = command == "Test" -if command != None and not any((detect_mode,test_mode)): +if command is not None and not any((detect_mode,test_mode)): print('[ERROR] Invalid command ' + command) sys.exit(SCRIPT_ERROR) @@ -52,42 +52,42 @@ sys.exit(check) # Counters for added Categories -countCategory = 1 +countcategory = 1 for i in range(1, 100): if os.environ.get("NZBOP_Category" + str(i) + ".Name") is not None: - countCategory +=1 -countCategoryExt = 1 + countcategory +=1 +countcategoryext = 1 for i in range(1, 100): if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: - countCategoryExt +=1 + countcategoryext +=1 # Testing the validity of settings, executed from settings page if test_mode: if not os.environ.get("NZBPO_DestDir") == os.environ.get("NZBOP_DestDir"): - print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],check_SETTINGS) + print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],CHECK_SETTINGS) check = SCRIPT_ERROR if not re.match('^[0-7]{3}$', os.environ.get("NZBPO_Access")): - print("Default Category: Invalid Access[mask]:",[os.environ.get("NZBPO_Access")],check_SETTINGS) + print("Default Category: Invalid Access[mask]:",[os.environ.get("NZBPO_Access")],CHECK_SETTINGS) check = SCRIPT_ERROR if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Owner")): - print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],check_SETTINGS) + print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],CHECK_SETTINGS) check = SCRIPT_ERROR else: try: pwd.getpwuid(int(os.environ.get("NZBPO_Owner"))) except KeyError: - print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",check_SETTINGS) + print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Group")): - print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],check_SETTINGS) + print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],CHECK_SETTINGS) check = SCRIPT_ERROR else: try: grp.getgrgid(int(os.environ.get("NZBPO_Group"))) except KeyError: - print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",check_SETTINGS) + print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR for i in range(1, countCategoryExt): @@ -99,41 +99,41 @@ catextgroup = os.environ["NZBPO_CategoryExt" + str(i) + ".Group"]; if not re.match('^[0-7]{3}$', catextaccess): - print(catextname,"Category: Invalid Access[mask]:",[catextaccess],check_SETTINGS) + print(catextname,"Category: Invalid Access[mask]:",[catextaccess],CHECK_SETTINGS) check = SCRIPT_ERROR if not re.match('^[0-9]{1,}$', catextowner): - print(catextname,"Category: Invalid Owner[UID]:",[catextowner],check_SETTINGS) + print(catextname,"Category: Invalid Owner[UID]:",[catextowner],CHECK_SETTINGS) check = SCRIPT_ERROR else: try: pwd.getpwuid(int(catextowner)) except KeyError: - print(catextname,"Category: Invalid Owner[UID]:",[catextowner],"User not in system.",check_SETTINGS) + print(catextname,"Category: Invalid Owner[UID]:",[catextowner],"User not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR if not re.match('^[0-9]{1,}$', catextgroup): - print(catextname,"Category: Invalid Group[UID]:",[catextgroup],check_SETTINGS) + print(catextname,"Category: Invalid Group[UID]:",[catextgroup],CHECK_SETTINGS) check = SCRIPT_ERROR else: try: grp.getgrgid(int(catextgroup)) except KeyError: - print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.",check_SETTINGS) + print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR for i in range(1, countCategory): if catextname == os.environ.get("NZBOP_Category" + str(i) + ".Name"): if not catextdestdir == os.environ.get("NZBOP_Category" + str(i) + ".DestDir"): - print(catextname,"Category: Invalid Path:",[catextdestdir],check_SETTINGS) + print(catextname,"Category: Invalid Path:",[catextdestdir],CHECK_SETTINGS) check = SCRIPT_ERROR catnames = [] for i in range(1, countCategory): catname = os.environ.get("NZBOP_Category" + str(i) + ".Name") catnames.append(catname) - if not catextname in catnames: - print(catextname,"Category: Invalid CategoryExt Name:",[catextname],"Name not same as in CATEGORIES.",check_SETTINGS) + if catextname not in catnames: + print(catextname,"Category: Invalid CategoryExt Name:",[catextname],"Name not same as in CATEGORIES.",CHECK_SETTINGS) check = SCRIPT_ERROR try: @@ -177,27 +177,27 @@ # Check if input values are valid if not re.match('^[0-7]{3}$', access): - print(category,"Category: Invalid Access[mask]:",[access],check_SETTINGS) + print(category,"Category: Invalid Access[mask]:",[access],CHECK_SETTINGS) sys.exit(SCRIPT_ERROR) if not re.match('^[0-9]{1,}$', owner): - print(category,"Category: Invalid Owner[UID]:",[owner],check_SETTINGS) + print(category,"Category: Invalid Owner[UID]:",[owner],CHECK_SETTINGS) sys.exit(SCRIPT_ERROR) else: try: pwd.getpwuid(int(owner)) except KeyError: - print(category,"Category: Invalid Owner[UID]:",[owner],"User not in system.",check_SETTINGS) + print(category,"Category: Invalid Owner[UID]:",[owner],"User not in system.",CHECK_SETTINGS) sys.exit(SCRIPT_ERROR) if not re.match('^[0-9]{1,}$', group): - print(category,"Category: Invalid Group[UID]:",[group],check_SETTINGS) + print(category,"Category: Invalid Group[UID]:",[group],CHECK_SETTINGS) sys.exit(SCRIPT_ERROR) else: try: grp.getgrgid(int(group)) except KeyError: - print(category,"Category: Invalid Group[UID]:",[group],"Group not in system.",check_SETTINGS) + print(category,"Category: Invalid Group[UID]:",[group],"Group not in system.",CHECK_SETTINGS) sys.exit(SCRIPT_ERROR) From 645b959ef039584de4755c5505aca106952d040f Mon Sep 17 00:00:00 2001 From: big Date: Fri, 25 Oct 2024 20:29:58 +0200 Subject: [PATCH 08/21] Update main.py --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 07a67f0..5a1015c 100644 --- a/main.py +++ b/main.py @@ -90,7 +90,7 @@ print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR - for i in range(1, countCategoryExt): + for i in range(1, countcategoryext): if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: catextname = os.environ["NZBPO_CategoryExt" + str(i) + ".Name"]; catextdestdir = os.environ["NZBPO_CategoryExt" + str(i) + ".DestDir"]; @@ -122,14 +122,14 @@ print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR - for i in range(1, countCategory): + for i in range(1, countcategory): if catextname == os.environ.get("NZBOP_Category" + str(i) + ".Name"): if not catextdestdir == os.environ.get("NZBOP_Category" + str(i) + ".DestDir"): print(catextname,"Category: Invalid Path:",[catextdestdir],CHECK_SETTINGS) check = SCRIPT_ERROR catnames = [] - for i in range(1, countCategory): + for i in range(1, countcategory): catname = os.environ.get("NZBOP_Category" + str(i) + ".Name") catnames.append(catname) if catextname not in catnames: @@ -152,7 +152,7 @@ catextaccess = os.environ.get("NZBPO_CATEGORYEXT" + str(i) + "_ACCESS") catextowner = os.environ.get("NZBPO_CATEGORYEXT" + str(i) + "_OWNER") catextgroup = os.environ.get("NZBPO_CATEGORYEXT" + str(i) + "_GROUP") - if catextname == None or catextdestdir == None: + if catextname is None or catextdestdir is None: break categories.append({catextname, catextdestdir, catextaccess, catextowner, catextgroup}) @@ -168,7 +168,7 @@ # If download is an added category, read in the related values and dir if not category == "": - for i in range(1, countCategoryExt): + for i in range(1, countcategoryext): if category == os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name"): destdir = os.environ["NZBPO_CategoryExt" + str(i) + ".DestDir"]; access = os.environ["NZBPO_CategoryExt" + str(i) + ".Access"]; From 76701fef31bc6e9927fe62db81d16b5095edc987 Mon Sep 17 00:00:00 2001 From: big Date: Fri, 25 Oct 2024 20:57:30 +0200 Subject: [PATCH 09/21] Update main.py --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 5a1015c..12e416b 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,7 @@ required_options = ('NZBPO_DESTDIR', 'NZBPO_ACCESS', 'NZBPO_OWNER', 'NZBPO_GROUP') for optname in required_options: if (optname not in os.environ): - print('[ERROR] Option %s is missing in configuration file. Please check script settings' % optname[6:]) + print(f"[ERROR] Option {optname[6:]} is missing in configuration file. Please check script settings") sys.exit(SCRIPT_ERROR) # Check if the script is executed from settings page with a custom command From cffb98c8a4b485c5348b49aa5d4ef946f7dc4b6f Mon Sep 17 00:00:00 2001 From: big Date: Sat, 26 Oct 2024 09:38:56 +0200 Subject: [PATCH 10/21] Update main.py --- main.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 12e416b..e32817f 100644 --- a/main.py +++ b/main.py @@ -34,22 +34,19 @@ if detect_mode: if pwd.getpwuid(os.getuid())[2] is not None: print("User UID is detected:",[pwd.getpwuid(os.getuid())[2]],) + check = SCRIPT_SUCCESS else: print("Cannot detect logged in users UID") check = SCRIPT_ERROR if pwd.getpwuid(os.getuid())[3] is not None: print("Group GID is detected:",[pwd.getpwuid(os.getuid())[3]],) + check = SCRIPT_SUCCESS else: print("Cannot detect logged in users GID") check = SCRIPT_ERROR - try: - check - except NameError: - sys.exit(SCRIPT_SUCCESS) - else: - sys.exit(check) + sys.exit(check) # Counters for added Categories countcategory = 1 From 06a2e7b92ac42c7f789cbb323e2e022b10baf57b Mon Sep 17 00:00:00 2001 From: big Date: Sat, 26 Oct 2024 10:26:04 +0200 Subject: [PATCH 11/21] Update main.py --- main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index e32817f..04bba6d 100644 --- a/main.py +++ b/main.py @@ -59,14 +59,17 @@ countcategoryext +=1 # Testing the validity of settings, executed from settings page -if test_mode: +def testpath(): if not os.environ.get("NZBPO_DestDir") == os.environ.get("NZBOP_DestDir"): print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],CHECK_SETTINGS) check = SCRIPT_ERROR + +def testaccess(): if not re.match('^[0-7]{3}$', os.environ.get("NZBPO_Access")): print("Default Category: Invalid Access[mask]:",[os.environ.get("NZBPO_Access")],CHECK_SETTINGS) check = SCRIPT_ERROR +def testowner(): if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Owner")): print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],CHECK_SETTINGS) check = SCRIPT_ERROR @@ -77,6 +80,7 @@ print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR +def testgroup(): if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Group")): print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],CHECK_SETTINGS) check = SCRIPT_ERROR @@ -87,6 +91,12 @@ print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR +if test_mode: + testpath() + testaccess() + testowner() + testgroup() + for i in range(1, countcategoryext): if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: catextname = os.environ["NZBPO_CategoryExt" + str(i) + ".Name"]; From 62e50b462b583d31c61d16d4be790fe565f865ca Mon Sep 17 00:00:00 2001 From: big Date: Sat, 26 Oct 2024 10:44:41 +0200 Subject: [PATCH 12/21] Update main.py --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 04bba6d..8024561 100644 --- a/main.py +++ b/main.py @@ -59,6 +59,7 @@ countcategoryext +=1 # Testing the validity of settings, executed from settings page +check = SCRIPT_SUCCESS def testpath(): if not os.environ.get("NZBPO_DestDir") == os.environ.get("NZBOP_DestDir"): print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],CHECK_SETTINGS) From ee382d3e2a6db6eafbe438e76685f8dccc42c420 Mon Sep 17 00:00:00 2001 From: big Date: Sat, 26 Oct 2024 10:57:20 +0200 Subject: [PATCH 13/21] Update main.py --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 8024561..5044f05 100644 --- a/main.py +++ b/main.py @@ -59,16 +59,19 @@ countcategoryext +=1 # Testing the validity of settings, executed from settings page -check = SCRIPT_SUCCESS def testpath(): if not os.environ.get("NZBPO_DestDir") == os.environ.get("NZBOP_DestDir"): print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],CHECK_SETTINGS) check = SCRIPT_ERROR + else: + check = SCRIPT_SUCCESS def testaccess(): if not re.match('^[0-7]{3}$', os.environ.get("NZBPO_Access")): print("Default Category: Invalid Access[mask]:",[os.environ.get("NZBPO_Access")],CHECK_SETTINGS) check = SCRIPT_ERROR + else: + check = SCRIPT_SUCCESS def testowner(): if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Owner")): @@ -80,6 +83,8 @@ def testowner(): except KeyError: print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR + else: + check = SCRIPT_SUCCESS def testgroup(): if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Group")): @@ -91,8 +96,11 @@ def testgroup(): except KeyError: print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR + else: + check = SCRIPT_SUCCESS if test_mode: + testpath() testaccess() testowner() From 667fbd0878ae7185838ddbf0040f2db6db5e87f5 Mon Sep 17 00:00:00 2001 From: big Date: Sat, 26 Oct 2024 11:09:53 +0200 Subject: [PATCH 14/21] Update main.py --- main.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index 5044f05..12e416b 100644 --- a/main.py +++ b/main.py @@ -34,19 +34,22 @@ if detect_mode: if pwd.getpwuid(os.getuid())[2] is not None: print("User UID is detected:",[pwd.getpwuid(os.getuid())[2]],) - check = SCRIPT_SUCCESS else: print("Cannot detect logged in users UID") check = SCRIPT_ERROR if pwd.getpwuid(os.getuid())[3] is not None: print("Group GID is detected:",[pwd.getpwuid(os.getuid())[3]],) - check = SCRIPT_SUCCESS else: print("Cannot detect logged in users GID") check = SCRIPT_ERROR - sys.exit(check) + try: + check + except NameError: + sys.exit(SCRIPT_SUCCESS) + else: + sys.exit(check) # Counters for added Categories countcategory = 1 @@ -59,21 +62,14 @@ countcategoryext +=1 # Testing the validity of settings, executed from settings page -def testpath(): +if test_mode: if not os.environ.get("NZBPO_DestDir") == os.environ.get("NZBOP_DestDir"): print("Default Category: Invalid Path:",[os.environ.get("NZBPO_DestDir")],CHECK_SETTINGS) check = SCRIPT_ERROR - else: - check = SCRIPT_SUCCESS - -def testaccess(): if not re.match('^[0-7]{3}$', os.environ.get("NZBPO_Access")): print("Default Category: Invalid Access[mask]:",[os.environ.get("NZBPO_Access")],CHECK_SETTINGS) check = SCRIPT_ERROR - else: - check = SCRIPT_SUCCESS -def testowner(): if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Owner")): print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],CHECK_SETTINGS) check = SCRIPT_ERROR @@ -83,10 +79,7 @@ def testowner(): except KeyError: print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR - else: - check = SCRIPT_SUCCESS -def testgroup(): if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Group")): print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],CHECK_SETTINGS) check = SCRIPT_ERROR @@ -96,15 +89,6 @@ def testgroup(): except KeyError: print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) check = SCRIPT_ERROR - else: - check = SCRIPT_SUCCESS - -if test_mode: - - testpath() - testaccess() - testowner() - testgroup() for i in range(1, countcategoryext): if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: From 7234961320458b946f22a290eab28c249c7fda3f Mon Sep 17 00:00:00 2001 From: big Date: Sun, 17 Nov 2024 04:46:04 +0100 Subject: [PATCH 15/21] Delete .github/workflows directory --- .github/workflows/tasks.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/workflows/tasks.yml diff --git a/.github/workflows/tasks.yml b/.github/workflows/tasks.yml deleted file mode 100644 index b11d71b..0000000 --- a/.github/workflows/tasks.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: extension tasks - -on: - push: - branches: - - main - tags: - - "v*" - -jobs: - prospector: - uses: nzbgetcom/nzbget-extensions/.github/workflows/prospector.yml@main - - manifest: - uses: nzbgetcom/nzbget-extensions/.github/workflows/manifest.yml@main From dac93cd9f5ee79206b1fc2a5e5b62635f7054e7e Mon Sep 17 00:00:00 2001 From: big Date: Sun, 17 Nov 2024 10:20:17 +0100 Subject: [PATCH 16/21] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b23130..8fb929e 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ Supports multiple categories and to configure access permissions & ownership sep Built in function to test entered values.
Built in function to get UID and GID for NZBGet instance. + ## OS Support (so far) Linux / Debian12
MacOS / 14 +Docker ## Installation -For manual installation, unpack 'Extension-AccessOwnership-1.5.zip' into NZBget's scripts folder.
+For manual installation, unpack 'Extension-AccessOwnership-1.6.zip' into NZBget's scripts folder.
Follow instructions here:
https://nzbget.com/documentation/extension-scripts From a1905e2f81f78d2fed50a3ca0c99994e927f5e38 Mon Sep 17 00:00:00 2001 From: big Date: Sun, 17 Nov 2024 10:20:36 +0100 Subject: [PATCH 17/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fb929e..060869d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Built in function to get UID and GID for NZBGet instance. ## OS Support (so far) Linux / Debian12
-MacOS / 14 +MacOS / 14
Docker ## Installation From 55952e7ab65ca1d83283cdd054aba880fbc97b17 Mon Sep 17 00:00:00 2001 From: big Date: Sun, 17 Nov 2024 10:21:29 +0100 Subject: [PATCH 18/21] Update main.py --- main.py | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 12e416b..bdf1e69 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ CHECK_SETTINGS="Check instructions in the extension settings" # Check if all required script config options are present in config file -required_options = ('NZBPO_DESTDIR', 'NZBPO_ACCESS', 'NZBPO_OWNER', 'NZBPO_GROUP') +required_options = ('NZBPO_DESTDIR', 'NZBPO_ACCESS', 'NZBPO_OWNER', 'NZBPO_GROUP', 'NZBPO_OVERRIDEID') for optname in required_options: if (optname not in os.environ): print(f"[ERROR] Option {optname[6:]} is missing in configuration file. Please check script settings") @@ -30,6 +30,9 @@ print('[ERROR] Invalid command ' + command) sys.exit(SCRIPT_ERROR) +# Override and debugging +overrideid = os.environ['NZBPO_OVERRIDEID']; + # Detecting users Owner[UID] and Group[GID], executed from settings page if detect_mode: if pwd.getpwuid(os.getuid())[2] is not None: @@ -77,8 +80,11 @@ try: pwd.getpwuid(int(os.environ.get("NZBPO_Owner"))) except KeyError: - print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",CHECK_SETTINGS) - check = SCRIPT_ERROR + if overrideid == "yes": + print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"<- ENABLED!!") + else: + print("Default Category: Invalid Owner[UID]:",[os.environ.get("NZBPO_Owner")],"User not in system.",CHECK_SETTINGS) + check = SCRIPT_ERROR if not re.match('^[0-9]{1,}$', os.environ.get("NZBPO_Group")): print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],CHECK_SETTINGS) @@ -87,8 +93,11 @@ try: grp.getgrgid(int(os.environ.get("NZBPO_Group"))) except KeyError: - print("Default Category: Invalid Group[GID]: Group[GID]",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) - check = SCRIPT_ERROR + if overrideid == "yes": + print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],"<- ENABLED!!") + else: + print("Default Category: Invalid Group[GID]:",[os.environ.get("NZBPO_Group")],"Group not in system.",CHECK_SETTINGS) + check = SCRIPT_ERROR for i in range(1, countcategoryext): if os.environ.get("NZBPO_CategoryExt" + str(i) + ".Name") is not None: @@ -109,8 +118,11 @@ try: pwd.getpwuid(int(catextowner)) except KeyError: - print(catextname,"Category: Invalid Owner[UID]:",[catextowner],"User not in system.",CHECK_SETTINGS) - check = SCRIPT_ERROR + if overrideid == "yes": + print(catextname,"Category: Invalid Owner[UID]:",[catextowner],"User not in system.","<- ENABLED!!") + else: + print(catextname,"Category: Invalid Owner[UID]:",[catextowner],"User not in system.",CHECK_SETTINGS) + check = SCRIPT_ERROR if not re.match('^[0-9]{1,}$', catextgroup): print(catextname,"Category: Invalid Group[UID]:",[catextgroup],CHECK_SETTINGS) @@ -119,8 +131,11 @@ try: grp.getgrgid(int(catextgroup)) except KeyError: - print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.",CHECK_SETTINGS) - check = SCRIPT_ERROR + if overrideid == "yes": + print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.","<- ENABLED!!") + else: + print(catextname,"Category: Invalid Group[UID]:",[catextgroup],"Group not in system.",CHECK_SETTINGS) + check = SCRIPT_ERROR for i in range(1, countcategory): if catextname == os.environ.get("NZBOP_Category" + str(i) + ".Name"): @@ -187,8 +202,11 @@ try: pwd.getpwuid(int(owner)) except KeyError: - print(category,"Category: Invalid Owner[UID]:",[owner],"User not in system.",CHECK_SETTINGS) - sys.exit(SCRIPT_ERROR) + if overrideid == "yes": + print(category,"Category: Invalid Owner[UID]:",[owner],"User not in system.","<- ENABLED!!") + else: + print(category,"Category: Invalid Owner[UID]:",[owner],"User not in system.",CHECK_SETTINGS) + sys.exit(SCRIPT_ERROR) if not re.match('^[0-9]{1,}$', group): print(category,"Category: Invalid Group[UID]:",[group],CHECK_SETTINGS) @@ -197,8 +215,11 @@ try: grp.getgrgid(int(group)) except KeyError: - print(category,"Category: Invalid Group[UID]:",[group],"Group not in system.",CHECK_SETTINGS) - sys.exit(SCRIPT_ERROR) + if overrideid == "yes": + print(category,"Category: Invalid Group[UID]:",[group],"Group not in system.","<- ENABLED!!") + else: + print(category,"Category: Invalid Group[UID]:",[group],"Group not in system.",CHECK_SETTINGS) + sys.exit(SCRIPT_ERROR) # Apply chmod & chown to files in destination dir From f5f90379776ed02a3225ff336faf1e946a9fc329 Mon Sep 17 00:00:00 2001 From: big Date: Sun, 17 Nov 2024 10:21:55 +0100 Subject: [PATCH 19/21] Update manifest.json --- manifest.json | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index 30a3a81..68d4ce1 100644 --- a/manifest.json +++ b/manifest.json @@ -1,26 +1,37 @@ { "main": "main.py", "name": "AccessOwnership", - "homepage": "https://github.com/nzbgetcom/Extension-AccessOwnership", + "homepage": "https://github.com/Lennong/Extension-AccessOwnership", "kind": "POST-PROCESSING", "displayName": "AccessOwnership", - "version": "1.5", + "version": "1.6", "nzbgetMinVersion": "24", "author": "Lennong", "license": "GNU", - "about": "Sets access permissions & ownership to downloaded files.", + "about": "Sets access permissions & ownership to downloaded files", "queueEvents": "", "requirements": [ "This extension is compatible with NZBGet v24+.", "This extension requires Python3.8 and up to be installed on your system.", - "This extension is supported on [Linux, MacOS].", + "This extension is supported on [Linux, MacOS, Docker].", "", - "Start initial configuration of this extension by save and reload one time!" + "START INITIAL CONFIGURATION OF THIS EXTENSION BY SAVE AND RELOAD ONE TIME!" ], "description": [ "This script modifies access permissions & ownership on downloaded files." ], "options": [ + { + "name": "OverrideID", + "displayName": "Override UID and GID", + "value": "no", + "description": [ + "To override UID or GID check and allow non-system present UID and GID to be set on downloaded files", + "", + "NOTE: WARNING! Only use this if you know what you are doing!" + ], + "select": ["no", "yes"] + }, { "name": "DestDir", "displayName": "DestDir", From 7b359d92f0c3db68e3fe9607d85416b5c5617794 Mon Sep 17 00:00:00 2001 From: big Date: Wed, 1 Apr 2026 21:07:16 +0200 Subject: [PATCH 20/21] Update OS support from Debian 12 to 13 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 060869d..8cf6a1d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Built in function to get UID and GID for NZBGet instance. ## OS Support (so far) -Linux / Debian12
+Linux / Debian13
MacOS / 14
Docker From c23cb1e72552eb131edd47151fbd866cce7f65dd Mon Sep 17 00:00:00 2001 From: big Date: Thu, 2 Apr 2026 12:51:40 +0200 Subject: [PATCH 21/21] Refactor user UID and GID detection logic Added try...except KeyError block to avoid script crash when a dictionary key is not found. --- main.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index bdf1e69..68ec7b9 100644 --- a/main.py +++ b/main.py @@ -35,24 +35,27 @@ # Detecting users Owner[UID] and Group[GID], executed from settings page if detect_mode: - if pwd.getpwuid(os.getuid())[2] is not None: - print("User UID is detected:",[pwd.getpwuid(os.getuid())[2]],) - else: - print("Cannot detect logged in users UID") - check = SCRIPT_ERROR + try: + if pwd.getpwuid(os.getuid())[2] is not None: + print("User UID is detected:",[pwd.getpwuid(os.getuid())[2]],) + else: + print("Cannot detect logged in users UID") + check = SCRIPT_ERROR - if pwd.getpwuid(os.getuid())[3] is not None: - print("Group GID is detected:",[pwd.getpwuid(os.getuid())[3]],) - else: - print("Cannot detect logged in users GID") - check = SCRIPT_ERROR + if pwd.getpwuid(os.getuid())[3] is not None: + print("Group GID is detected:",[pwd.getpwuid(os.getuid())[3]],) + else: + print("Cannot detect logged in users GID") + check = SCRIPT_ERROR - try: - check - except NameError: - sys.exit(SCRIPT_SUCCESS) - else: - sys.exit(check) + try: + check + except NameError: + sys.exit(SCRIPT_SUCCESS) + else: + sys.exit(check) + except KeyError: + print("The requested key was not found.") # Counters for added Categories countcategory = 1