2007-07-28, 02:38
Does anyone know the optimal method for retrieving album review text for the currently playing song?
I could not find a programmatic way to review text in either infolabels or the xbmc python library.
HTTP-APIs QueryMusicDatabase seemed to have the most potential, however I have run into two problems.
1) There seems to be no method to match up the currently playing song with a songID. If the song is being played in library mode the sondID seems to be available as part of the file location, the last part before mp3 in the api command GetCurrentlyPlaying , however it is not available if something is being played off a share - even if that song has been placed in the library and review text has been obtained. So, anyone know of a method to get the song ID?
2) Without a songID I ended up creating a query with all known information about the currently playing song. They query works great from a browser but fails when called from xbmc.executehttpapi. I read in xbmc AJAX interface skin thread that excutehttpapi with QueryMusicDatabase seems to fail if the query has a comma? Does anyone know if that is accurate or is something more complicated going on? It seems to be the case because my query starts off with "select strReview from albuminfo,..." and returns every album review in the database. Do I need to escape the commas?
Here is the code I am using:
Now if I print the quoted string, put it in a browser as the argument to http://xbmc/xbmcCmds/xbmcHttp?command=Qu...icDatabase it works correctly.
Is this a bug or is there something I misunderstand?
Thanks!
I could not find a programmatic way to review text in either infolabels or the xbmc python library.
HTTP-APIs QueryMusicDatabase seemed to have the most potential, however I have run into two problems.
1) There seems to be no method to match up the currently playing song with a songID. If the song is being played in library mode the sondID seems to be available as part of the file location, the last part before mp3 in the api command GetCurrentlyPlaying , however it is not available if something is being played off a share - even if that song has been placed in the library and review text has been obtained. So, anyone know of a method to get the song ID?
2) Without a songID I ended up creating a query with all known information about the currently playing song. They query works great from a browser but fails when called from xbmc.executehttpapi. I read in xbmc AJAX interface skin thread that excutehttpapi with QueryMusicDatabase seems to fail if the query has a comma? Does anyone know if that is accurate or is something more complicated going on? It seems to be the case because my query starts off with "select strReview from albuminfo,..." and returns every album review in the database. Do I need to escape the commas?
Here is the code I am using:
Code:
from spyceModule import spyceModule
import xbmc
import urllib
class albumreview(spyceModule):
def getReview(self, musicinfo):
sqlStatement = 'select strReview from albuminfo,album,artist,song,genre where album.idAlbum = albuminfo.idAlbum and album.idArtist = artist.idArtist and song.idArtist = artist.idArtist and song.idAlbum = album.idAlbum and album.idGenre = genre.idGenre '
sqlStatement += 'and album.strAlbum = \'' + self.escape(musicinfo.getAlbum()) + '\' '
sqlStatement += 'and artist.strArtist = \'' + self.escape(musicinfo.getArtist()) + '\' '
sqlStatement += 'and song.strTitle = \'' + self.escape(musicinfo.getTitle()) + '\' '
sqlStatement += 'and genre.strGenre = \'' + self.escape(musicinfo.getGenre()) + '\' '
sqlStatement += 'NOT NULL LIMIT 1'
# print urllib.quote(sqlStatement)
return xbmc.executehttpapi("QueryMusicDatabase(" + sqlStatement + ")" )
def escape(self,string):
return string.replace('\'','\'\'')
Now if I print the quoted string, put it in a browser as the argument to http://xbmc/xbmcCmds/xbmcHttp?command=Qu...icDatabase it works correctly.
Is this a bug or is there something I misunderstand?
Thanks!