Read file names / assign category based on nzb filename

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
Emmcee
Newbie
Newbie
Posts: 2
Joined: October 28th, 2022, 5:01 pm

Read file names / assign category based on nzb filename

Post by Emmcee »

Hello people
I am trying to find a solution to the following problem after a lot of trial and error:
Is there a way that SABnzbd automatically assigns the download to a certain category based on reading the NZB file name and occurrences in it?
An example:
Series.S01E01.nzb
If Sabnzbd detects a NZB in the watched folder that contains "S0" or "E0" in its name, automatically assign this download to the category Series and start downloading.
I am looking forward to your constructive help!
Mama Greetz Emmcee
User avatar
sander
Release Testers
Release Testers
Posts: 8847
Joined: January 22nd, 2008, 2:22 pm

Re: Read file names / assign category based on nzb filename

Post by sander »

I'm not sure if SAB itself can do it, but you certainly can do it with a pre-queue script. See https://sabnzbd.org/wiki/scripts/pre-queue-scripts
User avatar
safihre
Administrator
Administrator
Posts: 5390
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Read file names / assign category based on nzb filename

Post by safihre »

See here in the second list how we apply it: https://sabnzbd.org/wiki/configuration/3.6/categories

Your specific case might indeed require a custom script.

But maybe a better question, why do some jobs need different category? What problem do you have?
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Emmcee
Newbie
Newbie
Posts: 2
Joined: October 28th, 2022, 5:01 pm

Re: Read file names / assign category based on nzb filename

Post by Emmcee »

Hello and thank you very much for the great answers! I often load series and movies with always the same name attributes in one watched NZB Folder. These should be assigned automatically and not manually via the dashboard. many greetings from Germany
User avatar
jcfp
Release Testers
Release Testers
Posts: 993
Joined: February 7th, 2008, 12:45 pm

Re: Read file names / assign category based on nzb filename

Post by jcfp »

Emmcee wrote: October 29th, 2022, 4:15 amI often load series and movies with always the same name attributes in one watched NZB Folder.
You can assign categories via the watched folder by putting the nzb file in a subdirectory named after a category.
User avatar
OneCD
Hero Member
Hero Member
Posts: 565
Joined: March 4th, 2017, 3:47 pm

Re: Read file names / assign category based on nzb filename

Post by OneCD »

jcfp wrote: October 29th, 2022, 4:46 am You can assign categories via the watched folder by putting the nzb file in a subdirectory named after a category.
Thanks @jcfp, I'll be able to make good use of that. :)
Stuff I like: Apache bash cron DD-WRT Debian DNSMasq Entware FireFox GitHub ImageMagick Kate KDE LibreELEC Netrunner NFS NVIDIA OpenVPN Orvibo-S20 pfSense Python Raspberry-Pi RAID SABnzbd Transmission Usenet VirtualBox Watcher3 XFCE
User avatar
safihre
Administrator
Administrator
Posts: 5390
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Read file names / assign category based on nzb filename

Post by safihre »

Hmm reading the documentation, I think we should improve the documentation a bit. This functionality isn't really described well in the Categories page, only on the Config page.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
mantinaut
Newbie
Newbie
Posts: 1
Joined: May 1st, 2024, 3:05 pm

Re: Read file names / assign category based on nzb filename

Post by mantinaut »

I'm using the sabnbzd docker container and realized it as follows:

1.) Settings > Special Folders > Scripts Folder > bin
2.) Created the file "obtain-category-by-filename" in /config/bin with the following content:

Code: Select all

#!/bin/bash

# Return parameters

# accept nzb
echo "1"

# do not overwrite job name
echo ""

# no post processing
echo ""

# category
if echo "$SAB_FINAL_NAME$SAB_FILENAME" | --quiet grep --ignore-case --perl-regexp "(s[0-9]+e[0-9]+|s[0-9]+.?complete)"; then
  echo "tv"
else
  echo "movies"
fi

# no script path
echo ""

# default priority
echo "0"

# do not change group
echo ""
3.) chmod 775 /config/bin/obtain-category-by-filename
4.) Settings > Switches > Pre-queue script > set to "obtain-category-by-filename"

EDIT: @admins the default board preference "Notify me upon replies by default:" should be "yes" I think. I would have almost missed replies :-\
Post Reply