I want to get all the song tags through the Last.fm API from Pylast

experts

Currently, I want to use all the song tags in a research project. Of course I have Pylast on my arm. But there is no detailed document on Pilast.

Then, can someone tell me how to use Pylast to get all song tags via last.fm api?

Thank you very much.

+4
source share
2 answers

It doesn't seem like what you want is actually possible with the last.fm api. Only top-level tags are available through api . However, they are not completely clear what constitutes the top tag. So this may be enough for your needs. The attempt to create several different performers of the number of results that I get is very different.

Here is a sample code to get you started.

from pylast import * #Set up the api key, secret, user and password here network = get_lastfm_network(API_KEY,API_SECRET, user, password_hash) userData = User(user, network) track = network.get_track("Cher", "Believe") #Get the tags aa TopItem object. topItems = track.get_top_tags(limit=None) for topItem in topItems: print topItem.item.get_name(), topItem.weight 

pylast really has really good documentation. What I do most often is just start the shell and call for help on different pylast objects. It explains most of the function. The source is also very readable, so this is also a good place to find out how it works. So in this case:

 help(TopItem) help(Track) help(Tag) 
+4
source

All the tags that I don’t have, if you can get it, but the tag.getTopTags () method has the num_res parameter, you can do something like:

http://ws.audioscrobbler.com/2.0/?method=tag.getTopTags&api_key=[api_key_here] & num_res = 1000

It worked for me.

0
source

Source: https://habr.com/ru/post/1386248/


All Articles