def single_score(self, a, b): if a == b: return 1.0 if playdar_resolver.soundex(a) == playdar_resolver.soundex(b): return 1.0 m = self.percentage_match(a, b) return m
def results(self, query): if query['artist'].lower() != 'mokele': return [] if soundex(query['track']) != soundex('hiding in your insides'): return [] return [{ 'artist': "Mokele", 'track' : "Hiding In Your Insides (python)", 'album' : "You Yourself are Me Myself and I am in Love", 'source' : "Mokele.co.uk", 'size' : 4971780, 'bitrate' : 160, 'duration' : 248, # NB this url should be url encoded properly: 'url' : "http://play.mokele.co.uk/music/Hiding%20In%20Your%20Insides.mp3", 'score' : 1.00 }]
def results(self, query): if query['artist'].lower() != 'mokele': return [] if soundex(query['track']) != soundex('hiding in your insides'): return [] return [{ 'artist': "Mokele", 'track': "Hiding In Your Insides (python)", 'album': "You Yourself are Me Myself and I am in Love", 'source': "Mokele.co.uk", 'size': 4971780, 'bitrate': 160, 'duration': 248, # NB this url should be url encoded properly: 'url': "http://play.mokele.co.uk/music/Hiding%20In%20Your%20Insides.mp3", 'score': 1.00 }]
def getStreamData(artistName, albumName, title): artists = searchArtists(artistName) artistlist = [] for artist in artists.get('artist', []): artistlist.append(artist['restArtistURL'][0]) if len(artistlist) == 0: return [] albumlist = [] if len(albumName) > 0: albums = searchAlbums(albumName) for album in albums.get('album', []): if album['artistResourceURL'][0] in artistlist: albumlist.append(album) if len(albumlist) == 0: # no album, try a track search instead # (may be on a best-of?) return artistTrackSearch(artistName, title) elif len(albumlist) == 1: # intersection of album/artist search is 1 album albumurl = "albums/%s" % os.path.basename(albumlist[0]['albumResourceURL'][0]) albumdata = _do_checked_query(albumurl) for tr in albumdata['tracks']: if tr['trackName'][0].lower() == title.lower(): return [_make_track_result(tr)] # If no matches, try a soundex - fixes the Foxy Lady/Foxey Lady problem at least! for tr in albumdata['tracks']: if playdar_resolver.soundex(tr['trackName'][0]) == playdar_resolver.soundex(title): return [_make_track_result(tr)] # no match, do a track search return artistTrackSearch(artistName, title) else: # more than 1 match. track search? return artistTrackSearch(artistName, title) else: # No album, just do an artist/track search return artistTrackSearch(artistName, title)