From 726a505538c00a642bd0ac300ed315608d01ab56 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 24 Nov 2010 14:13:30 -0500 Subject: [PATCH] Add MPD playlist duration post. --- posts/MPD_playlist_duration.mdwn | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 posts/MPD_playlist_duration.mdwn diff --git a/posts/MPD_playlist_duration.mdwn b/posts/MPD_playlist_duration.mdwn new file mode 100644 index 0000000..e08180c --- /dev/null +++ b/posts/MPD_playlist_duration.mdwn @@ -0,0 +1,23 @@ +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. + +[MPD]: http://mpd.wikia.com/ +[M3U]: http://en.wikipedia.org/wiki/M3U +[post]: http://repura.livejournal.com/59403.html?thread=156683 + +[[!tag tags/linux]] +[[!tag tags/fun]] -- 2.26.2