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

标签 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)

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/

相关文章:

javascript - 使用jquery获取json对象而不使用$.each

javascript - 利用并不总是存在的 JSON 属性。使用jquery

python - tensorflow:使用队列运行器有效地提供 eval/train 数据

python - Tornado 与 ThreadPoolExecutor

python - 完整性错误 : update or delete violates foreign key constraint. Django + PostgreSQL

c++ - mfc c++ 中是否存在用于 URL 编码的 API?

python - 如何访问装饰器属性?

youtube - 检索YouTube迪斯科播放列表

javascript - 如何一次停止所有 Soundcloud 流?