From Amarok Wiki
Contents |
Description
Similar to Audioscrobbler but with a different focus, there is the site musicmobs.com, which has at the moment only plugins for a few players available. With the following script you can upload your Amarok database to musicmobs. You will need a musicmobs account to do so.
Update
The Musicmobs XML-RPC API is depricated. The new, supported API is the REST interface seen here:
This API also supports playlist syncing.
Prerequisites
For this script you need a recent version of Python, the SQLite libraries / command client (Version 3.2) and the APSW module for Python installed.
The script
Save this file as amarok2musicmobs.py
#!/usr/bin/python
# amaroK to musicmobs scripts
# (C) 2005 by Titus Stahl <mail@titus-stahl.de>
# Licensed under the GPL Version 2 and above
import apsw,sys
import base64
import xmlrpclib
def submit(file, username, password):
artists = {}
albums = {}
genres = {}
#Fetch artists
connection=apsw.Connection(file)
cursor=connection.cursor()
for aid,aname in cursor.execute("select id, name from artist"):
artists[aid] = aname
for aid,aname in cursor.execute("select id, name from album"):
albums[aid] = aname
for aid,aname in cursor.execute("select id, name from genre"):
genres[aid] = aname
s = ""
for title, album, artist, genre, score, counter in cursor.execute("select tags.title, tags.album, tags.artist, tags.genre, statistics.percentage, statistics.playcounter FROM tags, statistics WHERE tags.url = statistics.url"):
if score <= 20:
score = 20
if score > 20 and score <= 40:
score = 40
if score > 40 and score <= 60:
score = 60
if score > 60 and score <= 80:
score = 80
if score > 80:
score = 100
s = s + artists[artist] +"\t" + title + "\t"+str(counter)+"\t"+albums[album]+"\t"+str(score)+"\n"
#print s
bs = base64.encodestring(s.encode('ascii', 'ignore'))
server = xmlrpclib.ServerProxy("http://www.musicmobs.com/services/xmlrpc.php")
print "OK"
try:
res = server.musicmobs.updateProfile(username, password, bs)
except xmlrpclib.ProtocolError:
print "MusicMobs.com plugin: Could not submit tracks (Network Error)"
except:
print "XML-RPC ERROR: Check your credentials"
if __name__ == "__main__":
if len(sys.argv) < 4:
print "Usage: amarok2musicmobs.py /path/to/your/collection.db username password"
else:
submit(sys.argv[1],sys.argv[2],sys.argv[3])
Usage
If you mark the file as executable and move it somewhere into your path, you can update your metadata as follows:
amarok2musicmobs.py /path/to/your/collection.db username password
For example:
amarok2musicmobs.py ~/.kde/share/apps/amarok/collection.db username password
If you want your profile to be updated regularly, consider a cron job.