def top_tracks(self, artist): """Get artist top-tracks from 7Digital""" ## 7D API parameters py7digital.COUNTRY = sap.sevend_country py7digital.OAUTHKEY = sap.sevend_key ## Get artist + top tracks results = py7digital.search_artist(artist) if results: ## Save top-tracks in a {Digit:value} dict to manage TwiML <Gather> input artist = results.get_next_page()[0] top_tracks = map(lambda x: { 'title' : x.get_title(), 'preview' : self.preview_url(x.get_audio()), }, artist.get_top_tracks()) return { 'artist' : "%s" %(artist), 'tracks' : dict([i+1, top_tracks[i]] for i in range(len(top_tracks))) } else: return False
def top_tracks(self, artist): """Get artist top-tracks from 7Digital""" ## 7D API parameters py7digital.COUNTRY = sap.sevend_country py7digital.OAUTHKEY = sap.sevend_key ## Get artist + top tracks results = py7digital.search_artist(artist) if results: ## Save top-tracks in a {Digit:value} dict to manage TwiML <Gather> input artist = results.get_next_page()[0] top_tracks = map( lambda x: { 'title': x.get_title(), 'preview': self.preview_url(x.get_audio()), }, artist.get_top_tracks()) return { 'artist': "%s" % (artist), 'tracks': dict([i + 1, top_tracks[i]] for i in range(len(top_tracks))) } else: return False
def test_artist_search_returns_names_containing_stone(): artists = py7digital.search_artist("stones") for i in artists.get_next_page(): assert i.get_name().lower().find("stones") > -1
import py7digital # Search artist results = py7digital.search_artist("stones") print results.get_total_result_count() for artist in results.get_next_page(): print artist.get_name() # , artist.get_image(), artist.get_url(), artist.get_tags() print "\tTop tracks:" for top_track in artist.get_top_tracks(): print "\t\t", top_track.get_title(), top_track.get_isrc(), top_track.get_duration(), top_track.get_position(), top_track.get_explicit(), top_track.get_version() print "\tRec. Albums:" for rec_album in artist.get_recommended_albums(): print "\t\t", rec_album, rec_album.get_year() # , album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label() for album in artist.get_albums(5): print "\t", album, album.get_year(), album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label(), album.get_release_date(), album.get_added_date() for sim_album in album.get_similar(): print "\t\tSimilar:", sim_album, sim_album.get_year(), sim_album.get_artist() for track in album.get_tracks(): print "\t\t", track, track.get_isrc() # , track.get_url(), track.get_audio() # Browse artists starting with 'J' results = py7digital.browse_artists("j") print results.get_total_result_count() for artist in results.get_next_page(): print artist.get_name() # , artist.get_image(), artist.get_url(), artist.get_tags() for album in artist.get_albums(2): print "\t", album, album.get_year() # album.get_barcode(), album.get_type(), album.get_artist(), album.get_tags(), album.get_label() for track in album.get_tracks(): print "\t\t", track.get_title(), track.get_isrc() # , track.get_url(), track.get_audio() # Search albums