Skip to content

Instantly share code, notes, and snippets.

@robmathers
Created September 6, 2013 21:16
Show Gist options
  • Save robmathers/6470128 to your computer and use it in GitHub Desktop.
Save robmathers/6470128 to your computer and use it in GitHub Desktop.
Converts a OGG format chapters to csv format for use with Handbrake. Uses stdin/stdout for easy use with other command-line utilities.
#!/usr/bin/env python
from sys import stdin, stdout
import re
pattern = re.compile("CHAPTER0*(\\d+)=[\\d:\\.]+\\nCHAPTER0*\\1NAME=(.*)$", flags = re.MULTILINE)
replacement = "\\1,\\2"
input = stdin.read()
output = pattern.sub(replacement, input)
stdout.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment