@jitterjames - Yes, but he wants to have his Hue switch to random colours at the beginning of a song *only* if the track does not include a colour term. If it has a colour term, he wants to set his lights to that colour using the Python script in this thread. Hence his attempt to alter the script.
@OK - You're on the right track but you can't do it quite like that in the case of the script that I posted.
The following should work. There are other ways too. I don't have time to spend on it now though, sorry.
import re
from System.Collections.Generic import *
def hueTunes(song,artist,album):
palette=["red","green","purple","yellow","blue","white","pink","orange"]
for colour in palette:
#checks if song title has one of the colours in it. The 1st colour found generates event "Hue.song", w/ payloads {1}:colour, {2}:title
if re.search(colour,song,re.I):
vc.triggerEvent("Hue.song", List[str]([colour, song]))
return
#if no colour in song, checks if artist name has one of the colours in it. If so, generates event "Hue.song", w/ payloads {1}:colour, {2}:artist
elif re.search(colour,artist,re.I):
vc.triggerEvent("Hue.song", List[str]([colour, artist]))
return
elif re.search(colour,album,re.I):
vc.triggerEvent("Hue.song", List[str]([colour, album]))#same thing, w/ album name. Put this above artist if you want it checked first.
return
else:
colour = False
if colour is False:
vc.triggerEvent("Hue.song",List[str](["random"]))#if no colour, trigger Hue.song event passing "random" as a colour.
return
wrt your weird character problem. Yes, there's probably a way to strip out the offending characters or whatnot. Again, I don't have time to help with that right now, but maybe someone else can suggest some solutions. If not, no biggee, the script will return an error and so nothing will change. When the next track plays, the python script will run again.