Last.fm tag to amarok playlist

Various Stuff

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
Score 50.0%
Description:

IMPORTANT: This script is not built as an amarok script, it should be executed from the command line. This is because it's a one-run script which will have no benefit running in the background, and it is pretty CPU intensive. If you really want to integrate it as an amarok script, you should have very little trouble adapting the code.


This script fetches last.fm user tags (not global tags) and creates playlists based on your local files.
These playlists are then added to amarok.

The script assumes your amarok playlists are under ~/.kde/share/apps/amarok/playlists (change it if you are using another directory)

You can use this script by running it this way:

'python lastfm_playlists.py [last.fm user name]'

It will yield better results with your own tags, as you'll problaby have most of your tagged music.

Obtaining artists names, songs, etc, is done by parsing the html user tag page as there's not still a webservice which will give me the contents of a tag (i'm talking about user tags all the time)

Version 0.12:

Added support for amarok 1.4.2 (amarok track paths have been changed in the database to relative paths and the device mountpoint must be added to each path)


Version 0.11:

This version is a patch for avoiding encoding problems. The script now checks the retrieved names in different encodings, until finds one that does not throw an exception. This is a temporary fix so the script does not break. There must be a better way of doing this :P


TO-DO:
- Check some character encodings
- Retrieve amarok's configured last.fm user as default
- Support for global tags

Check my last.fm account:
http://www.last.fm/user/latengoyo/


alex.

ochoha

13 years ago

I'm about to start work on a similar script, but with some key differences. I'm planning to write the last.fm tags into the comment field for each track. This will allow the user to build smart playlists based on the presence of the tag.

I haven't decided if I want to write it in python or something else yet but if it's in python I might like to use some of your code. I hope you don't mind.

Thanks for the script!

-mark

Report

akemi

13 years ago

a problem

i get this error:
Traceback (most recent call last):
File "44547-lastfm_playlists.py", line 175, in ?
if __name__ == "__main__": main()
File "44547-lastfm_playlists.py", line 168, in main
lastfm_playlists(argv[1])
File "44547-lastfm_playlists.py", line 76, in __init__
numItems=self.addToPlaylist(fh,item.prop("href"))
File "44547-lastfm_playlists.py", line 105, in addToPlaylist
rs=os.popen(("dcop amarok collection query \""+sql+"\"").encode('iso8859_15'))
File "/usr/lib/python2.4/encodings/iso8859_15.py", line 18, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u015e' in position 143: character maps to






here is my piano tag:
1 Yann Tiersen – Amélie - La Valse D'Amélie (Ve
Aug 23 2006 21:28
2
Yann Tiersen – A Dispute
Aug 23 2006 21:25
3
Yann Tiersen – Comptine D`un Autre Été - L`ap
Aug 23 2006 20:50
4
Yann Tiersen – Sur le fil
Aug 23 2006 20:43
5
Ben Folds Five – Air
Aug 20 2006 16:09
6
Sergei Rachmaninoff – Rhapsody on a Theme by Paganini
Aug 20 2006 16:06
7
Paul Weller – You do Something to Me
Aug 20 2006 15:39
8
Şebnem Ferah – Hoşçakal
Aug 20 2006 15:30
9
Franz Ferdinand – Fade Together
Aug 14 2006 22:16
10
Beethowen – moonlight sonata
Aug 14 2006 22:15
11
Yann Tiersen – Musiques de films - Amélie Pou
Aug 13 2006 16:30
12
Yann Tiersen – Le Moulin
Aug 13 2006 16:05
13
Evanescence – You
Aug 13 2006 13:52
14
Evanescence – Breathe No More
Aug 13 2006 13:52
15
The Gathering – Broken Glass (Piano version)
Aug 12 2006 16:49
16
Evanescence – Hello

Report

akemi

13 years ago

the problem is with the turkish charcter in the eight track. For now is there way not to parse that one and go on adding the next tracks. Brcause now after the error the tracks on the way are not handled. Thanks for sharing this plugin

Report

C

latengoyo

13 years ago

I've got issues with certain character encodings... if you send me your last.fm user name, i can test the script with your tags for debbuging this.

you can also try changing 'iso8859_15' to the charset you are using. Probably 'cp1026'... see http://docs.python.org/lib/standard-encodings.html#standard-encodings

also i'll to put a try..catch block so the script don't stops with this kind of problems.

Report

akemi

13 years ago

changing coding worked. thanks:)

Report

12345678910
product-maker Base: 4 x 5.0 Ratings
File (click to download) Version Description Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
0.12
updated Aug 25 2006
added Aug 22 2006
downloads 24h
0
mediaviews 24h 0
pageviews 24h 0