I use MPD to organize and play my music, since it's a pretty thin
layer over the directory structure I'd been using before. MPD's
playlists are stored in /var/lib/mpd/playlists/
as M3U files
(one filename per line), so it easy to build your own tools to work
with the playlists directly.
Anyhow, I was interedted in determining the total runtime for a playlist, and searching around brought me to Repolho's post which I've condensed to:
$ mpc --format '%time%' playlist | awk -F ':' 'BEGIN{t=0} {t+=$1*60+$2} END{print strftime("%j %H:%M:%S", t, 1)}'
001 10:48:35
Note that, unfortunately, %j
returns the day of the year in the
range [001,366]
, so an empty playlist would return 001 00:00:00
,
not the 000 00:00:00
I'd like. Oh well.