This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

good article!

Posted by: Anonymous Coward on April 09, 2007 02:20 AM
<tt>I liked your article!

I guess some people would like to add the lyrics to the id3v2 tag of the file (at least i do)

So i changed you're script a little. Don't know if it works for everyone but it works for me at least<nobr> <wbr></nobr>:)

if [ ! -f "$1.txt" ]; then
            echo $lyrics_results | xmlstarlet sel -t -v "/leoslyrics/lyric/text/text()" | xmlstarlet unesc > "$1.txt"
            exec put_lyrics.py "$1" "$1.txt"
        fi

put_lyrics.py:

#!/usr/bin/env python
import sys
import codecs
from mutagen.id3 import ID3, USLT,TALB
audio = ID3(sys.argv[1])
lyrics = codecs.open(sys.argv[2],'r','utf8').read()
audio<nobr>.<wbr></nobr> update_to_v24()
audio.add(USLT(encoding=3, desc="tagged by python", lang="und", text=lyrics))
audio.save()

You have to have the mutagen module installed though.

Hope it can be of help to anyone.</tt>

#

Return to How to script songs lyrics retrieval