github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

garethr / lastbot

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 3
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A simple search bot for last.fm created during the last.fm hackday — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fixed layout of README 
garethr (author)
Mon Dec 15 02:05:14 -0800 2008
commit  a6f5ef58327f88978377dff0f482e1fc13006dce
tree    e0689779d9841273e465534b3bf9e07f870206c5
parent  ff193678559dc15b341574452b3b3dcb0b06f2b8
lastbot /
name age
history
message
file .gitignore Loading commit data...
file README.textile
directory ext/
file lastbot.py
README.textile

This XMPP bot was produced as part of the Last.fm hackday in London in December 2008. It provides a simple search interface over IM to a portion of the Last.fm API.

Usage

You can run it from the command line like so:

./lastbot.py

Note that if it crashes for whatever reason then it will simply stop. Again resilience could be backed in if you were using it for real.

When up and running you should be able to talk to it with your IM client. Simply send the user specified in the settings file a message like so:

search {query}

So if you wanted to search for “astley” you would type:

search astley

Which would probably give you:

you probably mean Never Gonna Give You Up by Rick Astley
http://www.last.fm/music/Rick_Astley/_/Never_Gonna_Give_You_Up

Richard Paul Astley (born February 6, 1966) is an English dance-pop singer,
songwriter and musician. He was born in Newton-le-Willows, St Helens,
Lancashire, England. Astley currently resides in Richmond, Surrey with his 
Danish girlfriend, Lene Bausager, and their daughter, Emilie. In 1985, Astley 
was playing the club circuit as a singer with a soul band named FBI, when he 
was seen by the record producer Pete Waterman and persuaded to come to London 
to work at the PWL recording studio.

If the first result that comes back isn’t the one you wanted you can ask for the next result by simply sending next in another message. You can use prev as well to come back through the set.

next

You can always send it a call for help at any time which should return the instructions to you via an IM message.

help

Which should return something like:

Personal LastFM search bot. Useful for looking for tracks you can't 
remember the full name of. Or for findind out who sung a track.

search: do a search for tracks
prev: get details about the previous track in the list
next: get details about the next track in the list

Installation

It requires the pylast library that can be
found at http://code.google.com/p/pylast. A compatible version is included in the ext directory and this is used unless you change the code.

You also need a settings file with the following constants defined:

USERNAME = ""
PASSWORD = ""
API_KEY = ""
API_SECRET = ""
SESSION_KEY = ""

The username and password are for the jabber server you want to connect to. You can get your API details from the Last.fm website at http://last.fm/api/account. Each application requires a session key that you will need to retrieve from Last.fm via the webservice. This is explained in the pylast documentation at http://code.google.com/p/pylast/wiki/Authentication

Limitations

It has a few limitations you should be aware of:

  • It’s purposely pretty small. You could extend it to cover every corner of the API, but it’s quite a big API. And this was designed as a simple example of writing a functioning bot.
  • Because of how it maintains state it doesn’t deal well with multiple people talking to it at once. It gets a bit confused in fact. This is more because it’s a hack than anything else, you could store the results in a hash keyed off a session identifier or similar if you wanted.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server