Friday, July 16, 2010

Add album to amarok playlist remotely

Completely different track here, this is more for my own reference until I get around to creating the bash script...

I've just discovered the need to manipulate amarok remotely through SSH and came across DCOP which is really cool.

The first problem is when you login in via SSH, DCOP is not running in your session because it's not a KDE session. You can connect to the one that is already running, by adding the '--user `whoami`' parameter to each DCOP call. I just created an alias to automatically do all that:
alias damarok='dcop --user bruzie amarok'

Get list of tracks for an album:
damarok collection query "select url from tags, album where tags.album = album.id and album.name = '<album name>' order by track" | sed 's/^\./"/g; s/$/"/g' > playlist

Then replace the newlines with a space:
sed '{:q;N;s/\n/ /g;t q}' playlist

Which leaves me with a nicely formatted list of tracks to paste into:
damarok playlist addMediaList [ <tracklist> ]

So I can start playing them:
damarok player play

No comments:

Post a Comment