Pre Process script for handling Zip files

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.
Post Reply
vergessen
Posts: 23
Joined: 19 Feb 2014, 15:36

Pre Process script for handling Zip files

Post by vergessen » 28 Feb 2014, 20:59

I have created the below for unzipping packs of nzbs'

Code: Select all

code corrected below
Everything is working as expected. It gets the zips, extracts the files and modifies the name to cat.category.filename Then when the nzbs are loaded it searches for files named cat.* and sets the category to *.category.*

This way each nzb makes it to where it should. It looks like it all works correctly. The nzbs unzip, the naming works, the files load and in my case the category is set to TV. The problem is that even though the category is set the post processing scripts I have set for that category are not being changed. It ends up with the default post processing scripts. Am I missing something. I am using 13.0-testing-r958M

Thanks
Last edited by vergessen on 05 Mar 2014, 14:00, edited 2 times in total.

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

Re: Pre Process script

Post by hugbug » 28 Feb 2014, 22:53

The assigned scripts are initialized before the pre-process script is called. This allows the script to override the defaults.
I can improve this by reassigning scripts in a case the pre-process script has changed the category.

As a workaround instead of setting category via "[NZB] CATEGORY=" you can put extracted files into subfolders inside nzb-directory (TV). Subfolders work as categories.

vergessen
Posts: 23
Joined: 19 Feb 2014, 15:36

Re: Pre Process script

Post by vergessen » 01 Mar 2014, 02:17

Thanks that worked as expected.

for anyone who needs/wants a script that isn't perl to handle nzbs in a zip file here you go.

Code: Select all


#!/usr/bin/env python
import os
import sys
import zipfile

ext = os.path.splitext(os.environ['NZBNP_FILENAME'])[1]
cat = os.environ['NZBNP_CATEGORY']
dir = os.environ['NZBNP_DIRECTORY']
filename = os.environ['NZBNP_FILENAME']
if ext.lower() == '.zip':
    zipf = zipfile.ZipFile(filename, mode='r')
    if cat != "":
        zipf.extractall(dir + os.path.sep + cat)
    else:
        zipf.extractall(dir)

#file is there but has to be cleared on next pass?
#    os.unlink(os.environ['NZBNP_FILENAME'] + '.processed')

You can also find it at https://github.com/vergessen/nzbgetpp

vergessen
Posts: 23
Joined: 19 Feb 2014, 15:36

Re: Pre Process script for handling Zip files

Post by vergessen » 07 May 2014, 01:23

Updated git hub source to new standards set by Hugbug in the dev tree.

I believe this should continue to work in old revisions as well as they won't be looking for the header and as far as python cares its all comments.

ressof
Posts: 6
Joined: 21 Aug 2014, 07:03

Re: Pre Process script for handling Zip files

Post by ressof » 21 Aug 2014, 08:50

Hello

When i'm trying this script with Nzbget 13.0 Stable release i get an error message when I upload a zip file via the web interface. See picture below. But it adds the nzb to downloading queue.
nzbget.jpg
nzbget.jpg (14.31 KiB) Viewed 9255 times

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

Re: Pre Process script for handling Zip files

Post by hugbug » 03 Oct 2014, 20:59

hugbug wrote:I can improve this by reassigning scripts in a case the pre-process script has changed the category.
Implemented in r1135.

carow
Posts: 12
Joined: 16 Oct 2014, 18:04

Re: Pre Process script for handling Zip files

Post by carow » 27 Nov 2014, 15:45

ressof wrote:Hello

When i'm trying this script with Nzbget 13.0 Stable release i get an error message when I upload a zip file via the web interface. See picture below. But it adds the nzb to downloading queue.
nzbget.jpg
Same thing happening here, an error message even though the archive is unzipped and the nzbs are added.

vergessen
Posts: 23
Joined: 19 Feb 2014, 15:36

Re: Pre Process script for handling Zip files

Post by vergessen » 02 Dec 2014, 20:39

carow wrote:
ressof wrote:Hello

When i'm trying this script with Nzbget 13.0 Stable release i get an error message when I upload a zip file via the web interface. See picture below. But it adds the nzb to downloading queue.
nzbget.jpg
Same thing happening here, an error message even though the archive is unzipped and the nzbs are added.
There was an issue with 13.x that hugbug later fixed. You may want to update. You probably also want to utilize the rewrite http://nzbget.net/forum/viewtopic.php?f=8&t=1600 done by prinz2311

He added much more support then I had in the original version of this script.

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests