mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / MPD_playlist_duration.mdwn
1 I use [[MPD]] to organize and play my music, since it's a pretty thin
2 layer over the directory structure I'd been using before.  MPD's
3 playlists are stored in `/var/lib/mpd/playlists/` as [M3U][] files
4 (one filename per line), so it easy to build your own tools to work
5 with the playlists directly.
6
7 Anyhow, I was interedted in determining the total runtime for a
8 playlist, and searching around brought me to Repolho's [post][] which
9 I've condensed to:
10
11     $ mpc --format '%time%' playlist | awk -F ':' 'BEGIN{t=0} {t+=$1*60+$2} END{print strftime("%j %H:%M:%S", t, 1)}'
12     001 10:48:35
13
14 Note that, unfortunately, `%j` returns the day of the year in the
15 range `[001,366]`, so an empty playlist would return `001 00:00:00`,
16 not the `000 00:00:00` I'd like.  Oh well.
17
18 [M3U]: http://en.wikipedia.org/wiki/M3U
19 [post]: http://repura.livejournal.com/59403.html?thread=156683
20
21 [[!tag tags/linux]]
22 [[!tag tags/fun]]