[Scan-Script] pfftn (formerly pass-from-file-to-nzbget.py)

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

[Scan-Script] pfftn (formerly pass-from-file-to-nzbget.py)

Post by wusa » 05 Sep 2013, 19:15

What is this?
This script is filling the Unpack-password from the filename and removes it from NZB Name: file*{{password}}*.nzb

Installation, usage:
x. pfftn_2x, pfftn_3x tested with: nzbget v13, Python v2.7.4, v3.4.1 @ Win8 x64 and Python 2.6.2 @ NSA325 (Linux 2.6.31.8)
1. safe file to ScriptDir and set chown/chmod (for linux only)
2. adjust first line for your OS! (ex. WIN: #!c:/python/python.exe --- LINUX/NAS: #!/usr/local/zy-pkgs/bin/python2.6 or #!/usr/bin/env python)
3. start/restart nzbget (PFFTN_2X or/and PFFTN_3X should appear on left side in settings page of nzbget)
4. nzbget settings -> EXTENSION SCRIPTS -> ScanScript -> Choose (Python v3: pfftn_3x.py / Python v2: pfftn_2x.py)

Help
Maybe, the RegEx can be improved!? :)
Problem with some letters in filename (windows only).

Edit1: Changed line endings from attachment and merge posts.
Edit2: New version (only for Python 2.7) explicit tested for NSA325 (ffp) see: http://nzbget.net/forum/viewtopic.php?p=6190#p6190
Edit3: New version for nzbget v13; Changed filenames; changes from v1.3 removed
Attachments
pfftn_2x.py
v1.4 for Python v2.x
(2.85 KiB) Downloaded 5124 times
pfftn_3x.py
v1.4 for Python v3.x
(2.81 KiB) Downloaded 5306 times
Last edited by wusa on 04 Aug 2014, 14:16, edited 5 times in total.

wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by wusa » 08 Sep 2013, 11:05

There is a problem with the file environment variable (['NZBNP_NZBNAME'] - dos/win) which is set by nzbget.
The special character % is reserved for env-variables (dos).

If the password contains one of this character it will get lost in the env-variable. This can be fixed, if you (or nzbget - fix/feature) double it.

password: 7$%6Ve7 >> env: 7$6Ve7
fix: 7$%%6Ve7 >> env: 7$%6Ve7

password: 7$%%6Ve7 >> env: 7$%6Ve7
fix: 7$%%%%6Ve7 >> env: 7$%%6Ve7
Last edited by wusa on 25 Sep 2013, 14:23, edited 1 time in total.

wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by wusa » 25 Sep 2013, 14:12

Edit: merged
Last edited by wusa on 25 Sep 2013, 15:27, edited 1 time in total.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by hugbug » 25 Sep 2013, 14:18

wusa wrote:I tested my script on a Zyxel NSA325. There is a problem with executing python scripts.
Using "#!/ffp/bin/python3" directly in python-script doesn't work?

wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by wusa » 25 Sep 2013, 14:41

No.

I have tested many settings:
lrwxrwxrwx 1 root root 9 Jun 6 12:50 /ffp/bin/python3 -> python3.3 <- from ffp-package
-rwxr-xr-x 1 root root 1965604 Jun 6 12:52 /ffp/bin/python3.3
-rwxr-xr-x 1 root root 5656 Aug 23 12:15 /usr/bin/python <- from system v2.6.2

#!/ffp/bin/python3(.3) or #!/usr/bin/python
-> nzbget error: Could not start /i-data/md0/admin/nzbget/nzbp/pass-from-file-to-nzbget.py: No such file or directory
-> bash error: -sh: ./pass-from-file-to-nzbget.py: /ffp/bin/python3^M: bad interpreter: No such file or directory

#!/ffp/bin/env python3 oder #!/bin/env python
-> nzbget error: /ffp/bin/env: python3 : No such file or directory
-> bash error: ': No such file or directory

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by hugbug » 25 Sep 2013, 14:46

Looks like the file was saved using windows line endings.

wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by wusa » 25 Sep 2013, 14:49

Yes. I used the script created under windows, just copy the file on the nas and changed first line.
Ok, I will test it.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by hugbug » 25 Sep 2013, 14:55

Change line endings to UNIX using notepad++ or notepad2 or other editor.

wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by wusa » 25 Sep 2013, 14:59

Yes. That's it. Argh. :oops: Thanks! I will change my postings and the attachments.

wusa
Posts: 22
Joined: 05 Sep 2013, 18:39

Re: [NzbProcess] pass-from-file-to-nzbget.py

Post by wusa » 13 Oct 2013, 17:39

There is another problem with letters >ord(128) [ASCII] on a Zyxel NSA325.

The Fonz fun_plug (ffp) "doesn't" support a dpkg-reconfigure console-setup or an apt-get install locales.
Python couldn't read this letters, if the environment doesn't support it. So long, I haven't found a solution, yet.

If anyone got the same problems with (äöü ß etc.) the script is setting the first error line from python into the NZBPR_*Unpack:Password field.
To avoid it, please add this code.

after:

Code: Select all

fwp = os.environ['NZBNP_NZBNAME']
add:

Code: Select all

try:
   fwp.encode('utf-8')
except:
   print('[ERROR] One or more letter(s) could not parse correctly - wrong locales set? Password was not set!')
   sys.exit(1)
Nzbget (windows), not the script, have problems with some letters, too.
Example: Test{{äöüߧ}}.nzb
[ERROR] Error parsing nzb-file: System ...
[ERROR] Could not add collection Test{{äöüߧ}}.nzb to queue

Why are such characters used in file names I don't understand. Happens about once a week.

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests