我想訪問pylast的類庫,但一定是做錯了什麼。我可以獲得大多數其他功能。下面是一個代碼示例它只是需要標準的實施例,並增加了什麼,我認爲是添加專輯我last.fm庫的正確方式:我需要幫助使用python(python last.fm api wrapper)的library.add_album功能
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)
我是新來的蟒蛇,所以我對不起,如果這是顯而易見的,我剛剛被困了幾天,並決定問。
非常感謝!這是我一直感興趣的pylast的一個功能,它讓我瘋狂!萬分感謝! – adam 2011-04-04 20:49:36