我正在尝试访问pylast的库类,但必须做错了什么。我可以使用其他大多数功能。以下是一个代码示例,仅采用标准的工作示例,并添加了我认为是将相册添加到last.fm库的正确方法:

import pylast

# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from http://www.last.fm/api/account for Last.fm
API_KEY = "80a1c765efb52869575821c03d93a30e" # this is a sample key
API_SECRET = "2ba567f5b0d74c6cc6a8d07ef2cbc2d"

# In order to perform a write operation you need to authenticate yourself
username = "astroid0"
password_hash = pylast.md5("xxx")

network = pylast.LastFMNetwork(api_key = API_KEY, api_secret =
    API_SECRET, username = username, password_hash = password_hash)

# now you can use that object every where
artist = network.get_artist("System of a Down")
artist.shout("<3")


track = network.get_track("Iron Maiden", "The Nomad")
track.love()
track.add_tags(("awesome", "favorite"))

## This is the area causing trouble
library1 = pylast.Library(user = "astroid0", network = "LastFM")
album1 = network.get_album("The Rolling Stones", "Sticky Fingers")
library1.add_album(album1)


ss pylast的库类,但是一定做错了。我可以使用其他大多数功能。以下是一个代码示例,仅采用标准的工作示例,并添加了我认为是将相册添加到last.fm库的正确方法:

 library1 = pylast.Library(user = "astroid0", network = "LastFM")
 album1 = network.get_album("The Rolling Stones", "Sticky Fingers")
 library1.add_album(album1)


我是python的新手,所以很抱歉,如果这很明显,我已经被困了好几天,并决定询问。

最佳答案

这是pylast中的错误。

1957行(从中继线开始)应为:

params["artist"] = album.get_artist().get_name()


代替:

params["artist"] = album.get_artist.get_name()


您可以将问题报告给作者here

关于python - 我需要使用pylast的library.add_album功能(python last.fm api包装器)进行帮助,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5539867/

10-08 23:32