FAQ  •  Register  •  Login

Using CURL to force library refresh

<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Mon Aug 15, 2011 6:11 pm

Re: Using CURL to force library refresh

Ive tried all variation using putty to run the python code, the only one that returns 200 is connection = httplib.HTTPConnection('192.168.1.6:23423')
It does refresh my Serviio Library - Hurray!!
[/share/Qdownload/sabnzbd/script] # python ServiioRefresh.py
200

My sabnzbd and serviio is on the same IP on the same NAS server - 192.168.1.6

BUT! - Its not running with sabnzb, sab keeps saying the same error message
Exit(-1) Cannot run script /share/Qdownload/sabnzbd/script/ServiioRefresh.py

Ive check the permission rights of the file, read and execute is enabled, dont know why sab wont run my script...
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

J038lack

Serviio newbie

Posts: 12

Joined: Mon Jul 19, 2010 4:05 am

Post Thu Aug 18, 2011 3:57 pm

Re: Using CURL to force library refresh

So Here is your problem when you run putty you tell it to run python ServiioRefresh.py. Which tells it to use Python to run the script.
To correct the script so you dont need to tell it what to run it with is to add a line to the top of the script stating the path to where python is

Example.

  Code:
#!/usr/local/bin/python
import httplib
connection = httplib.HTTPConnection('192.168.1.6:23423')
body_content = '<action><name>forceLibraryRefresh</name></action>'
connection.request('POST', '/rest/action', body_content)
result = connection.getresponse()
#print result.status


#!/usr/local/bin/python
With the above line you are specifying the location to the python executable in your machine, that rest of the script needs to be interpreted with.The above line is pointing to python that is located at /usr/local/bin/python this maybe different on your machine find the python executable and use that path.

I think after adding this line you should be able to run the script in putty without the python in front of it. Just type - ServiioRefresh.py

Hope this works
J03
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Thu Aug 18, 2011 5:46 pm

Re: Using CURL to force library refresh

J03 you are a star!! 8-)
Im such an idiot not realising this before, for my NAS linux its #!/usr/bin/env python after checking other .py scripts used by my sab

It works perfect and updates my library, just one little thing i want to change,
Iv added on an extra line print "Updated Serviio Library" but for some reason sab says
Updated Serviio Library (More)
It adds extra break line, is there a better way to printline without the link (more) doesnt appear
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

J038lack

Serviio newbie

Posts: 12

Joined: Mon Jul 19, 2010 4:05 am

Post Thu Aug 18, 2011 8:18 pm

Re: Using CURL to force library refresh

Xmantium,

Just a little IF else statement will take care of your output,
As I explained earlier the 200 result is the OK command from the REST interface and we can use that to decide if the Update was successful or failed. try the code below.
As for the line break - you can put a , on the end of the print command. take a look below
but this will not stop the (more) link that is created by sabnzbd. It is a log link and it can only be disable by running a output free script or disable logging (which I'm pretty sure can not be done).

  Code:
#!/usr/bin/env python
import httplib
connection = httplib.HTTPConnection('192.168.1.6:23423')
body_content = '<action><name>forceLibraryRefresh</name></action>'
connection.request('POST', '/rest/action', body_content)
result = connection.getresponse()
if result.status == 200:
    print "Updated Serviio Library",
else :
    print "Update Failed",


J03
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Mon Sep 26, 2011 9:00 pm

Re: Using CURL to force library refresh

When i updated to 0.6, the script no longer works! :?

Has the ports changed to update library!?
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17215

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon Sep 26, 2011 10:03 pm

Re: Using CURL to force library refresh

no, nothing changed. just make sure the REST API still binds to the IP you're expecting (that changed, it now binds automatically to the public IP of the server)
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Mon Sep 26, 2011 10:27 pm

Re: Using CURL to force library refresh

Im a noob to REST, how do i do this to get the script working again?

It should return "200" when the library have been updated, it doesnt return anything now
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

Cerberus

User avatar

DLNA master

Posts: 4114

Joined: Sun Jan 02, 2011 5:20 pm

Location: Reading, UK

Post Mon Sep 26, 2011 10:44 pm

Re: Using CURL to force library refresh

check ip is still correct.
Phil Bennett
Beta Tester Group
Wiki | FAQ

Samsung LE40C750 LCD | Samsung BD-C5900 | Sony PS3 | Windows 7 |
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17215

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon Sep 26, 2011 10:50 pm

Re: Using CURL to force library refresh

does it get throught to the server, ie is the library updated?
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Tue Sep 27, 2011 6:22 am

Re: Using CURL to force library refresh

my sabnzbd and serviio are on the same NAS and all same fixed IP - 192.168.1.6
The script is exactly the same as J03Black's last post.

the script is in python, its designed to run after a media file is downloaded in sabnzbd so I don't have to press force refresh to watch media file straight away, the library does not get updated
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

J038lack

Serviio newbie

Posts: 12

Joined: Mon Jul 19, 2010 4:05 am

Post Sat Oct 01, 2011 1:24 am

Re: Using CURL to force library refresh

Here is the fix for the new version,

Xmantium test this for me,

I have added a header to the POST request telling the REST interface it is xml.
the highlighted text is the added info to the script.

headers = { "Content-type": "text/xml" }
connection.request('POST', '/rest/action' , body_content , headers)

or copy + paste the whole script.

  Code:
#!/usr/bin/env python
import httplib
connection = httplib.HTTPConnection('192.168.1.6:23423')
body_content = '<action><name>forceLibraryRefresh</name></action>'
headers = { "Content-type": "text/xml" }
connection.request('POST', '/rest/action' , body_content , headers)
result = connection.getresponse()
if result.status == 200:
    print "Updated Serviio Library",
else :
    print "Update Failed",
print result.status,


hope it helps
J03
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Sat Oct 01, 2011 4:56 pm

Re: Using CURL to force library refresh

Tested this and its working fine again!!

Thanks for getting back to me :D

Sabnzbd and Serviio combined is the perfect media station!
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Sun Feb 19, 2012 4:01 pm

Re: Using CURL to force library refresh

Update: For QNAP users who who use SABnzbd to run the script, Ive also noticed sickbeard takes over the Serviio library refresh script if sickbeard installed. The quick solution is edit sickbeard.sh and remove the following code:
  Code:
config_sabnzbdplus() {
if [ -f $SABconfig ] && [ -f ${QPKG_DIR}/config.ini ]; then
/sbin/setcfg misc script_dir "${QPKG_DIR}/autoProcessTV" -f $SABconfig
/sbin/setcfg misc enable_tv_sorting 0 -f $SABconfig
/sbin/setcfg [tv] script sabToSickBeard.py -f $SABconfig
/sbin/setcfg [tv] dir TV -f $SABconfig
fi
inject_sb_startup_procedure
}
Last edited by Xmantium on Sun Feb 26, 2012 7:13 pm, edited 1 time in total.
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

J038lack

Serviio newbie

Posts: 12

Joined: Mon Jul 19, 2010 4:05 am

Post Sun Feb 26, 2012 8:07 am

Re: Using CURL to force library refresh

Xmantium,

What do you mean Sickbeard takes over the Serviio refresh?

Im running Sabnzbd, Sickbeard, and CouchPotato with Serviio and I am having no problems. Sickbeard Allows you to run post-processing Scripts from the app itself. Just manually configure the Config.ini.

extra_scripts = C:\\Python27\\pythonw.exe C:\\NZB\\SickBeard\\forceserviio.pyw (running on a windows box)

And CouchPotato has just added post-processing to the renaming section in its new Version also allowing a force update script.

Also remember I let CouchPotato and Sickbeard do all the renaming and creating of thumbnails and metadata allowing Serviio to just serve the files.

J03
<<

Xmantium

User avatar

DLNA master

Posts: 1396

Joined: Sat Jul 23, 2011 2:12 pm

Location: Manchester, UK

Post Sun Feb 26, 2012 7:11 pm

Re: Using CURL to force library refresh

Ah you let sickbeard run the script, i use sab to run the script

I think this must be only for QNAP users
Looking at out sickbeard.sh script, it changes serviiorefresh.py to sabToSickBeard.py everytime my Qnap restarts
I actually let Sabnzbd do all the renaming, i dont like how sickbeard renames the files
I just use sickbeard to send the nzb to sab and let sab do the rest :)

Thanks for this amazing script, works wonders!!
Sony Bravia 2010 52NX803 - Sony PS3 - Xbox 360
Serviio running on QNAP NAS 639 Pro - 1.6 Intel Dual Core - 2GB RAM and QNAP NAS 121 - 2Ghz ARM Marvell - 1GB RAM
Console using ServiiDroid for Android, ServiiMetro and ServiiWP for Windows Phone and WebUI for iOS
<<

DeanoX

Streaming enthusiast

Posts: 23

Joined: Thu Jan 03, 2013 10:30 pm

Post Tue Jan 15, 2013 2:58 pm

Re: Using CURL to force library refresh

phardwick wrote:Quick tip:

I use this to force a library refresh (I'm running on linux):

curl -X POST "http://localhost:23423/rest/action" -H "Content-Type: text/xml" -d "<action><name>forceLibraryRefresh</name></action>"

I plan on putting this into a daily cron job and disabling the auto library refresh.


Many Thanks :-) My windows batch file that creates a few directory based playlists now updates the library on completion. Perfect !
Zyxel NSA325 running Serviio 1.1 | Sony Bravia 2011 KDL-24EX320 / KDL-40EX723
Next

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 30 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.