When you start playing a song it query's (through the Last.FM API) "track.getSimilar" http://www.last.fm/api/show?service=319 , then sweeps through your library to find a match and then appends the matched song to the playlist. If there isn't any track similarity then it query's "artist.getSimilar" http://www.last.fm/api/show?service=119 and appends a song from the artist that comes closest.

That way you could start listening to one song and the script will create the playlist for you based on your first choice.

I'm currently using MediaMonkey as my music player, been meaning to use XBMC (one program for all media would be much easier) but i really miss that feature.

This is similar to Pandora, but with a local library, and similar to the 'Smart Playlist' feature available in...uhm...can't recall now (the company was bought out, but basically it scanned all your music and then could generate smart lists of similar music based on a seed song).

This seems like a good way to get around the need for a massive backend database for music 'similarity' storing/scoring.

A simple script that reads the current artist and track info that is playing in XBMC, passes this info off the last.fm api, requesting similar artist and tracks. The script will then search the music db for artists or songs that match the API response. If a match is found, track is appended to current music queue.

So querying the last.fm api is fairly straightforward, and existing libraries exist to do this.

Not sure about the XBMC side of things.

- how can python scripts interact with the database? Which is preferred json , web api, or directly with the sqllite library?
- Is it possible to control a playlist from a script? Can the script continually run in the background while playing music?

This is also something I'd like to be able to run. Curious if there was any progress made on this script? I'd like to take a shot at implementing something or expanding on something else already implemented.

I've started working on this script and have made some progress, but there are a few snags:

The Last.FM api requires an API key. I have acquired my own for testing purposes, but this might be a bit of a show-stopper if we're to make this into a user friendly addon.

I query similarTrack recursively until the playlist has 25 items after 5 tries.
This is a bit time consuming and it might exceed the traffic limits stated in the api eula.

The script is far from finished, but if someone wants to try it out, you can find the script here: http://code.google.com/p/lastfmplaylistgenerator/
Feel free to modify/improve and please share your thoughts/code.
I'm just trying to learn python, so development is slow and the code probably needs a good cleanup.

Thanks, was hoping to find something similar to what was described in this thread.. rather than building an entire playlist, only query for the next 1-2 tracks to play based on the current song - changes if I manually select a different song