wclastfm

last.fm api python script


In [3]:
import pylast

In [4]:
opke = open('/home/wcmckee/lfm.txt', 'r')
rekde = opke.read()

In [5]:
opke.close()

In [6]:
opsec = open('/home/wcmckee/lfm-sec.txt', 'r')

resec = opsec.read()

In [7]:
opsec.close()

In [8]:
oppas = open('/home/wcmckee/lfm-p.txt', 'r')

opred = oppas.read()

In [10]:
oppas.close()

In [14]:
phash = pylast.md5(str(opred))

In [ ]:


In [ ]:
pylast.

In [12]:
usr = 'galf666'
pa = str(opred)

In [16]:
netwo = pylast.LastFMNetwork(str(rekde), api_secret= str(resec), username = usr, password_hash= phash)


---------------------------------------------------------------------------
WSError                                   Traceback (most recent call last)
<ipython-input-16-b4546b839405> in <module>()
----> 1 netwo = pylast.LastFMNetwork(str(rekde), api_secret= str(resec), username = usr, password_hash= phash)

/usr/local/lib/python2.7/dist-packages/pylast/__init__.pyc in __init__(self, api_key, api_secret, session_key, username, password_hash)
    864                 "track": "music/%(artist)s/_/%(title)s",
    865                 "group": "group/%(name)s",
--> 866                 "user": "user/%(name)s",
    867             }
    868         )

/usr/local/lib/python2.7/dist-packages/pylast/__init__.pyc in __init__(self, name, homepage, ws_server, api_key, api_secret, session_key, submission_server, username, password_hash, domain_names, urls)
    192             sk_gen = SessionKeyGenerator(self)
    193             self.session_key = sk_gen.get_session_key(
--> 194                 self.username, self.password_hash)
    195 
    196     """def __repr__(self):

/usr/local/lib/python2.7/dist-packages/pylast/__init__.pyc in get_session_key(self, username, password_hash)
   1267         request.sign_it()
   1268 
-> 1269         doc = request.execute()
   1270 
   1271         return _extract(doc, "key")

/usr/local/lib/python2.7/dist-packages/pylast/__init__.pyc in execute(self, cacheable)
   1148             response = self._get_cached_response()
   1149         else:
-> 1150             response = self._download_response()
   1151 
   1152         return minidom.parseString(_string(response))

/usr/local/lib/python2.7/dist-packages/pylast/__init__.pyc in _download_response(self)
   1139         response_text = XML_ILLEGAL.sub("?", response_text)
   1140 
-> 1141         self._check_response_for_errors(response_text)
   1142         return response_text
   1143 

/usr/local/lib/python2.7/dist-packages/pylast/__init__.pyc in _check_response_for_errors(self, response)
   1166             status = e.getAttribute('code')
   1167             details = e.firstChild.data.strip()
-> 1168             raise WSError(self.network, status, details)
   1169 
   1170 

WSError: Invalid API key - You must be granted a valid key by last.fm

In [ ]:


In [ ]:


In [ ]:


In [ ]:
'''
Created on 6/12/2012
 
@author: Will

import pylast
import pprint
 
API_KEY = 'KEY'
API_SECRET = 'SEC'
 
username = "USERNAME"
password_hash = pylast.md5("YOUWILLNEVERGETTHIS")
 
network = pylast.LastFMNetwork(API_KEY, api_secret =
API_SECRET, username=username, password_hash=password_hash)
 
arti = raw_input("Enter the artist name: ")
 
artist = network.get_artist(arti)
 
cart = artist.get_bio_content()
pprint.pprint(cart)
test = artist.get_similar(20)
pprint.pprint(test)
 
 
doc = open('hellothere', 'w')
doc.write('---~~~--- ')
doc.write(arti)
doc.write('---~~~--- ')
doc.write('\n')
doc.write(cart)
doc.write('\n')
doc.write(arti)
doc.write('---~~~--- ')
doc.write('\n')
doc.close 
'''