[request] nzbs in zip files; store .queued files elsewhere

Discuss newly added features or request new features.
Post Reply
k1tk4t
Posts: 11
Joined: 12 Dec 2013, 19:09

[request] nzbs in zip files; store .queued files elsewhere

Post by k1tk4t » 12 Dec 2013, 19:22

First, a huge shoutout to hugbug for such an awesome app! The download speeds are amazing and have convinced me to make the move from sabnzbd. That said, there are two features from SAB that I desperately miss and would like to request for inclusion in a future version (I realize these could probably be done via processing scripts, but I consider them so fundamental as to request they be made part of the core program).

1) Storing .queued files in a history-specific folder, and zipping them to save space. Storing these in the nzb folder clutters it and makes it very hard to tell what has been processed and what files you have just dropped in there to be processed, especially when you've downloaded a lot of stuff in the past X days. I'm not sure if I would break your history handling if I moved these elsewhere with a script, but it feels like I would, so having the program look elsewhere would be ideal.
2) Handle zip files dropped into the nzb folder, adding every NZB file in the zip to the queue (what to do with the zip after that is a point for discussion, but deleting it and keeping the nzbs files in the history seems reasonable).

Sorry if this isn't the right way to request new features, but I couldn't find a request tracker or anything like that so this seemed appropriate.

k1tk4t
Posts: 11
Joined: 12 Dec 2013, 19:09

Re: [request] nzbs in zip files; store .queued files elsewhe

Post by k1tk4t » 26 Dec 2013, 21:45

Any chance of this happening? I'm holding off on writing some scripts until I know one way or the other :)

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

Re: [request] nzbs in zip files; store .queued files elsewhe

Post by hugbug » 26 Dec 2013, 21:51

1. Moving processed files into a separate directory is a nice idea. Zipping them is an overkill which adds complexity. The files will be deleted anyway, when they expire (as set by option KeepHistory).

2. To handle zipped nzb-file you can write a pre-processing script - see option NzbProcess. This should be easy.

k1tk4t
Posts: 11
Joined: 12 Dec 2013, 19:09

Re: [request] nzbs in zip files; store .queued files elsewhe

Post by k1tk4t » 26 Dec 2013, 22:16

Granted, the zipping borders on unnecessary given hard drive sizes today.

Sounds like I'll hold off on a script that moves the .queued file elsewhere, as you're interested in adding that. But I'll take a look at pre-processing scripts to see what I can come up with for zip files and will share anything useful that results.

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

Re: [request] nzbs in zip files; store .queued files elsewhe

Post by hugbug » 26 Dec 2013, 22:41

Take a look at this pre-processing script - last post of old topic "ziped nzb files".
The script NEEDS to be changed a little. Newer versions of NZBGet pass parameters via environment variables instead of command line arguments. You will need to change the references to "$ARGV[1]" to env. vars instead (I don't know how to do that in perl but this should be easy).

k1tk4t
Posts: 11
Joined: 12 Dec 2013, 19:09

Re: [request] nzbs in zip files; store .queued files elsewhe

Post by k1tk4t » 28 Dec 2013, 16:29

I found the same over at http://nzbget.sourceforge.net/forum/vie ... ?f=3&t=876. I've updated it and adapted it for my specific environment (Synology with 7z installed via ipkg):

Code: Select all

#!/opt/bin/perl
use warnings;
use strict;

# r2, for NZBGet >= 0.6.0-testing-r241

# Configure
my $RenameNzb = '0'; # 1 = true - nzb-name.nzb > archive-name.nzb_processed, 0 = false - foo.nzb > foo.nzb_processed
# overridden if the archive contains multipls nzbs
my $DeleteArchive = '0'; # 1 = true - deletes successfully extracted archive, 0 = false - foo.ext > foo.ext.processed
# overridden if there are any errors during processing

my $ok = 1;

#my $dir = $ARGV[0];
printf "arg1 = $ENV{'NZBNP_FILENAME'}\n";
if ($ENV{'NZBNP_FILENAME'} =~ m!(.+)/([^/]+)\.(zip|rar)$!i){
   &ExtractNzb ($1, $2, $3);
}
elsif ($ENV{'NZBNP_FILENAME'} =~ m!(.+)/([^/]+)\.(nzb)$!i){
   &Save ($1, $2, $3, $2, 'nzb_processed');
}
else { printf "[ERROR] Cannot process: $ENV{'NZBNP_FILENAME'}\n"; }

sub ExtractNzb {
     my ($dir, $arch_name, $arch_ext) = @_;
     my $count = 0;
     my $nzb_name;
     my $nzb_ext;
     my $new_name = $arch_name;
     $new_name =~ s!\.nzb$!!;

     open ARCHIVE, "-|", "/opt/bin/7z e -y -o\"$dir\" \"$dir/$arch_name.$arch_ext\"" or die $!;

     while (<ARCHIVE>){
      print $_;
        if (m!Extracting\s*([^/]+)\.(nzb)$!i){
           $nzb_name = $1;
           $nzb_ext  = $2;
           printf "[INFO] Extracted: $nzb_name.$nzb_ext\n";
           utime (undef, undef, "$dir/$nzb_name.$nzb_ext"); # touch
           &Save ($dir, $nzb_name, $nzb_ext, $nzb_name, 'nzb_processed');
           $count ++;
        }
        elsif (m!([^/]+\.[^\.]{3,4})  (?:.+OK )?$!){
           &Delete ($dir, $1);
        }
     }
     close ARCHIVE or warn $?;

     if ($count == 1 and $RenameNzb and $nzb_name ne $new_name){
        &Save ($dir, $nzb_name, 'nzb_processed', $new_name, 'nzb_processed');
     }

     if ($DeleteArchive and $nzb_name and $ok){
        &Delete ($dir, "$arch_name.$arch_ext");
     }
     elsif ($nzb_name) {
        &Save ($dir, $arch_name, $arch_ext, $arch_name, "$arch_ext.processed");
     }
     else { printf "[ERROR] No nzbs were extracted from: $arch_name.$arch_ext\n"; }
}

sub Delete {
     my ($dir, $file) = @_;
     if (unlink ("$dir/$file")){
        printf "[INFO] Deleted: $file\n";
     }
     else {
        $ok = 0;
        printf "[ERROR] Couldn't delete: $file\n";
     }

}

sub Save {
     my ($dir, $name, $ext, $new_name, $new_ext) = @_; # $new_name can = $name
     if (rename("$dir/$name.$ext", "$dir/$new_name.$new_ext")){
        printf "[INFO] Renamed:  $name.$ext, $new_name.$new_ext\n";
     }
     else {
        $ok = 0;
        printf "[ERROR] Couldn't rename: $name.$ext, $new_name.$new_ext\n";
     }
}
Seems to work well enough, but it also looks like it takes two passes for the files to actually get added to the queue. The first directory scan handles the .zip file, and the second adds all the .nzb_processed files to the queue (I assume there's no way to avoid this and do it all in one go, and that's fine). I am a bit confused about what the original author was trying to do here though:

Code: Select all

     elsif ($nzb_name) {
        &Save ($dir, $arch_name, $arch_ext, $arch_name, "$arch_ext.processed");
     }

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests