Page 1 of 1

category translation when adding via API?

Posted: March 27th, 2019, 6:11 pm
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.

Re: category translation when adding via API?

Posted: March 28th, 2019, 2:09 am
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.

Re: category translation when adding via API?

Posted: March 28th, 2019, 1:07 pm
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. :)

Re: category translation when adding via API?

Posted: March 30th, 2019, 9:02 pm
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

Re: category translation when adding via API?

Posted: March 31st, 2019, 12:45 pm
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. ;)

Re: category translation when adding via API?

Posted: April 1st, 2019, 7:41 am
by safihre
Cool!