Automated feedback broadcast script
#1
Hi! bare with me on this long post.
I´ve been looking at the HTTP API for ways to control/get status from the XBMC that im running on my PC.
The idea is to get a controlsystem like AMX/Crestron to control and get updates from the XBMC. I saw in the API manual that there is a broadcast function that makes XBMC send me notifications of changes, BUT the information that the broadcast function sends out is limited, i would like to get info of what page/function is active, playbacktime, playerstatus, coverart, rating, albuminfo etc etc in other words as much info as possible.
Of course I could get the controlsystem to poll the xbmc for all this info but this would make a very heavy traffic.

My idea for a solution was to write a script in pyhton that would keep track of all this information and send them out in UDP (or TCP) as a already properly formatted string to the controlsystem, the controlsystem just have to listen and cut the string at the propper delimiter. This string would be sent 2 times a second so the playingtime doesn’t seem slow.

This was 2 weeks ago...i´m going crazy.
Its very hard to find information on this application because all other scripts are interfacing with actions or buttonevents but I would like to have the true feedback off the xbmc all the time, not just when a button is pressed.

Questions 1-5

1. Is this even possible to do in Pyhton or does the language/system have limitations for this application. for example, I cant find any form of command in pyhton that will notify me when a change is made in for example playingstatus or playbacktime. Systems that I have programmed before have some kind of interrupt or "change" function. Now I have to continuously do a wile if loop, is this accurate or normally this is not how you would do it?

include xbmc
Artist = "X"
OldArtist = ""
while 1:
if (xbmc.Player().isPlaying() == 1):
tag = xbmc.Player().getMusicInfoTag()
Artist = tag.getArtist()

if OldArtist != Artist:
Artist = tag.getArtist()
Title = tag.getTitle()
Genre = tag.getGenre()
URL = tag.getURL()
OldArtist = Artist
print "Artist:", Artist, "Titel:", Title, "Genre:", Genre, "URL:", URL

2. I’m having trouble with the Boolean conditions defined in "list of Boolean functions" xbmc wiki. for example:
if (xbmc.Player().isPlaying() == 1): works
but according to the document it sould be:
if (xbmc.Player().Playing() == 1):
why is that? and also i don’t get Boolean condition Player.HasMedia
to work at all...what am i doing wrong.


3. What is the cox.net link below?? Is it built in functions that i could recall from pyhton and if so what is the difference of those and the other link of built in functions from xbmc wiki?
http://members.cox.net/alexpoet/download.../xbmc.html
http://wiki.xbmc.org/?title=List_of_Built_In_Functions

At the members.cox link the first class is InfoTagMusic but i cant get this to work, but further down in the document there is player.MusicTagInfo and this works, does anybody know what the difference is.


4. Allow wondering about Infolabels defined in "Labels Available In XBMC" at xbmc wiki.
http://wiki.xbmc.org/?title=InfoLabels
I don’t seem to find an explanation to these infolabels how could i use them?


5. If i run the script below it is a very tight if (xbmc.Player().isPlaying() == 1):
loop that is giving me problems when i change song, because the if statement was true at the moment (the player was playing before i changed song)the script asks for function tag = xbmc.Player().getMusicInfoTag()
but now the player is changing song so its not playing at the moment and i get a message in the debug that follows: "Exception: XBMC is not playing any music file" and the script stops, why is that?

include xbmc
Artist = "X"
OldArtist = ""
while 1:
if (xbmc.Player().isPlaying() == 1): #is it playing
tag = xbmc.Player().getMusicInfoTag() #update info to tag
Artist = tag.getArtist()

if OldArtist != Artist: #look for change in for example artist
Artist = tag.getArtist()
Title = tag.getTitle()
Genre = tag.getGenre()
URL = tag.getURL()
OldArtist = Artist
print "Artist:", Artist, "Titel:", Title, "Genre:", Genre, "URL:", URL

I’m greatly appreciating any help on my questions, and needless to say im a newbe at phyton and im really stuck...feeling hopeless
Best Regards
Niklas
Reply
#2
Okej, might hve gone a little overboard with the questions. after 2 more days of trying iv figgured out the infolabels=). Let´s narrow it down to one question.
Do you think it possible to read out many (allmost all) of the infolables and send them out throug at udp server function? Or is this to CPU/proces demanding?
Thanks in advance
Niklas
Reply

Logout Mark Read Team Forum Stats Members Help
Automated feedback broadcast script0