Force library refresh of DLNA server (Serviio)

Come up with a useful post-processing script? Share it here!
Post Reply
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Force library refresh of DLNA server (Serviio)

Post 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
Last edited by J03 8LACK on September 30th, 2011, 8:33 pm, edited 1 time in total.
Xmantium
Newbie
Newbie
Posts: 13
Joined: July 10th, 2011, 4:43 pm

Re: Force library refresh of DLNA server (Serviio)

Post 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
Xmantium
Newbie
Newbie
Posts: 13
Joined: July 10th, 2011, 4:43 pm

Re: Force library refresh of DLNA server (Serviio)

Post by Xmantium »

This script no longer works with latest 0.6 build, tried running it but does not return 200 value
User avatar
Mar2zz
Jr. Member
Jr. Member
Posts: 85
Joined: February 4th, 2011, 8:30 am
Contact:

Re: Force library refresh of DLNA server (Serviio)

Post 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.
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: Force library refresh of DLNA server (Serviio)

Post 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
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: Force library refresh of DLNA server (Serviio)

Post 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
Post Reply