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

发布于 2024-10-30 18:09:45 字数 1414 浏览 0 评论 0原文

我正在尝试访问 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新手,所以如果这是显而易见的,我很抱歉,我被困了好几天了,决定问一下。

I am trying to access the library class of pylast, but must be doing something wrong. I can get most other features to work. The following is a code example which just takes the standard working example and adds what I believe to be the correct way of adding an album to my last.fm library:

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 the library class of pylast, but must be doing something wrong. I can get most other features to work. The following is a code example which just takes the standard working example and adds what I believe to be the correct way of adding an album to my last.fm library:

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

I am new to python, so I am sorry if this is obvious, I have just been stuck for days now, and decided to ask.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羁客 2024-11-06 18:09:45

这是 pylast 中的一个错误。

第 1957 行(来自主干)应为:

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

而不是:

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

您可以在此处向作者报告问题

It's a bug in pylast.

Line 1957 (from trunk) should be:

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

instead of:

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

You can report the issue to the author here.

箜明 2024-11-06 18:09:45

miles82 的回答显示了该错误,并且已报告给 pylast

不幸的是,几年来没有更新,所以我在我的 pylast 分支中修复了这个问题。

The answer by miles82 shows the bug and it's been reported to pylast.

Unfortunately there's been no updates in a few years so I've fixed this in my fork of pylast.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文