parsing sources.xml
#1
I'm trying to get the music source paths from sources.xml with python script.
I can parse it with minidom but I'm looking for other ways. One of them was http api Config(getbookmarks).
I found the post saying the json should be used instead but cannot find the relevant command.

How can I preferably get music/videos paths from python script?
Reply
#2
pru1 Wrote:I'm trying to get the music source paths from sources.xml with python script.
I can parse it with minidom but I'm looking for other ways. One of them was http api Config(getbookmarks).
I found the post saying the json should be used instead but cannot find the relevant command.

How can I preferably get music/videos paths from python script?


The following JSON-RPC call provides the video sources:

Code:
{"jsonrpc": "2.0", "method": "Files.GetSources", "params": {"media": "video"}, "id": 1}

Though to be honest, I think parsing the XML file itself might be still the better way, as the above JSON-RPC call returns 'multipath://' for any source that uses multiple paths.
Reply
#3
Thanks for that.

The problem with the file parser I noticed is the left over from minidom (minidoom?).
Simply calling:
Code:
doc = parse(file)
allocates some resources that seem to be freed only by the garbage collector after the python script finishes. In the script I expect getting the WindowId=13000 (to bind the remote keys to). Thus when I re-enter the script immediately I get 13001 etc. It takes about 10s to clean the minidom garbage and for that time the windowId is considered as being in use. So to get the WindowId=13000 I have to wait those 10s before I can call the script again. Unless I missed something…
Reply
#4
Self response - forcing garbage collection helps with sax/minidom.
Reply

Logout Mark Read Team Forum Stats Members Help
parsing sources.xml0