我需要帮助使用pylast的library.add_album功能(python last.fm api包装器)

时间:2011-04-04 14:23:40

标签: python api last.fm

我正在尝试访问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)

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

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

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

2 个答案:

答案 0 :(得分:1)

这是pylast中的一个错误。

1957行(来自主干)应该是:

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

而不是:

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

您可以向作者here报告此问题。

答案 1 :(得分:0)

answer by miles82显示错误,而且是reported to pylast

不幸的是,几年内没有更新,所以我已经在我的fork of pylast中解决了这个问题。

相关问题