I’m playing around with the plugins capabilities of Plex. I more or less understand the structure and the workflow of plugins, I can do general programming in Python, but I don’t know too much on XML.
I’m trying to parse the contents of a query to the Spotify public API, which is in fact an HTML file as the following one:
My question is: could somebody help writing a parser for such a structure? It shouldn't be difficult for somebody familiar with XML, but for me it will mean struggling many hours with the XML library for a quite small piece of code.
But it (obviously does not work). What I don't see is how should I use namespaces when querying the XML object. In the XML that I get in response, the xml starts with:
What I have understood from examples is that I should use the namescape "opensearch':'http://a9.com/-/spec/opensearch/1.1/" when querying for "totalResults", "startIndex", etc., I am wrong?
But, what about the artist blocks? I don't see how can I use xpath to obtain the list of artist in that XML?
check out the deviant art plugin for a reference on namespaces. you can put both namespaces into one variable ( i believe that’s the right terminology) I helped pooploser write that one for his first plugin. It looks awefully similar to what you are trying to do.
I see. My problem was that I did no try to add a name to the anonymous namespace in my XML. Now I correctly parse the XML. Thanks!!!
Now I have another problem. I’m creating TrackItems for each of the parsed tracks. This TrackItems call a callback (this works) but I do not know what return here. My idea is to call a helper from the callback function which carries out some task and the return. But, what should I return from the callback? Plex is not intended to reproduce anything, but to just launch the actual reproductor in background. Is all this possible?
After a little googling, it turns out there is a spotify app for plex. I would imagine that a lot of what you need help with (helper app) and what you may need help with in the future will be in that code as examples for you.
After re-reading my last post, I don’t want you to think I don’t want to help. I just wanted to point out a good resource for you. If you have any questions after looking at the spotify app, please continue to post them.
No problem. I will take a look at the Spotify plugin, although my approach is a bit different (I'm only using the open API to query for music information, not the API to access directly to the music). Anyway, thanks for trying helping. Most of the times there's only the need for somebody to point in the right direction to find out what you were doing wrong.
Ok. So, what if I do not want to actually reproduce the music file with Plex but to launch a helper which does it in the background (without gaining focus). Is this possible? Should I use another Media Item to show the results of my query?