category translation when adding via API?

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
User avatar
OneCD
Hero Member
Hero Member
Posts: 557
Joined: March 4th, 2017, 3:47 pm

category translation when adding via API?

Post by OneCD »

Hello. :)

SABnzbd 2.3.8 from Git source on Debian 9.8.

I might be missing something really simple here, but it seems when NZBHydra2 sends an NZB to SABnzbd, it's not being assigned to the correct category within SABnzbd.

My config is: a single SABnzbd category called "movies", with the "Indexer Categories / Groups" field set to:

Code: Select all

movies*, moviesbluray, movies sd
...(the redundancy is because I've been testing things).

So, I then push an NZB from NZBHydra to SAB and view the SAB debug log:

Code: Select all

2019-03-28 08:53:15,756::DEBUG::[interface:481] API-call from 127.0.0.1 [okhttp/3.11.0] {'nzbname': u'NA.2016.DVDScr.576p.H264.nzb', 'apikey': u'<HASH>d3240a3', 'name': u'http://talia:5076/getnzb/api/7005068519891039509?apikey=<APIKEY>', 'cat': u'Movies SD', 'priority': u'-100', 'mode': u'addurl', 'output': u'json'}
2019-03-28 08:53:20,357::DEBUG::[nzbstuff:560] META-DATA = {u'category': [u'Movies > SD'], u'name': [u'NA.2016.DVDScr.576p.H264 [02/14] - "<HASH>828c825.part1.rar" yEnc'], u'x-downloaded-from': [u'https://nzbfinder.ws']}
2019-03-28 08:53:20,361::INFO::[__init__:624] Backing up /share/downloads/sabnzbd/nzb/backup/NA.2016.DVDScr.576p.H264.nzb.gz
2019-03-28 08:53:20,469::INFO::[__init__:624] Backing up /share/downloads/sabnzbd/incomplete/NA.2016.DVDScr.576p.H264/__ADMIN__/NA.2016.DVDScr.576p.H264.nzb.gz
2019-03-28 08:53:20,498::DEBUG::[misc:178] Cat->Attrib cat=movies sd pp=3 script=CharTranslator.py prio=0
2019-03-28 08:53:20,520::DEBUG::[misc:178] Cat->Attrib cat=movies sd pp=3 script=CharTranslator.py prio=0
 
SAB then shows the new NZB with the category temporarily set to "Movies SD" while it's being fetched. It then changes to "movies sd", instead of "movies". It seems an NZB can be pushed onto the SAB queue with a new category? ???

If I understand correctly, SAB should automatically translate "Movies SD" into "movies":
Wiki wrote:Categories are applied:
  • When the indexer category tag or newsgroup of the download matches the field for that category.
  • When the indexer category tag starts with one of your categories.
  • When an RSS feed specifically applies a particular category.
  • When added via the Watched Folder using special file or folder name.
  • When a download gets added via the API that also specifies a category.
... but this does not appear to happen. How can I fix this?

Thank you.
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: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: category translation when adding via API?

Post by safihre »

Let me start by saying that there might be a bug in this code, since it's a bit tricky. Working on unittests for it, but not have full coverage.

So the idea is that Indexer Tags only get applied to the tags found inside the NZB or through the HTTP-headers send by the indexer, not the API-call-category.
The API-call-category overrules any auto-detection and should match any of the existing categories to have it's option's applied. The API-call-category is not passed trough the Indexer-Tags matching.
So you should pass "movies" to the API-call, or let SABnzbd auto-match it based on the tag inside the NZB.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
OneCD
Hero Member
Hero Member
Posts: 557
Joined: March 4th, 2017, 3:47 pm

Re: category translation when adding via API?

Post by OneCD »

safihre wrote: March 28th, 2019, 2:09 am The API-call-category overrules any auto-detection and should match any of the existing categories to have it's option's applied. The API-call-category is not passed trough the Indexer-Tags matching.
Ah, I see. No problem.
safihre wrote: March 28th, 2019, 2:09 am So you should pass "movies" to the API-call, or let SABnzbd auto-match it based on the tag inside the NZB.
Agree, however I'm unable to change these within NZBHydra as it passes the original NZB category names to SAB in the API call.

Thanks @safihre. :)
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
OneCD
Hero Member
Hero Member
Posts: 557
Joined: March 4th, 2017, 3:47 pm

Re: category translation when adding via API?

Post by OneCD »

Decided to manage this with an inelegant pre-queue script: ;D

Code: Select all

#!/usr/bin/env bash

[[ -z $3 ]] && exit 0

echo "1"        # 0 = refuse, 1 = accept
echo "$1"       # name of NZB
echo "$2"       # post-processing flags

if [[ ${3,,} =~ ^movies.* ]]; then
    echo "movies"
elif [[ ${3,,} =~ ^tv.* ]]; then
    echo "tv"
else
    echo "$3"
fi

exit 0
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
OneCD
Hero Member
Hero Member
Posts: 557
Joined: March 4th, 2017, 3:47 pm

Re: category translation when adding via API?

Post by OneCD »

Update: the NZBHydra2 dev has just added a new option to map NZB categories to NZBHydra2 categories. So, there's now another way to do this. ;)
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: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: category translation when adding via API?

Post by safihre »

Cool!
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply