1
나는 last.fm API
에서 최고 인기 태그를 가져 get_top_tags()
방법을 사용하는 기능이 있습니다파이썬 - Last.fm의 API의 모든 장르 태그를 검색
def lastfm_tags(tag):
tag_weight = {}
result = last.get_top_tags()
for tag in result:
tag_weight[str(tag.item.get_name())] = str(tag.weight)
tag_weight = {k: int(v) for k, v in tag_weight.items()}
return tag_weight
print lastfm_tags('pop')
인쇄 :
{'industrial': 533792, 'punk': 849254, 'indie': 1972289, 'metal': 1214142, 'heavy metal': 652768, 'japanese': 428483, 'pop': 1874644, 'new wave': 399642, 'black metal': 772854, 'rap': 513369, 'ambient': 1030860, 'alternative': 2059622, 'hard rock': 821047, 'electronic': 2289385, 'blues': 531227, 'folk': 882684, 'classic rock': 1123889, 'alternative rock': 1123671, '90s': 447817, 'Progressive metal': 407423, 'indie rock': 850647, 'electronica': 614612, 'female vocalists': 1558073, 'Soundtrack': 529623, 'dance': 769325, 'psychedelic': 458873, '80s': 752035, 'piano': 410036, 'chillout': 636262, 'post-rock': 426621, 'punk rock': 518635, 'jazz': 1117396, 'seen live': 2098252, 'instrumental': 818216, 'singer-songwriter': 810484, 'acoustic': 461045, 'hardcore': 656385, 'funk': 399980, 'Classical': 539399, 'Hip-Hop': 814911, 'death metal': 671617, 'soul': 641317, 'british': 667770, 'thrash metal': 465438, 'hip hop': 395139, 'rock': 3879776, 'metalcore': 444620, 'german': 409117, 'Progressive rock': 693750, 'experimental': 1010752}
나는 또한 검색 수를 예술가에 대한 tags
:
def lastfm_artist_to_tags(artist):
tag_weight = {}
result = last.get_artist(artist).get_top_tags()
for tag in result:
tag_weight[str(tag.item.get_name())] = str(tag.weight)
tag_weight = {k: int(v) for k, v in tag_weight.items()}
return sorted(tag_weight.items(), key=lambda x: x[1], reverse=True)
더 구체적인 태그 추가 :
가능한 모든 태그를 가져 오는 방법이 없습니까?
은 완전히 의미가 있습니다. 감사 –