[Scan-Script] Get Categorie and Password from NZB Filename

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
ProfDrLuigi
Posts: 7
Joined: 24 Apr 2017, 12:00

[Scan-Script] Get Categorie and Password from NZB Filename

Post by ProfDrLuigi » 24 Apr 2017, 18:24

I created a little scan script. It takes the Category and/or Password (if available) from NZB Filename.

[[Computer]]Debian8-Final.iso{{12345}}.nzb

In this example it will put "Computer" as Category and "12345" as password into the queue.

This Script is not running under Windows. It´s Unix/POSIX only.
Attachments
NZBCatPass.sh
(1.06 KiB) Downloaded 150 times
Last edited by ProfDrLuigi on 16 May 2017, 10:02, edited 1 time in total.

hati39
Posts: 1
Joined: 14 May 2017, 14:25

Re: [Scan-Script] Get Categorie and Password from NZB Filena

Post by hati39 » 14 May 2017, 14:43

Hi,

exactly what I need. However, I'm a stupid user. I browsed the docs and tried to understand the mechanisms. I understand, this is a shell script. I created a folder "scripts" in my nzbget main dir and dropped your file there. Do I have to install some unix shell to my Windows 7? The script is shown and activated in the settings page of the web ui. As unrar command I entered C:\Program Files\WinRAR\UnRAR.exe without any options. If I add "-p-" (even that I understand the doc that it is alwasy added I tried it) the path to unrar is no longer found, even if I add " around the path. My nzb filename correspond with your example, but there is no catagory, so it is like filename{{password}}.nzb. There is a folder with the name of the nzb file created in the complete folder, but I receive an upacking error and the folder is empty.

I also tried the option with a (unicode) text-file containing some passwords. Then I receive an unpacking error too, but without a folder been created in complete. What is wrong? Any suggestion?

ProfDrLuigi
Posts: 7
Joined: 24 Apr 2017, 12:00

Re: [Scan-Script] Get Categorie and Password from NZB Filena

Post by ProfDrLuigi » 16 May 2017, 10:01

Sorry I forgot to say: It´s for Linux Systems only. Changed my first Post.

karlnabb
Posts: 1
Joined: 24 Jun 2017, 17:01

Re: [Scan-Script] Get Categorie and Password from NZB Filename

Post by karlnabb » 24 Jun 2017, 17:09

Script starts with a "/bin/sh" shebang. Should be either /bin/bash or someone cares about the double bracket tests inside, seems that dash (which some ( debian, mint e.g.) have choosen as the system shell, doesnt like them ...
I was too lazy, changed it to /bin/bash :-)

Greez,

karl

derdigge
Posts: 10
Joined: 13 Jan 2015, 11:27

Re: [Scan-Script] Get Categorie and Password from NZB Filename

Post by derdigge » 01 Jul 2017, 09:12

4 me there was an problem using that script, so i wxtended it. If there is no catogery in nzbname had overwritten it wih empty value. This is an problem when the user adds a category by himself when adding them in webinter face. here is my fix. i commented a bit for others to come for better readability. pleasent usecases ....

Code: Select all

#!/bin/sh

# Scan Script for fetching Password and Category from NZB-Filename

################################################################################
### NZBGET SCAN SCRIPT 			                                             ##

# This Script takes the Password/Category (if available) from NZB-Filename.
#
# Example: [[Computer]]Debian8-Final.iso{{12345}}.nzb
#
#
# It switches the Category to "Computer" and set the password "12345".
#
# Script by ProfDrLuigi (2017)

### NZBGET SCAN SCRIPT                                                       ###
################################################################################

set > /tmp/set

#	back it up for ever:
if [[ ! -z "$NZBNP_CATEGORY" ]];then
	#echo "[NZB] PRIORITY=50"				optionaly
	t_name="[[$NZBNP_CATEGORY]]"$(echo "$NZBNP_NZBNAME" | tr ' ' '.') 			#	its allway an good idea to remove whitspaces in linux
else
	t_name=$(echo "$NZBNP_NZBNAME" | tr ' ' '.')
fi

#gzip -c "$NZBNP_FILENAME" > "$NZBOP_MAINDIR/nzbbackup/"$t_name.gz 				#	optionally backup nzbs / usefull in my case

newname=$(echo "$NZBNP_FILENAME" | sed -e 's/.*\]//g' -e 's/{.*//g' -e 's/.nzb//g' | tr ' ' '.')	#	added remove whitespaces

if [[ "$NZBNP_FILENAME" =~ "[[" ]]
then
	cat=$(echo "$NZBNP_FILENAME"  | sed -e 's/.*\[//g' -e 's/\].*//g')
else
	cat="$NZBNP_CATEGORY"														#	if user passes its own category its used, otherwise its empty value
fi

if [[ "$NZBNP_FILENAME" =~ "{{" ]]
then
	pass=$(echo "$NZBNP_FILENAME" | sed -e 's/.*{//g' -e 's/}.*//g')
else
	pass=""
fi

echo "[NZB] NZBNAME=$newname";
echo "[NZB] CATEGORY=$cat";
echo "[NZB] NZBPR_*Unpack:Password=$pass";

exit 93

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest