dseif / slide-drive

Slideshow using audio/video to drive content
45 stars 9 forks source link

Command-line tool to manipulate time codes #12

Closed banksJeremy closed 12 years ago

banksJeremy commented 12 years ago

Per Greg's suggestion, this is a command-line tool allowing one to quickly view, dump or replace 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. 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). If we're generating new presentations we'll need to specify a placeholder value or modify this.

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?

banksJeremy commented 12 years ago

Closing this pull request; I'm making the script more general for #14. I'll file a request for that when it's done.