Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

1
Become a Fan
5.0

Description:
=> Lastsync? What the ... (the short way)
Lastsync is a ruby script to download your last.fm statistics like playcount of your music files and save it to your Amarok database. This is particular useful if you scrobble from many sources (Linux, Windows, iPod ...) but want to have a accurate Amarok statistic (e.g. for creating dynamic playlists).

=> What this script does (the long way)
Last.fm provides their complete information in a XML format for easy access (see http://www.audioscrobbler.net/data/webservices/ for more details), but there's no way to see the complete playcount of all tracks ever listened (the "Top Tracks" stream only shows the Top 50). To solve this problem, the script downloads your complete "Weekly Chart List" history and processes week by week, summing up the playcount of all weeks. The script then searches for each track in your Amarok database and sets the playcount, score, last played and first played time of the appropriate files. This is not completely accurate, but works (for me it counted 23.000 of my 24.000 plays), to achieve the best results run it Sunday Noon, after last.fm updates their Weekly Chart.
Please note that the script currently only runs with a SQLite Amarok-backend.

=> Features
- Retrieve your last.fm stats (playcount, score, last played, first played) and save it to your Amarok
- Correct misstagged id3 tags
- Supported backend: SQLite
- More to come

=> Known Bugs
This is my first ruby script, so it is pretty hacked together and there will be bugs, so always make a backup of your collection.db! You have been warned!

I want to improve my Ruby skills, so comments or improvements are very welcome.
If you found a bug, want to make a feature request or just want to say "thank you", you can leave a comment, write an email or make a shout to my last.fm shoutbox under http://www.last.fm/user/LordGartenzwerg/

For usage and more info see the README file.

Ratings & Comments

9 Comments

passerby

all i get is this chris@linux-y76din7PC:~/Desktop/lastsync> ./lastsync.rb "eagles500" ./amarok.rb:14:in `require': no such file to load -- sqlite3 (LoadError) from ./amarok.rb:14 from ./lastsync.rb:18:in `require' from ./lastsync.rb:18 any suggestions on how i can make it run through im on openSuSE 11.1

bitcrazy

Any plans for Amarok 2? That would be really great, especially because I have to rebuild my collection very often.

Mirksar

Hi there! To fix the quotation error, just add this line name = name.gsub('"', '""') in the function getURL, at module amarok.rb, just after if artist == nil or name == nil return nil end

medievalkarl

I run the script but it doesn't affect my playcounts. Here's what I get: Backing up Amarok collection under /home/karl/.kde/share/apps/amarok/collection.db~ Loading Replace List ... /usr/lib/ruby/1.8/rexml/source.rb:156:in `readline': end of file reached (EOFError) from /usr/lib/ruby/1.8/rexml/source.rb:156:in `initialize' from /usr/lib/ruby/1.8/rexml/source.rb:16:in `new' from /usr/lib/ruby/1.8/rexml/source.rb:16:in `create_from' from /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:130:in `stream=' from /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:107:in `initialize' from /usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:8:in `new' from /usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:8:in `initialize' from /usr/lib/ruby/1.8/rexml/document.rb:205:in `new' from /usr/lib/ruby/1.8/rexml/document.rb:205:in `build' from /usr/lib/ruby/1.8/rexml/document.rb:42:in `initialize' from ./lastfm.rb:39:in `new' from ./lastfm.rb:39:in `initialize' from ./lastsync.rb:55:in `new' from ./lastsync.rb:55

Db0

I'm trying to make this run on amarok 1.4.8 but I get the following error when I run it on the terminal Quote:

/usr/lib/ruby/site_ruby/1.8/sqlite3/errors.rb:94:in `check': near "weird": syntax error (SQLite3::SQLException) from /usr/lib/ruby/site_ruby/1.8/sqlite3/statement.rb:71:in `initialize' from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:184:in `new' from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:184:in `prepare' from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:211:in `execute' from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:292:in `get_first_row' from ./amarok.rb:32:in `getURL' from ./amarok.rb:141:in `update' from ./lastsync.rb:61 from ./lastsync.rb:60:in `each' from ./lastsync.rb:60 from ./lastsync.rb:58:in `each' from ./lastsync.rb:58
Any idea?

gliblygangrenous

The script fails any time it comes across a quotation mark in a song title... or an artist name, I guess. All you need to do is navigate to ~/.kde/share/apps/amarok/scripts/lastsync/data and find the .xml file that the script crashed on. Open it in gedit or whatever and then type ctrl+f to search and type " and delete the song entry (or entries) from the .xml file. I've found that restoring the backup collection.db file is wise prior to re-running the script, so delete the file home/user/.kde/share/apps/amarok/collection.db and rename home/user/.kde/share/apps/amarok/collection.db~ deleting the tilde and you should be good to go. Depending on how long you've been on last.fm you may have to repeat this process several times in order for the script to complete.

dotcomstu

To fix this issue i pass the parameters to the query via the questionmark placeholders, in doing so i quote the variables using the database layer! so... replace line 32 of amarok.rb with: resultArtist = @db.get_first_row("SELECT * FROM artist WHERE LOWER(name) = ?", artist.downcase) and also line 38 with: result = @db.get_first_row("SELECT * FROM tags WHERE artist = ? AND LOWER(title) = ?", resultArtist[0], name.downcase) and that should fix

ageha

any chance for a MySql version some day?

lordgartenzwerg

Well it should be easy to do this, I will have a look into it ...

Pling
0 Affiliates
Details
license
version 0.1 *beta*
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 2

Other Amarok 1.x Scripts:

Gnome Play Video in Totem
mwheatland
last update date: 19 years ago

Score 5.0

editLyrics-gnome
ZeeD
last update date: 19 years ago

Score 5.0

amarok Alarm
aroth
last update date: 16 years ago

Score 5.0

amaroK Web Collection V xmms
pti-jean
last update date: 16 years ago

Score 5.0

SongLogger
lucatnt
last update date: 17 years ago

Score 5.0

amaroK Web Collection
pti-jean
last update date: 16 years ago

Score 5.0



System Tags