Sort queue according to file size when nzb is added (The 2nd)

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: 8
Joined: August 3rd, 2022, 10:39 am

Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

I have the same problem/wish like @hyptonize wrote in his 2010 Thread about setting a priority to new added nzb`s depending on their filesize..

( old Thread) Nr. #p109510

Safihre showed up a link to the wiki about pre-queue Scripts and this is where i stuck at the moment...

::) / wiki/ scripts/ pre-queue-scripts

According to the "Example Script 2" I`ve created a script with the shown code, in the specific folder, set it as executable, etc..
Inside Sabnzbd i can activate the script in the Config -> switches area, but then after adding a file < 50MB to the queue nothing happens...
The file is sorted at the end and starts downloading with the same "Normal" priority like all "Normal" Files inside the queue.

Sabnzbd ( 3.6.0) is running on a Synology NAS.

Any Ideas for solving this problem.?

Thank you

User avatar
safihre
Administrator
Administrator
Posts: 4790
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by safihre »

Maybe remind me, but why nog just use the Auto sort function in Config Switches? It allows to auto sort based on side after adding each new NZB.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

First, thank you for the good idaea which may probably work.
But It will also sort all files > 50 MB in the chosen direction and not only small files beeing added later.

And the second thing it doesn`t help me to figure out what`s wrong with this EXAMPLE 2 Script... ???

import sys

try:
(scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv
downloadsize = int(downloadsize)
except:
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script

prio = -100 # Default
if downloadsize > 50111222:
prio = 2



Is there any .log file I could submit to help me clearing this problem.?

User avatar
safihre
Administrator
Administrator
Posts: 4790
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by safihre »

Could you paste the full script in the special code blocks?
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

It was your link to the wiki in Post #109511 to the wiki

**##sabnzbd*org/wiki/scripts/pre-queue-scripts



Example Script 2

A python script to set prio to Force on downloads smaller than 50MB:

import sys

try:
(scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv
downloadsize = int(downloadsize)
except:
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script

prio = -100 # Default
if downloadsize > 50111222:
prio = 2

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

# 0 means OK
sys.exit(0)

User avatar
safihre
Administrator
Administrator
Posts: 4790
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by safihre »

Ah. Then enable Debug logging in the Status window and then after it happens again click Show Logging, it will show exactly how it processed the script and categories prio etc
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

I Think it happens at 2022-08-05 18:45:16,133

Code: Select all

2022-08-05 18:45:14,578::DEBUG::[interface:133] Request GET /api from 192.168.123.41 [Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0] {'mode': 'queue', 'search': '', 'start': '0', 'limit': '250', 'output': 'json', 'apikey':<APIKEY>', '_': '1659717835313'}
2022-08-05 18:45:14,781::INFO::[dirscanner:163] Trying to import /volume1/UpDownload/Horcher/0508 Neue Zurcher Zeitung 2022{{MW6BlHuO9Da1gkjqGw3Ta2}}.nzb
2022-08-05 18:45:15,608::DEBUG::[interface:133] Request GET /api from 192.168.123.41 [Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0] {'mode': 'queue', 'search': '', 'start': '0', 'limit': '250', 'output': 'json', 'apikey':<APIKEY>', '_': '1659717835315'}
2022-08-05 18:45:15,611::DEBUG::[interface:133] Request GET /api from 192.168.123.41 [Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0] {'mode': 'history', 'search': '', 'failed_only': '0', 'start': '0', 'limit': '250', 'last_history_update': '2769', 'output': 'json', 'apikey':<APIKEY>', '_': '1659717835316'}
2022-08-05 18:45:15,783::INFO::[nzbparser:84] Attempting to add 0508 Neue Zurcher Zeitung 2022{{MW6BlHuO9Da1gkjqGw3Ta2}}.nzb [/volume1/UpDownload/Horcher/0508 Neue Zurcher Zeitung 2022{{MW6BlHuO9Da1gkjqGw3Ta2}}.nzb]
2022-08-05 18:45:15,784::INFO::[filesystem:703] Creating directories: /volume1/UpDownload/Temp/0508 Neue Zurcher Zeitung 2022
2022-08-05 18:45:15,785::INFO::[filesystem:703] Creating directories: /volume1/UpDownload/Temp/0508 Neue Zurcher Zeitung 2022/__ADMIN__
2022-08-05 18:45:15,785::INFO::[filesystem:1233] Saving /volume1/UpDownload/Temp/0508 Neue Zurcher Zeitung 2022/__ADMIN__/0508 Neue Zurcher Zeitung 2022{{MW6BlHuO9Da1gkjqGw3Ta2}}.nzb.gz
2022-08-05 18:45:15,787::DEBUG::[nzbparser:399] NZB file meta-data = {'password': ['MW6BlHuO9Da1gkjqGw3Ta2']}
2022-08-05 18:45:15,801::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.par2 added to queue
2022-08-05 18:45:15,802::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol000+01.par2 added to queue
2022-08-05 18:45:15,803::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol003+04.par2 added to queue
2022-08-05 18:45:15,804::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol007+08.par2 added to queue
2022-08-05 18:45:15,805::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol001+02.par2 added to queue
2022-08-05 18:45:15,806::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol015+16.par2 added to queue
2022-08-05 18:45:15,807::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol031+32.par2 added to queue
2022-08-05 18:45:15,808::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol127+33.par2 added to queue
2022-08-05 18:45:15,809::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.vol063+64.par2 added to queue
2022-08-05 18:45:16,070::DEBUG::[filesystem:1110] [sabnzbd.nzbstuff.__init__] Saving data for SABnzbd_nzf_bfnimhs6 in /volume1/UpDownload/Temp/0508 Neue Zurcher Zeitung 2022/__ADMIN__
2022-08-05 18:45:16,071::INFO::[nzbparser:477] File WUfcXow5wZhA81e9I6KiYuSekKa9lPx0kX44tCV2KLpM6OlERc.rar added to queue
2022-08-05 18:45:16,071::DEBUG::[misc:215] Parsing category * to attributes: pp=3 script=None prio=0
2022-08-05 18:45:16,131::DEBUG::[sorting:610] Initial guess for FIX0508 Neue Zurcher Zeitung 2022 is MatchesDict([('title', 'FIX0508 Neue Zurcher Zeitung'), ('year', 2022), ('type', 'episode')])
2022-08-05 18:45:16,131::DEBUG::[sorting:364] Using tv sorter for 0508 Neue Zurcher Zeitung 2022 / MW6BlHuO9Da1gkjqGw3Ta2
2022-08-05 18:45:16,132::INFO::[misc:1163] [sabnzbd.newsunpack.pre_queue] Running external command: ['/volume1/@appstore/sabnzbd/bin/nice', '-n15', '/volume1/@appstore/sabnzbd/bin/ionice', '-c2', '-n4', '/volume1/@appdata/sabnzbd/@[email protected]/fileprio', '0508 Neue Zurcher Zeitung 2022 / MW6BlHuO9Da1gkjqGw3Ta2', '', '', '', '', '9558382', 'alt.binaries.bloaf', '0508 Neue Zurcher Zeitung', '1', '', '']
2022-08-05 18:45:16,133::DEBUG::[misc:1164] Popen arguments: {'stdin': -1, 'stdout': -1, 'stderr': -2, 'startupinfo': None, 'creationflags': 0, 'env': {'SYNOPKG_PKGVAR': '/volume1/@appdata/sabnzbd', 'SYNOPKG_PKGPORT': '8080', 'SYNOPKG_USERNAME': 'admin', 'SYNOPKG_PKGNAME': 'sabnzbd', 'SYNOPKG_DSM_VERSION_MAJOR': '7', 'SYNOPKG_PKGHOME': '/volume1/@apphome/sabnzbd', 'SYNOPKG_DSM_VERSION_MINOR': '1', 'SYNOPKG_PKGTMP': '/volume1/@apptemp/sabnzbd', 'SYNOPKG_DSM_VERSION_BUILD': '42661', 'SELF': 'sabnzbd', 'PWD': '/', 'SYNOPKG_PKGVER': '3.6.0-56', 'SYNOPKG_DSM_LANGUAGE': 'ger', 'SYNOPKG_DSM_ARCH': 'avoton', 'SYNOPKG_PKGDEST_VOL': '/volume1', 'SHLVL': '2', 'PATH': '/volume1/@appstore/sabnzbd/env/bin:/volume1/@appstore/sabnzbd/bin:/var/packages/python310/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/python310/target/lib/python3.10/site-packages/certifi/cacert.pem', 'SAB_BYTES': '9558382', 'SAB_BYTES_DOWNLOADED': '0', 'SAB_BYTES_TRIED': '0', 'SAB_CAT': '*', 'SAB_CORRECT_PASSWORD': '', 'SAB_DUPLICATE': '0', 'SAB_ENCRYPTED': '0', 'SAB_FAIL_MSG': '', 'SAB_FILENAME': '0508 Neue Zurcher Zeitung 2022{{MW6BlHuO9Da1gkjqGw3Ta2}}.nzb', 'SAB_FINAL_NAME': '0508 Neue Zurcher Zeitung 2022', 'SAB_GROUP': 'alt.binaries.bloaf', 'SAB_NZO_ID': '', 'SAB_OVERSIZED': '0', 'SAB_PASSWORD': 'MW6BlHuO9Da1gkjqGw3Ta2', '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_SHOW_NAME': '0508 Neue Zurcher Zeitung', 'SAB_SHOW_SEASON': '1', 'SAB_SHOW_EPISODE': '', 'SAB_SHOW_EPISODE_NAME': '', '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_ZIP_COMMAND': '', 'SAB_7ZIP_COMMAND': '/volume1/@appstore/sabnzbd/bin/7za', 'SAB_VERSION': '3.6.0'}}
2022-08-05 18:45:16,145::INFO::[newsunpack:2407] Pre-queue script returned 2 and output=
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 1: import: command not found
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 3: try:: command not found
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 4: syntax error near unexpected token `='
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 4: `    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv'

2022-08-05 18:45:16,145::INFO::[newsunpack:2432] Pre-Q accepts 0508 Neue Zurcher Zeitung 2022
2022-08-05 18:45:16,145::DEBUG::[nzbstuff:1897] Saving attributes {'cat': '*', 'pp': 3, 'script': 'None', 'priority': 0, 'final_name': '0508 Neue Zurcher Zeitung 2022', 'password': 'MW6BlHuO9Da1gkjqGw3Ta2', 'url': None} for 0508 Neue Zurcher Zeitung 2022
2022-08-05 18:45:16,146::DEBUG::[misc:215] Parsing category * to attributes: pp=3 script=None prio=0
2022-08-05 18:45:16,147::DEBUG::[nzbstuff:968] NZB nzo-info = {'password': 'MW6BlHuO9Da1gkjqGw3Ta2'}
2022-08-05 18:45:16,148::INFO::[nzbqueue:236] Saving queue
2022-08-05 18:45:16,148::DEBUG::[nzbstuff:1897] Saving attributes {'cat': '*', 'pp': 3, 'script': 'None', 'priority': 0, 'final_name': '0508 Neue Zurcher Zeitung 2022', 'password': 'MW6BlHuO9Da1gkjqGw3Ta2', 'url': None} for 0508 Neue Zurcher Zeitung 2022
2022-08-05 18:45:16,149::DEBUG::[filesystem:1110] [sabnzbd.nzbstuff.save_to_disk] Saving data for SABnzbd_nzo_b0_eb9ew in /volume1/UpDownload/Temp/0508 Neue Zurcher Zeitung 2022/__ADMIN__
2022-08-05 18:45:16,150::DEBUG::[filesystem:1178] [sabnzbd.nzbqueue.save] Saving data for queue10.sab
2022-08

Code: Select all

2022-08-05 18:45:16,133::DEBUG::[misc:1164] Popen arguments: {'stdin': -1, 'stdout': -1, 'stderr': -2, 'startupinfo': None, 'creationflags': 0, 'env': {'SYNOPKG_PKGVAR': '/volume1/@appdata/sabnzbd', 'SYNOPKG_PKGPORT': '8080', 'SYNOPKG_USERNAME': 'admin', 'SYNOPKG_PKGNAME': 'sabnzbd', 'SYNOPKG_DSM_VERSION_MAJOR': '7', 'SYNOPKG_PKGHOME': '/volume1/@apphome/sabnzbd', 'SYNOPKG_DSM_VERSION_MINOR': '1', 'SYNOPKG_PKGTMP': '/volume1/@apptemp/sabnzbd', 'SYNOPKG_DSM_VERSION_BUILD': '42661', 'SELF': 'sabnzbd', 'PWD': '/', 'SYNOPKG_PKGVER': '3.6.0-56', 'SYNOPKG_DSM_LANGUAGE': 'ger', 'SYNOPKG_DSM_ARCH': 'avoton', 'SYNOPKG_PKGDEST_VOL': '/volume1', 'SHLVL': '2', 'PATH': '/volume1/@appstore/sabnzbd/env/bin:/volume1/@appstore/sabnzbd/bin:/var/packages/python310/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/python310/target/lib/python3.10/site-packages/certifi/cacert.pem', 'SAB_BYTES': '9558382', 'SAB_BYTES_DOWNLOADED': '0', 'SAB_BYTES_TRIED': '0', 'SAB_CAT': '*', 'SAB_CORRECT_PASSWORD': '', 'SAB_DUPLICATE': '0', 'SAB_ENCRYPTED': '0', 'SAB_FAIL_MSG': '', 'SAB_FILENAME': '0508 Neue Zurcher Zeitung 2022{{MW6BlHuO9Da1gkjqGw3Ta2}}.nzb', 'SAB_FINAL_NAME': '0508 Neue Zurcher Zeitung 2022', 'SAB_GROUP': 'alt.binaries.bloaf', 'SAB_NZO_ID': '', 'SAB_OVERSIZED': '0', 'SAB_PASSWORD': 'MW6BlHuO9Da1gkjqGw3Ta2', '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_SHOW_NAME': '0508 Neue Zurcher Zeitung', 'SAB_SHOW_SEASON': '1', 'SAB_SHOW_EPISODE': '', 'SAB_SHOW_EPISODE_NAME': '', '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_ZIP_COMMAND': '', 'SAB_7ZIP_COMMAND': '/volume1/@appstore/sabnzbd/bin/7za', 'SAB_VERSION': '3.6.0'}}
2022-08-05 18:45:16,145::INFO::[newsunpack:2407] Pre-queue script returned 2 and output=
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 1: import: command not found
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 3: try:: command not found
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 4: syntax error near unexpected token `='
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 4: `    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv'


User avatar
sander
Release Testers
Release Testers
Posts: 8076
Joined: January 22nd, 2008, 2:22 pm

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by sander »

I think you're running a python script as a shell script.

Solution: put a "shebang" in the first line, "#!/usr/bin/python3"

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

sander wrote: August 5th, 2022, 12:02 pm I think you're running a python script as a shell script.

Solution: put a "shebang" in the first line, "#!/usr/bin/python3"
I did, but nothing changed...

Code: Select all

2022-08-05 19:45:48,125::DEBUG::[filesystem:1110] [sabnzbd.nzbstuff.__init__] Saving data for SABnzbd_nzf_2x71_0ph in /volume1/UpDownload/Temp/NOZ Kinderzeitung 05 08 2022/__ADMIN__
2022-08-05 19:45:48,125::INFO::[nzbparser:477] File p0qyIz0Bh2ERikQZiuzPjmj5aO4qxArdPZZumyH7ggQg81rhje.rar added to queue
2022-08-05 19:45:48,126::DEBUG::[misc:215] Parsing category * to attributes: pp=3 script=None prio=0
2022-08-05 19:45:48,189::DEBUG::[sorting:610] Initial guess for NOZ Kinderzeitung 05 08 2022 is MatchesDict([('title', 'NOZ Kinderzeitung'), ('date', datetime.date(2022, 8, 5)), ('type', 'episode')])
2022-08-05 19:45:48,190::INFO::[misc:1163] [sabnzbd.newsunpack.pre_queue] Running external command: ['/volume1/@appstore/sabnzbd/bin/nice', '-n15', '/volume1/@appstore/sabnzbd/bin/ionice', '-c2', '-n4', '/volume1/@appdata/sabnzbd/@[email protected]/fileprio', 'NOZ Kinderzeitung 05 08 2022 / lpYds4wfDUzZxEoOOv5QFr', '', '', '', '', '14917834', 'alt.binaries.bloaf', '', '', '', '']
2022-08-05 19:45:48,191::DEBUG::[misc:1164] Popen arguments: {'stdin': -1, 'stdout': -1, 'stderr': -2, 'startupinfo': None, 'creationflags': 0, 'env': {'SYNOPKG_PKGVAR': '/volume1/@appdata/sabnzbd', 'SYNOPKG_PKGPORT': '8080', 'SYNOPKG_USERNAME': 'admin', 'SYNOPKG_PKGNAME': 'sabnzbd', 'SYNOPKG_DSM_VERSION_MAJOR': '7', 'SYNOPKG_PKGHOME': '/volume1/@apphome/sabnzbd', 'SYNOPKG_DSM_VERSION_MINOR': '1', 'SYNOPKG_PKGTMP': '/volume1/@apptemp/sabnzbd', 'SYNOPKG_DSM_VERSION_BUILD': '42661', 'SELF': 'sabnzbd', 'PWD': '/', 'SYNOPKG_PKGVER': '3.6.0-56', 'SYNOPKG_DSM_LANGUAGE': 'ger', 'SYNOPKG_DSM_ARCH': 'avoton', 'SYNOPKG_PKGDEST_VOL': '/volume1', 'SHLVL': '2', 'PATH': '/volume1/@appstore/sabnzbd/env/bin:/volume1/@appstore/sabnzbd/bin:/var/packages/python310/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/python310/target/lib/python3.10/site-packages/certifi/cacert.pem', 'SAB_BYTES': '14917834', 'SAB_BYTES_DOWNLOADED': '0', 'SAB_BYTES_TRIED': '0', 'SAB_CAT': '*', 'SAB_CORRECT_PASSWORD': '', 'SAB_DUPLICATE': '0', 'SAB_ENCRYPTED': '0', 'SAB_FAIL_MSG': '', 'SAB_FILENAME': 'NOZ Kinderzeitung 05 08 2022{{lpYds4wfDUzZxEoOOv5QFr}}.nzb', 'SAB_FINAL_NAME': 'NOZ Kinderzeitung 05 08 2022', 'SAB_GROUP': 'alt.binaries.bloaf', 'SAB_NZO_ID': '', 'SAB_OVERSIZED': '0', 'SAB_PASSWORD': 'lpYds4wfDUzZxEoOOv5QFr', '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_SHOW_NAME': '', 'SAB_SHOW_SEASON': '', 'SAB_SHOW_EPISODE': '', 'SAB_SHOW_EPISODE_NAME': '', '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_ZIP_COMMAND': '', 'SAB_7ZIP_COMMAND': '/volume1/@appstore/sabnzbd/bin/7za', 'SAB_VERSION': '3.6.0'}}
2022-08-05 19:45:48,204::INFO::[newsunpack:2407] Pre-queue script returned 2 and output=
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 3: import: command not found
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 5: try:: command not found
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 6: syntax error near unexpected token `='
/volume1/@appdata/sabnzbd/@[email protected]/fileprio: line 6: `    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv'

2022-08-05 19:45:48,205::INFO::[newsunpack:2432] Pre-Q accepts NOZ Kinderzeitung 05 08 2022
2022-08-05 19:45:48,206::DEBUG::[nzbstuff:1897] Saving attributes {'cat': '*', 'pp': 3, 'script': 'None', 'priority': 0, 'final_name': 'NOZ Kinderzeitung 05 08 2022', 'password': 'lpYds4wfDUzZxEoOOv5QFr', 'url': None} for NOZ Kinderzeitung 05 08 2022
2022-08-05 19:45:48,207::DEBUG::[misc:215] Parsing category * to attributes: pp=3 script=None prio=0

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

After I`ve googled "shebang" :) and landing at WIKIPEDIA I also tried "#!/usr/bin/env python3" but no change..

User avatar
safihre
Administrator
Administrator
Posts: 4790
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by safihre »

Try just this one (special for Synology):

#!/usr/bin/python3
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

WOOhoooooo, now it`s working!!


I did some changes in the Example Code from the WIKI after I read about problems with TABS and SPACES in python3.x codes...

https://stackoverflow.com/questions/444 ... nted-block I followed (Tip Nr.3) ereasing all tabs and replaced them with 4 spaces.

after this I changed the original
if downloadsize > 501111222
to
if downloadsize < 50111222

and now it works perfect!!

;D ;D ;D
So here is the final working script:

Code: Select all

#!/usr/bin/python3
import sys

try:
    (scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist, showname, season, episodenumber, episodename) = sys.argv

    downloadsize = int(downloadsize)
except:
    sys.exit(1)    # exit with 1 causes SABnzbd to ignore the output of this script

prio = -100    # Default
if downloadsize < 50111222:
    prio = 2

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

# 0 means OK
sys.exit(0)
Thanx to all of you pointing me in the right direction.... :D :D

gohakn
Newbie
Newbie
Posts: 8
Joined: August 3rd, 2022, 10:39 am

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by gohakn »

Donation is on it`s way...
Have a nice WE.

User avatar
safihre
Administrator
Administrator
Posts: 4790
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Sort queue according to file size when nzb is added (The 2nd)

Post by safihre »

Great :)
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate

Post Reply