This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Lyrics tag script - reading qdbus stream output

Tags: None
(comma "," separated)
Fluffhouse
Registered Member
Posts
1
Karma
0
I'm trying to develop an Amarok 2 script to read lyrics from the ID3 tag of the file, and save lyrics back to the tag if they have been edited in the lyric panel. There are scripts for this purpose for Amarok 1, but it looks like the author of those no longer uses Amarok.

Reading from tags is working fine - I implemented this by calling the python mutagen library via a QProcess shell command in qtscript. But saving the tags is more problematic. It appears that I need a way of reading the cached lyrics. The only scriptable way I've found is to call

Code: Select all
var parent = new QObject;
var process = new QProcess(parent);
process.start("/usr/bin/qdbus org.kde.amarok /Player GetMetadata");

and parse the messy output for the string "lyrics: ".

Now I'm having difficulty obtaining the standard output of this command. The qdbus command works from an external shell, and redirecting the QProcess output to a file (process.setStandardOutputFile()) works fine, but it would be nicer to use the default stream output and read it with process.readAllStandardOutput(). However unless I redirect the output to a file, the command just times out. Other qdbus commands produce stream output, such as qdbus --help, qdbus org.kde.kded. but calls to the org.kde.amarok service just time out when run from the Script Console.

Any ideas what's blocking the stream? Or is there a nicer way to read the lyric window contents from a script?
HaMF
Registered Member
Posts
1
Karma
0
Obviousely this just doesn't work with the Amarok 2 script API and querying dbus with qdbus produces some stupid output that would have to be parsed (as Fluffhouse stated).

To make lyrics show on my iPod ( touch , iPhone , whatever model) I needed to somehow save the lyrics to the id3 USLT frame and I did not want to do this manually for every song I transfer.

So I wrote a little "daemon" in ruby that runs in the background, waits for a track change, waits some seconds (to account for the time amarok needs to fetch the lyrics), and writes the lyrics to the mp3 file. Basically works pretty well for my use case. Might fail for yours, but one could even "recycle" the code to integrate it in an Amarok script.

You can find it on github: https://github.com/HaMF/amarok_id3lyrics
Read the Readme. Criticise. Use it. Contribute.

Hannes


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], Sogou [Bot]