Page 1 of 1

Force library refresh of DLNA server (Serviio)

Posted: August 14th, 2011, 12:28 am
by J03 8LACK
Here is a python script that will force a Serviio library refresh after downloading.

Serviio is a free UPnP/DLNA media streaming server that has a auto library refresh. But who wants to wait for the library to refresh or manually refresh every time you download something.

Code: Select all

#!/usr/bin/env python
import httplib
connection = httplib.HTTPConnection("localhost",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,
I have tested this on python 2.6 windows version, but I don't see anything that would cause any problems in Linux.
If you have a Serviio bounded IP address change the connection line.

example:
connection = httplib.HTTPConnection('1.2.3.4:23423')


Tell me what you think?
J03

Re: Force library refresh of DLNA server (Serviio)

Posted: August 18th, 2011, 12:53 pm
by Xmantium
Thanks J03, your the man! O0
This code with location of python worked a charm for me!

Code: Select all

#!/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()
#print result.status

Re: Force library refresh of DLNA server (Serviio)

Posted: September 27th, 2011, 8:57 pm
by Xmantium
This script no longer works with latest 0.6 build, tried running it but does not return 200 value

Re: Force library refresh of DLNA server (Serviio)

Posted: September 29th, 2011, 2:52 am
by Mar2zz
Can you see what it returns? (run it in terminal (python '/path to script' to see what happens). Post your output and it can be fixed.

Re: Force library refresh of DLNA server (Serviio)

Posted: September 30th, 2011, 9:51 am
by J03 8LACK
Hey Guys,

It seem the REST interface is binding itself to the Serviio server differently

And the code it does send back is a 415. They are working on it over at the Serviio form.

http://forum.serviio.org/viewtopic.php? ... 2&start=10

Will update if a solution is found
J03

Re: Force library refresh of DLNA server (Serviio)

Posted: September 30th, 2011, 8:30 pm
by J03 8LACK
Here is the fix

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: Select all

#!/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,
I have updated the first post with the above code.
hope it helps
J03