Sort queue according to file size when nzb is added (3rd)

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
gohakn
Newbie
Newbie
Posts: 17
Joined: August 3rd, 2022, 10:39 am

Sort queue according to file size when nzb is added (3rd)

Post by gohakn »

Again after updating sabnzbd to 4.2.1 on my Synology DS1817+ my prequeue Script priorising files < 50 MB stopped working.

Following safihres hint to the changelog and the wiki i tried the code from the 'example2' but added files smaller 50MB won't get priorised.

Code: Select all

import sys

try:
    # Parse the input variables for SABnzbd version >= 4.2.0
    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist) = sys.argv
except Exception:
    sys.exit(1)  # a non-zero exit status causes SABnzbd to ignore the output of this script

prio = -100  # Default
if int(downloadsize) < 50*1024**2:
    prio = 2

print("1")  # Accept the job
print()
print()
print()
print()
print(prio)
print()

# 0 means OK
sys.exit(0)
According to the older Thread 25935 from April 2023 i tried

- adding #!/usr/bin/python3 to my script but there is no change.
- changing if int(downloadsize) < 50*1024**2: with if int(downloadsize) < 50111222:
Here is what happens if I add a File15MB to the queue and what the log file is showing:

Code: Select all

2024-01-13 16:36:49,755::INFO::[nzbparser:81] Attempting to add File15MB.nzb [/volume1/UpDownload/Horcher/File15MB.nzb]
2024-01-13 16:36:49,756::INFO::[filesystem:737] Creating directories: /volume1/UpDownload/Temp/File15MB
2024-01-13 16:36:49,757::INFO::[filesystem:737] Creating directories: /volume1/UpDownload/Temp/File15MB/__ADMIN__
2024-01-13 16:36:49,758::INFO::[filesystem:1230] Saving /volume1/UpDownload/Temp/File15MB/__ADMIN__/File15MB.nzb.gz
2024-01-13 16:36:49,760::DEBUG::[nzbparser:394] NZB file meta-data = {'password': ['RsvXPMsafGIvjhnUQ5tHVV']}
2024-01-13 16:36:49,762::INFO::[nzbstuff:960] File <HASH><HASH>.par2 added to queue
2024-01-13 16:36:49,763::INFO::[nzbstuff:960] File <HASH><HASH>.vol000+01.par2 added to queue
2024-01-13 16:36:49,764::INFO::[nzbstuff:960] File <HASH><HASH>.vol001+02.par2 added to queue
2024-01-13 16:36:49,767::INFO::[nzbstuff:960] File <HASH><HASH>.vol003+04.par2 added to queue
2024-01-13 16:36:49,768::INFO::[nzbstuff:960] File <HASH><HASH>.vol007+08.par2 added to queue
2024-01-13 16:36:49,769::INFO::[nzbstuff:960] File <HASH><HASH>.vol031+32.par2 added to queue
2024-01-13 16:36:49,770::INFO::[nzbstuff:960] File <HASH><HASH>.vol127+33.par2 added to queue
2024-01-13 16:36:49,772::INFO::[nzbstuff:960] File <HASH><HASH>.vol015+16.par2 added to queue
2024-01-13 16:36:49,773::INFO::[nzbstuff:960] File <HASH><HASH>.vol063+64.par2 added to queue
2024-01-13 16:36:49,774::DEBUG::[filesystem:1121] [sabnzbd.nzbstuff.__init__] Saving data for SABnzbd_nzf_94e4zb1k in /volume1/UpDownload/Temp/File15MB/__ADMIN__
2024-01-13 16:36:49,775::INFO::[nzbstuff:960] File <HASH><HASH>.rar added to queue
2024-01-13 16:36:49,776::DEBUG::[misc:260] Parsing category * to attributes: pp=3 script=None prio=0
2024-01-13 16:36:49,804::DEBUG::[sorting:657] Initial guess for File15MB is MatchesDict([('title', 'File15MB'), ('type', 'movie')])
2024-01-13 16:36:49,805::INFO::[misc:1185] [sabnzbd.newsunpack.pre_queue] Running external command: ['/volume1/@appstore/sabnzbd/bin/nice', '-n15', '/volume1/@appstore/sabnzbd/bin/ionice', '-c2', '-n4', '/volume1/@appdata/sabnzbd/@script_dir@/fileprio4', 'File15MB / RsvXPMsafGIvjhnUQ5tHVV', '', '', '', '', '14103898', 'alt.binaries.bloaf']
2024-01-13 16:36:49,806::DEBUG::[misc:1186] Popen arguments: {'stdout': -1, 'stderr': -2, 'bufsize': 0, 'startupinfo': None, 'creationflags': 0, 'text': True, 'encoding': 'utf8', 'errors': 'replace', 'env': {'SYNOPKG_TEMP_UPGRADE_FOLDER': '/volume1/@tmp/synopkg.tmp/sabnzbd', 'SYNOPKG_PKGVAR': '/volume1/@appdata/sabnzbd', 'SYNOPKG_PKGPORT': '8080', 'SYNOPKG_PKGSHARE': '/volume1/@appshare/sabnzbd', 'SYNOPKG_USERNAME': 'admin', 'SYNOPKG_PKGNAME': 'sabnzbd', 'SYNOPKG_DSM_VERSION_MAJOR': '7', 'SYNOPKG_PKGHOME': '/volume1/@apphome/sabnzbd', 'SYNOPKG_DSM_VERSION_MINOR': '2', 'SYNOPKG_PKGTMP': '/volume1/@apptemp/sabnzbd', 'SYNOPKG_DSM_VERSION_BUILD': '69057', 'SELF': 'sabnzbd', 'PWD': '/', 'SYNOPKG_TEMP_REPLACE_FOLDER': '/volume1/@tmp/synopkg.tmp/sabnzbd', 'SYNOPKG_PKGVER': '4.2.1-67', 'SYNOPKG_DSM_LANGUAGE': 'ger', 'SYNOPKG_DSM_ARCH': 'avoton', 'SYNOPKG_PKG_PROGRESS_PATH': '/tmp/install_progress_sabnzbd', 'SYNOPKG_PKGDEST_VOL': '/volume1', 'SHLVL': '2', 'SYNOPKG_PKG_STATUS': 'UPGRADE', 'PATH': '/volume1/@appstore/sabnzbd/env/bin:/volume1/@appstore/sabnzbd/bin:/var/packages/python311/target/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin', 'SYNOPKG_TEMP_LOGFILE': '/tmp/synopkgmgr.log-sabnzbd', 'SYNOPKG_PKGDEST': '/volume1/@appstore/sabnzbd', '_': '/bin/env', 'LANG': 'en_US.UTF-8', 'AVAHI_COMPAT_NOWARN': '1', 'SSL_CERT_FILE': '/var/packages/python311/target/lib/python3.11/site-packages/certifi/cacert.pem', 'SAB_BYTES': '14103898', 'SAB_BYTES_DOWNLOADED': '0', 'SAB_BYTES_TRIED': '0', 'SAB_CAT': '*', 'SAB_CORRECT_PASSWORD': '', 'SAB_DUPLICATE': '', 'SAB_DUPLICATE_KEY': '', 'SAB_ENCRYPTED': '0', 'SAB_FAIL_MSG': '', 'SAB_FILENAME': 'File15MB.nzb', 'SAB_FINAL_NAME': 'File15MB', 'SAB_GROUP': 'alt.binaries.bloaf', 'SAB_NZO_ID': '', 'SAB_OVERSIZED': '0', 'SAB_PASSWORD': 'RsvXPMsafGIvjhnUQ5tHVV', 'SAB_PP': '3', 'SAB_PRIORITY': '0', 'SAB_REPAIR': '1', 'SAB_SCRIPT': 'None', 'SAB_STATUS': 'Queued', 'SAB_UNPACK': '1', 'SAB_UNWANTED_EXT': '0', 'SAB_URL': '', 'SAB_GROUPS': 'alt.binaries.bloaf', 'SAB_TITLE': 'File15MB', 'SAB_SEASON': '', 'SAB_EPISODE': '', 'SAB_EPISODE_NAME': '', 'SAB_IS_PROPER': 'False', 'SAB_RESOLUTION': '', 'SAB_DECADE': '', 'SAB_YEAR': '', 'SAB_MONTH': '', 'SAB_DAY': '', 'SAB_JOB_TYPE': 'unknown', 'SAB_PROGRAM_DIR': '/volume1/@appstore/sabnzbd/share/SABnzbd', 'SAB_PAR2_COMMAND': '/volume1/@appstore/sabnzbd/bin/par2', 'SAB_MULTIPAR_COMMAND': '', 'SAB_RAR_COMMAND': '/volume1/@appstore/sabnzbd/bin/unrar', 'SAB_7ZIP_COMMAND': '/volume1/@appstore/sabnzbd/bin/7za', 'SAB_VERSION': '4.2.1'}}
2024-01-13 16:36:49,823::INFO::[newsunpack:2192] Pre-queue script returned 2 and output=
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 1: import: command not found
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 3: try:: command not found
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 5: syntax error near unexpected token `='
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 5: `    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist) = sys.argv'

2024-01-13 16:36:49,824::INFO::[newsunpack:2217] Pre-Q accepts File15MB
2024-01-13 16:36:49,824::DEBUG::[nzbstuff:1870] Saving attributes {'cat': '*', 'pp': 3, 'script': 'None', 'priority': 0, 'final_name': 'File15MB', 'REMOVED': '<REMOVED>', 'url': None} for File15MB
2024-01-13 16:36:49,826::DEBUG::[misc:260] Parsing category * to attributes: pp=3 script=None prio=0
2024-01-13 16:36:49,827::DEBUG::[nzbstuff:930] NZB nzo-info = {'REMOVED': '<REMOVED>'}
2024-01-13 16:36:49,828::INFO::[nzbqueue:230] Saving queue
2024-01-13 16:36:49,828::DEBUG::[nzbstuff:1870] Saving attributes {'cat': '*', 'pp': 3, 'script': 'None', 'priority': 0, 'final_name': 'File15MB', 'REMOVED': '<REMOVED>', 'url': None} for File15MB
2024-01-13 16:36:49,829::DEBUG::[filesystem:1121] [sabnzbd.nzbstuff.save_to_disk] Saving data for SABnzbd_nzo_s8ert2n0 in /volume1/UpDownload/Temp/File15MB/__ADMIN__
2024-01-13 16:36:49,831::DEBUG::[filesystem:1189] [sabnzbd.nzbqueue.save] Saving data for queue10.sab
But what is leading to this reaction

Code: Select all

2024-01-13 16:36:49,823::INFO::[newsunpack:2192] Pre-queue script returned 2 and output=
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 1: import: command not found
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 3: try:: command not found
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 5: syntax error near unexpected token `='
/volume1/@appdata/sabnzbd/@script_dir@/fileprio4: line 5: `    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist) = sys.argv'
gohakn
Newbie
Newbie
Posts: 17
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (3rd)

Post by gohakn »

After searching inside /usr/bin/ at my NAS I found the following "Link?" from python3 -> python3.8.

Image

So I changed the first line in the script to #!/usr/bin/python3.8 and now it's working again. ;D

Is this a type of "Link" and why did it work under sabnzbd 4.1.0??
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: Sort queue according to file size when nzb is added (3rd)

Post by sander »

Good that it works.

Nothing to do with SABnzb version.

The errors you got were because your python script was executed as a sh / bash script (which is default) ... which doesn't work. Note: On Linux/Unix, the extension (like .py) does not matter.

You must put the shebang at the top of the file.
Universal is: #!/usr/bin/env python3
Post Reply