annotate core/magnatagatune/fm_retrieve_artist.py @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 # gets data from the last.fm webservice and
wolffd@0 2
wolffd@0 3 import pylast
wolffd@0 4 import sys
wolffd@0 5 import fm_network
wolffd@0 6
wolffd@0 7 network = fm_network.get_network()
wolffd@0 8
wolffd@0 9 # now you can use that object every where
wolffd@0 10 artistsrch = network.search_for_artist(sys.argv[1])
wolffd@0 11
wolffd@0 12 # did we find any ?
wolffd@0 13 if int(artistsrch.get_total_result_count()) == False:
wolffd@0 14 print('-1, None')
wolffd@0 15
wolffd@0 16 else:
wolffd@0 17
wolffd@0 18 #print alternatives
wolffd@0 19 artists = artistsrch.get_next_page()
wolffd@0 20 for artist in artists:
wolffd@0 21 mbid = unicode(artist.get_mbid())
wolffd@0 22 print(artist.get_name().encode('utf-8','ignore') + ', ' + mbid.encode('utf-8','ignore'))
wolffd@0 23