Add MPD playlist duration post.
authorW. Trevor King <wking@drexel.edu>
Wed, 24 Nov 2010 19:13:30 +0000 (14:13 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 24 Nov 2010 19:13:30 +0000 (14:13 -0500)
posts/MPD_playlist_duration.mdwn [new file with mode: 0644]

diff --git a/posts/MPD_playlist_duration.mdwn b/posts/MPD_playlist_duration.mdwn
new file mode 100644 (file)
index 0000000..e08180c
--- /dev/null
@@ -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]]