Creare un dump delle statistiche di Last.fm per importarle in Libre.fm

from_last_to_libre

Ieri, mentre continuavo a documentarmi su Libre.fm, ho scoperto questa pagina carina: How to create a dump of your last.fm listening history and import it into turtle.libre.fm .

Ho seguito le istruzione e ha funzionato tutto :D

Qui un breve riassuntino in italiano:

Step 1. Ci posizioniamo in /tmp e scarichiamo tutto ciò di cui abbiamo bisogno:

cd /tmp/
wget http://www.crummy.com/software/BeautifulSoup/download/3.x/BeautifulSoup-3.0.7a.py -O BeautifulSoup.py
wget http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/lastscrape/lastscrape.py?root=librefm -O lastscrape.py
wget http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/lastscrape/import.py?root=librefm -O import.py
wget http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/scripts/gobble.py?root=librefm -O gobble.py

Step 2. Effettuiamo il dump di last.fm

chmod +x lastscrape.py
./lastscrape.py   QUI_VA_USERNAME_USATO_SU_LASTFM   lastfm_dump.txt

Step 3. Importiamo il dump su libre.fm

chmod +x import.py
./import.py  QUI_VA_USERNAME_USATO_SU_LIBREFM  http://turtle.libre.fm/ lastfm_dump.txt

Ora dovrebbe chiedervi la password dell’account su libre.fm.

Se lo username utilizzato su libre.fm comprende spazi, dovrete sostituirli con dei ‘+’, ad esempio:
Leo Iannacone‘ diventa ‘Leo+Iannacone

Una piccola nota:
se su last.fm siete utenti da prima del 2007 è possibile che siate affetti da un vecchio bug che tendeva a duplicare le entry. Se così fosse, sul documento originale è riportato come eliminare questi duplicati.

Bene, ora le statistiche sul vostro profilo dovrebbero essere aggiornate, ecco le mie: l3on.

Share and Enjoy:
  • Facebook
  • Google Bookmarks
  • Twitter
  • FriendFeed
  • MySpace
  • PDF
Related Posts
    • Killer Bob
    • maggio 5th, 2009

    A me non ha funzionato… dopo aver scaricato un po’ di dati da last.fm ho ricevuto questo errore:
    Traceback (most recent call last):
    File "./lastscrape.py", line 70, in
    sys.exit(main(*sys.argv))
    File "./lastscrape.py", line 61, in main
    for artist, track, timestamp in fetch_tracks(args[1]):
    File "./lastscrape.py", line 47, in fetch_tracks
    for artist, track, timestamp in tracks:
    File "./lastscrape.py", line 14, in parse_page
    soup = BeautifulSoup(urllib2.urlopen(page), convertEntities=BeautifulSoup.HTML_ENTITIES)
    File "/usr/lib/python2.6/urllib2.py", line 124, in urlopen
    return _opener.open(url, data, timeout)
    File "/usr/lib/python2.6/urllib2.py", line 389, in open
    response = meth(req, response)
    File "/usr/lib/python2.6/urllib2.py", line 502, in http_response
    'http', request, response, code, msg, hdrs)
    File "/usr/lib/python2.6/urllib2.py", line 421, in error
    result = self._call_chain(*args)
    File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
    result = func(*args)
    File "/usr/lib/python2.6/urllib2.py", line 597, in http_error_302
    return self.parent.open(new)
    File "/usr/lib/python2.6/urllib2.py", line 383, in open
    response = self._open(req, data)
    File "/usr/lib/python2.6/urllib2.py", line 401, in _open
    '_open', req)
    File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
    result = func(*args)
    File "/usr/lib/python2.6/urllib2.py", line 1130, in http_open
    return self.do_open(httplib.HTTPConnection, req)
    File "/usr/lib/python2.6/urllib2.py", line 1103, in do_open
    r = h.getresponse()
    File "/usr/lib/python2.6/httplib.py", line 950, in getresponse
    response.begin()
    File "/usr/lib/python2.6/httplib.py", line 390, in begin
    version, status, reason = self._read_status()
    File "/usr/lib/python2.6/httplib.py", line 354, in _read_status
    raise BadStatusLine(line)
    httplib.BadStatusLine

    In ogni modo ho continuato e quando ho lanciato l’ultimo comando per inviare i dati a libre.fm ho ricevuto questo errore:
    Traceback (most recent call last):
    File "./import.py", line 9, in
    from gobble import GobbleServer
    ImportError: No module named gobble

      • l3on
      • maggio 5th, 2009

      1. Prova ad installare il pacchetto python-beautifulsoup.
      2. Usa python2.5 per eseguire gli script:

      python2.5 NOMESCRIPT  PARAMENTRI.... 
    • l3on
    • maggio 5th, 2009

    Ah ok, forse trovato.. fra ieri ed oggi hanno aggiornato gli script che ora richiedono anche questo file:

    wget http://svn.savannah.gnu.org/viewvc/trunk/scripts/gobble.py?root=librefm -O gobble.py

    Prova a scaricarlo e a ripetere tutto (ovviamente lo devi mettere nella stessa dir degli altri script).

    • Killer Bob
    • maggio 5th, 2009

    Ho scaricato gobble.py, ma ora sembra che sia questo ultimo script ad avere errori, sia che venga lanciato con python2.5 che 2.6:

    $ ./import.py killerbob http://turtle.libre.fm/ lastfm_dump.txt
    Traceback (most recent call last):
    File "./import.py", line 9, in
    from gobble import GobbleServer
    File "/tmp/gobble.py", line 5
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    ^
    SyntaxError: invalid syntax

    • l3on
    • maggio 5th, 2009

    Mmm, scusa è stato un mio errore di copia/incolla.

    Il comando giusto è:

    wget http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/scripts/gobble.py?root=librefm -O gobble.py
    • Killer Bob
    • maggio 5th, 2009

    Yeah!! Ora si rockeggia ;)
    Grazie mille!!!

    PS: alla fine dell’importazione verso libre.fm ha restituito questi errori, ma da quel poco che ho capito dipendono dal sito e non dagli script


    Traceback (most recent call last):
    File "./import.py", line 30, in
    gobbler.add_track(artist, track, dt)
    File "/tmp/gobble.py", line 60, in add_track
    self.submit()
    File "/tmp/gobble.py", line 52, in submit
    raise GobbleException("Server returned: %s" % (response,))
    gobble.GobbleException: Server returned: FAILED MDB2 Error: constraint violation - _doQuery: [Error message: Could not execute statement]
    [Last executed query: INSERT INTO Scrobbles (username, artist, album, track, time, mbid, source, rating, length, stid) VALUES ('killerbob', 'The Kovenant', NULL, 'Cybertrash', 1237489202, NULL, NULL,'0',NULL,630397)]
    [Native message: ERROR: duplicate key value violates unique constraint "scrobbles_pkey"]

    Error has been reported to site administrators.

    • l3on
    • maggio 5th, 2009

    Sì esatto, se andavi in quell’istante sul sito, avresti visualizzato proprio l’errore:

    MDB2 Error: constraint violation

    Ciao :)

  1. No trackbacks yet.