dseif/slide-drive — pull request #12 by jeremybanks (2012-04-17 18:34:45+00:00)
Title: Command-line tool to manipulate time codes

Per Greg's suggestion, this is a command-line tool allowing one to quickly view, dump or edit time codes of a Slide Deck presentation. (This functionality will eventually be in the butter plugin, but that doesn't exist yet.) It uses Python with [lxml](http://lxml.de/). It alters whitespace, encodes non-ASCII entities and uses HTML-style self-closing tags, but doesn't otherwise mangle the original document.

Usage: ./times.py show slideshow.html
./times.py dump slideshow.html > times.json
./times.py write slideshow.html < times.json > modified.html

$ ./times.py show index.html
[ 0] t= 1 Software Carpentry in 90 Seconds
[ 1] t= 4 Mission Help scientists be more producti
[ 2] t= 9 Problem Scientists spend 40% or mor
[ 3] t= 14 But 95% or more are primarily self-ta
[ 4] t= 17 So they spend hours doing things that shoul
[ 5] t= 20 ...reinvent a lot of wheels... .
[ 6] t= 22 ...and still don't know if their results ar
[ 7] t= 24 Solution Short intensive workshops

...

$ ./times.py dump index.html
[1, 4, 9, 14, 17, 20, 22, 24, 27, 30, 33, 34, 35, 38, 42, 43, 44, 45, 46, 48, 49, 52, 53, 54, 55, 56, 58, 61, 62, 65, 67, 68, 73, 77, 78, 80, 82, 87, 89, 90]

For now this considers a "slide" to be any element with a `popcorn-slideshow` attribute instead of looking for the `slide` class, because I couldn't find a reliable way to precisely query classes with XPath 1.0 (used by lxml).

I'm not sure where this file should go. Right now, everything in here seems to client/browser code. Maybe we need a `/bin/` for tools?