[REQ] Synology - Indexing Script.

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.
hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [REQ] Synology - Indexing Script.

Post by hugbug » 18 Feb 2018, 23:29

I'm not sure the script works at all in combination with nzbToSickBeard which moves files. The script will probably pass wrong (old) path to synoindex as it doesn't know where SickBeard moved files.

Anyway, for a start remove the status check from the script and see how it goes.

To check what's wrong with status open in browser http://192.168.1.3:6792/jsonrpc/history (change IP and port if necessary) and check field "STATUS". See https://nzbget.net/api/history for description.

ronrosenfeld
Posts: 18
Joined: 08 Sep 2017, 02:12

Re: [REQ] Synology - Indexing Script.

Post by ronrosenfeld » 18 Feb 2018, 23:43

Thanks for that.

In jsonrpc/history, it indicates:

"Status" : "SUCCESS/ALL"

so I guess I should change the status check to that?

But you are correct in getting the correct directory.
I don't see in that information anyplace to indicate the proper folder.

Any other thoughts for a script that would work with Sickrage?

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

Re: [REQ] Synology - Indexing Script.

Post by hugbug » 19 Feb 2018, 10:09

There is an error in the script:

Code: Select all

if [ "$NZBPP_TOTALSTATUS"] != "SUCCESS" ]; then 
It should be:

Code: Select all

if [ "$NZBPP_TOTALSTATUS" != "SUCCESS" ]; then 
As I've mentioned I haven't tested the script, I don't have a syno has.

About integration with SickRage. The script needs to know where the files are. Or you can pass the root directory (containing all videos) to synoindex.

ronrosenfeld
Posts: 18
Joined: 08 Sep 2017, 02:12

Re: [REQ] Synology - Indexing Script.

Post by ronrosenfeld » 19 Feb 2018, 13:09

Hmmm. It seemed to run with just my change of SUCCESS --> SUCCESS/ALL

What does removing that bracket ] do?

Of course, as you anticipated, the script then failed with unknown error when it ran, undoubtedly because the directory was incorrect.

I will try hard coding the root directory. I should also learn more about the syntax of these scripts. I don't know how to access SickRage to determine the final destination, but maybe there's a way of reconstructing, at least down to the root for the particular series.

Fortunately, on my Synology box, synoindex runs pretty quickly.

Thank you for your help

ronrosenfeld
Posts: 18
Joined: 08 Sep 2017, 02:12

Re: [REQ] Synology - Indexing Script.

Post by ronrosenfeld » 20 Feb 2018, 12:34

Computers are very fussy. And I do seem to be further along
I've made some changes based on your recommendations and my observation of status, and now I am getting this odd result in the nzbGet log:
update: /bin/sh: can't open ' '
Without the space:
update: Could not start /downloads/scripts/update.sh: No such file or directory
I suspect this may be an issue in that nzbGet is being run inside docker, so the compiler directive sees the wrong path:

From Docker Settings:

"host_volume_file" : "/nzbGetDownloads",
"mount_point" : "/downloads",


and, in fact, the absolute path (outside of Docker) for the script location would be /volume1/nzbGetDownloads/Scripts

I have extremely limited experience with Unix, so I don't really know how to deal with this. Can you help?
Thanks.

Here is my current script:

Code: Select all

#!/bin/sh 

######################################
### NZBGET POST-PROCESSING SCRIPT   ###

# Add to Syno index.

### NZBGET POST-PROCESSING SCRIPT   ###
######################################

if [ "$NZBPP_TOTALSTATUS" != "SUCCESS/ALL" ]; then
    echo "Download failed, skipping Syno index";
        exit 95;
fi

echo "[INFO] Adding to Syno index"
if [ "$NZBPP_FINALDIR" != "" ]; then
    NZBPP_DIRECTORY = "$NZBPP_FINALDIR"
fi;
/usr/syno/bin/synoindex -R video
exit 93;

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

Re: [REQ] Synology - Indexing Script.

Post by hugbug » 20 Feb 2018, 21:40

This will not work:

Code: Select all

if [ "$NZBPP_TOTALSTATUS" != "SUCCESS/ALL" ]; then
"SUCCESS/ALL" is not a correct total-status to test. It should be "SUCCESS".
ronrosenfeld wrote:
20 Feb 2018, 12:34
update: /bin/sh: can't open ' '
update: Could not start /downloads/scripts/update.sh: No such file or directory
It seems you edit the file using a text editor on Windows. You should save the file using Unix line endings. Many text editors can do this (for example Notepad2 or Notepad++).

ronrosenfeld
Posts: 18
Joined: 08 Sep 2017, 02:12

Re: [REQ] Synology - Indexing Script.

Post by ronrosenfeld » 20 Feb 2018, 22:41

Thanks.
Although I had done some editing using Windows, most of the editing I did was using VIM (using putty to get into the Synology shell).

Hmmm. Doing some testing, it seems that VI just continues to use whatever line ending is in the file. So after editing it just once in Windows, I was stuck with the CRLF ending unless I specifically changed it.

And, sure enough, when I examined the file, it did have the CR/LF endings and not just the LF endings.
I don't have Notepad++ or Notepad2, but

vi +':w ++ff=unix' +':q' update.sh

managed to convert it (I think). At least, I don't see those ^M's any more.

I'll try testing just for SUCCESS. I was using SUCCESS/ALL due to that being the contents of the first "status" line for successful files in json/rpc/history file:

"Status" : "SUCCESS/ALL",

But I see now there is documentation defining the parameter differently in the link you provided regarding how to write a script.

ronrosenfeld
Posts: 18
Joined: 08 Sep 2017, 02:12

Re: [REQ] Synology - Indexing Script.

Post by ronrosenfeld » 21 Feb 2018, 21:59

hugbug wrote:
19 Feb 2018, 10:09
About integration with SickRage. The script needs to know where the files are. Or you can pass the root directory (containing all videos) to synoindex.
There may be a method of determining this.

Examining the json/rpc/history file, for each downloaded episode, there is an entry:

Code: Select all

"DupeKey" : "SickRage-328487-1.8"
This is the indexerid.season.episode

With this information, one can use the API for Sickrage to determine the final location of the file

Code: Select all

http://192.168.1.215:8080/api/...sickrage_api_key.../?cmd=episode&indexerid=328487&season=1&episode=8&full_path=1
would then return, in a field called "location", the full path of the file, which could be passed to synoindex.

Of course, running in Docker, one would have to somehow determine, from nzbGet, the mount point for the /tv folder in Sickbeard; or it could just be hard-coded or entered when the script is set up, much like other scripting parameters.

Is doing this something that is possible within the constraints of PP Scripts?

Right now, it is well beyond my capabilities, but it might be fun for me to learn how to do something like this.

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

Re: [REQ] Synology - Indexing Script.

Post by hugbug » 21 Feb 2018, 23:30

ronrosenfeld wrote:
21 Feb 2018, 21:59
Is doing this something that is possible within the constraints of PP Scripts?
There are no constraints.

Your problem is actually not the indexing script which works fine but rather the nzbToSickbeard-script which causes the files to be moved but doesn't instruct NZBGet about new location. Instead of tweaking this indexing script you better tweak nzbToSickbeard-script or ask the author (Clinton Hall) to extend it. First of all check if you use the newest version of the script.

See Post-processing scripts (control commands) on how to instruct NZBGet about new files location.

Scripting is a useful skill, learning it is a good idea ;)

ronrosenfeld
Posts: 18
Joined: 08 Sep 2017, 02:12

Re: [REQ] Synology - Indexing Script.

Post by ronrosenfeld » 22 Feb 2018, 00:03

Thank you. I will check with him, also.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests