6

for a long time I dream to have a songs lastfm tags in my music library, so I can use them to quickly generate playlists.

There used to be a way to do that in amarok 1.4, but it never was stable.

Than there is MusicBrainz Picard's lastfm/lastfmplus plugin. It is partially fine, but I cannot manage to make it look ONLY for the lastfm tags and put them into comments/genre/whatever but it always hast to tag everything. And it isn't particularly good with it, especially with small bands, songs without album etc.

My music library is rather well organised. Most of the tags are correct. I also have quite some songs without an album. And I don't want it to find the albums for those songs, since it'd mess up my album view. So it must not touch the fields track name, track number, artist and album. All I want is that the most popular lastfm tags get into the genre or comments tag of the mp3, separated by semicolons, commas or whatever.

I think I remember a script that did this job, but I cannot find.

Does anybody know if there is anything like this? Would it be to hard to write this, for example as Banshee plugin?

Thank you

3 Answers 3

5

I cooked one Python script quickly. You can review it here: http://db.tt/yGa14ZA or download from here: http://db.tt/Rnkhpod

As I understand your library is in MP3 format, so I used ID3 tagger. Script fetches last.fm top-tags and puts them in COMMENT tag.
If you ask me, although "TopTags" are more meaningful then "TrackTags" they can consist lots of garbage

Script uses Standard Python Library, except for module that writes tags - eyeD3 (sudo apt-get install python-eyed3)

Example usage (parse all files in current folder):

$ for f in *.mp3 ; do python lastfm_top-tags.py "$f" ; done

Similar bash line can crawl through all subfolders also.

Hope it's useful :)

2
  • Thank you! I will try it as soon as I have some time, but this is exactly the kind of answer I was looking for. I started to manually make my tags and it's quite a lot of work. Thanks!
    – Meng Tian
    Aug 24, 2011 at 8:56
  • I've made some modifications to this so that just the first five tags are used and it also sets the Genre: gist.github.com/aembleton/d0adc2e6ec96e67612b3
    – Arthur
    Dec 13, 2015 at 16:46
2

The bash script noted above is doing the trick for me - but how would I use it to automatically go through my subdirectories recursively? My subdirectories and files also have spaces in them - so how would I script it when I have spaces in file names?

I searched around, and wrapped it with this:

current_directory=$(pwd)
mp3_files=$(find "${current_directory}" -type f -iname "*.mp3")
# Need to change IFS or files with filenames containing spaces will not
# be handled correctly by for loop
IFS=$'\n' 
for mp3_file in ${mp3_files}; do 
   python /home/bruce/lastfm_top-tags.py "$f" ; 
done

But I'm thinking that isn't quite it.

1
  • Line 7 should be python /home/bruce/lastfm_top-tags.py "$mp3_file" ;
    – Arthur
    Dec 13, 2015 at 14:10
1

Make the script executable and run it like this:

#!/bin/bash

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

for f in $(find ./ -type f -iname "*.mp3")
do
    lastfm_top-tags.py
    # or use this : python $HOME/bin/lastfm_top-tags.py "$f" ;
done

IFS=$SAVEIFS

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .