2008-12-10, 06:19
Hi all--
I'm hoping to add an artist biography of the artist playing inside of the RunXM interface. I've gotten it to the point where it will display the biography and scroll down/up, but one thing I didn't expect is that, unlike overwritting the information for the artist/song/album upon updates using SetLabel(), the controltextbox SetText() basically writes over itself when updated. So you basically end up seeing several layers of text.
To fix this, I was thinking of doing something like if X variable doesn't exist, perform these functions for the first run-through, and if it does exist to pass on updating the biography until the artist changes; at this point, perform a removeControl(), then reupdate the biography, and redisplay. However, I can't figure out how to do this in python, since if a variable doesn't exist, the script quits.
Is this something easy to fix, or is this not possible to accomplish?
Here's the code for the biography display. If you need anything else, let me know.
I'm hoping to add an artist biography of the artist playing inside of the RunXM interface. I've gotten it to the point where it will display the biography and scroll down/up, but one thing I didn't expect is that, unlike overwritting the information for the artist/song/album upon updates using SetLabel(), the controltextbox SetText() basically writes over itself when updated. So you basically end up seeing several layers of text.
To fix this, I was thinking of doing something like if X variable doesn't exist, perform these functions for the first run-through, and if it does exist to pass on updating the biography until the artist changes; at this point, perform a removeControl(), then reupdate the biography, and redisplay. However, I can't figure out how to do this in python, since if a variable doesn't exist, the script quits.
Is this something easy to fix, or is this not possible to accomplish?
Here's the code for the biography display. If you need anything else, let me know.
Code:
search = urllib.urlencode({'m':'all','p':songData['artist']})
artistURL = urllib.urlopen("http://search.music.yahoo.com/search/?" + search)
#print "http://search.music.yahoo.com/search/?" + search
SearchHTML = artistURL.read()
target = '<a href="http://music.yahoo.com/ar-'
if SearchHTML.find(target) != -1:
SearchHTML = SearchHTML[SearchHTML.find(target) + len(target) :]
data = SearchHTML[: SearchHTML.find('---')]
print data
if (data):
artistBIO = urllib.urlopen("http://music.yahoo.com/ar-" + data + "-bio--")
print "http://music.yahoo.com/ar-" + data + "-bio--"
BioHTML = artistBIO.read()
target = '<table cellpadding="5" cellspacing="0" border="0" width="401">'
if BioHTML.find(target) != -1:
BioHTML = BioHTML[BioHTML.find(target) + len(target) :]
rawHTML = BioHTML[: BioHTML.find('</td>')]
#print rawHTML
target = '<td>'
if rawHTML.find(target) != -1:
biography = rawHTML[rawHTML.find(target) + len(target) :]
biography = str(biography)
biography = re.sub('<P>', '\n ', biography)
biography = re.sub('</P>', ' ', biography)
biography = re.sub('<p>', '\n', biography)
biography = re.sub('</p>', ' ', biography)
biography = re.sub('<BR>', '\n\n', biography)
#print biography
self.BiographyTEXT = xbmcgui.ControlTextBox((int(screenX * .3)),(int((screenY * .2) * 2.25)),int(screenY),(int(screenX * .3)),"font12")
self.addControl(self.BiographyTEXT)
self.BiographyTEXT.setText(biography)
self.setFocus(self.BiographyTEXT)