diff core/magnatagatune/fm_retrieve_artist_tags.py @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/magnatagatune/fm_retrieve_artist_tags.py	Tue Feb 10 15:05:51 2015 +0000
@@ -0,0 +1,26 @@
+# gets data from the last.fm webservice and 
+
+import pylast
+import sys
+import fm_network
+
+network = fm_network.get_network()
+
+# now you can use that object every where
+if sys.argv[2] == '0':
+    artist = network.get_artist(sys.argv[1])
+else:
+    artist = network.get_artist_by_mbid(sys.argv[1])
+
+# retrieve artist tags
+tags = artist.get_top_tags()
+
+# put in comma separated list
+for tag in tags[:-1]:
+    print(tag.item.get_name().encode('utf-8','ignore')+ ', ' + tag.weight.encode('utf-8','ignore'))
+
+if len(tags) > 0:
+    print(tags[-1].item.get_name().encode('utf-8','ignore') + ', ' + tags[-1].weight.encode('utf-8','ignore'))
+
+else:
+    print(-1)