alaingilbert/Turntable-API — pull request #80 by lemonsourkid (2012-06-23 18:49:50+00:00)
Title: Python: Changing isinstance str to basestring

basestring checks if the value is a str or unicode type so that either can be used because unicode data is sent to the bot. Unicodes don't register in Python as strings but unicodes register as basestring types.
Eg:

```python
def newSong(data):
global genre,artist,lameGenres,lameArtists
songData = data['room']['metadata']['current_song']
DJid = songData['djid'] # THIS DATA IS A UNICODE TYPE!
artist = songData['metadata']['artist']
genre = songData['metadata']['genre']
for i in range(len(lameGenres)): # Note: for loop is used because lameGenres contains substrings of disallowed genres in case there are 2 different genres such as "Rap" and "Rap/Hip Hop"
if lameGenres[i].lower() in genre.lower():
eebot.remDj(DJid) # REMDJ WILL NOT WORK WITH UNICODE TYPES!
eebot.speak('%s is not allowed!' % genre)
break
for i in range(len(lameArtists)):
if lameArtists[i].lower() in artist.lower():
eebot.remDj(DJid) # SAME AS ABOVE
eebot.speak('This kind of music is not allowed!')
break
```