Mercurial > hg > camir-aes2014
annotate core/magnatagatune/fm_retrieve_album.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 srch = network.search_for_artist(sys.argv[1]) |
wolffd@0 | 11 |
wolffd@0 | 12 |
wolffd@0 | 13 # did we find any ? |
wolffd@0 | 14 if (int(srch.get_total_result_count()) == False): |
wolffd@0 | 15 print('-1, None') |
wolffd@0 | 16 |
wolffd@0 | 17 else: |
wolffd@0 | 18 |
wolffd@0 | 19 #print first 200 results |
wolffd@0 | 20 albums = srch.get_next_page() |
wolffd@0 | 21 for album in albums: |
wolffd@0 | 22 mbid = unicode(album.get_mbid()) |
wolffd@0 | 23 print(album.get_name().encode('utf-8','ignore') + ', ' + mbid.encode('utf-8','ignore')) |