Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Strip YouTube Caption Timestamps with Textmate
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>commands</key>
<array>
<dict>
<key>command</key>
<string>selectAll:</string>
</dict>
<dict>
<key>argument</key>
<dict>
<key>action</key>
<string>replaceAll</string>
<key>findString</key>
<string>\d+:\d+:\d+.\d+,\d+:\d+:\d+.\d+</string>
<key>ignoreCase</key>
<true/>
<key>regularExpression</key>
<true/>
<key>replaceAllScope</key>
<string>selection</string>
<key>replaceString</key>
<string></string>
<key>wrapAround</key>
<true/>
</dict>
<key>command</key>
<string>findWithOptions:</string>
</dict>
<dict>
<key>argument</key>
<dict>
<key>action</key>
<string>replaceAll</string>
<key>findString</key>
<string>\n{2,}</string>
<key>ignoreCase</key>
<true/>
<key>regularExpression</key>
<true/>
<key>replaceAllScope</key>
<string>selection</string>
<key>replaceString</key>
<string>\n</string>
<key>wrapAround</key>
<true/>
</dict>
<key>command</key>
<string>findWithOptions:</string>
</dict>
<dict>
<key>argument</key>
<dict>
<key>action</key>
<string>replaceAll</string>
<key>findString</key>
<string>,\s+</string>
<key>ignoreCase</key>
<true/>
<key>regularExpression</key>
<true/>
<key>replaceAllScope</key>
<string>selection</string>
<key>replaceString</key>
<string>,</string>
<key>wrapAround</key>
<true/>
</dict>
<key>command</key>
<string>findWithOptions:</string>
</dict>
</array>
<key>name</key>
<string>Strip Timecodes</string>
<key>uuid</key>
<string>455B3685-5BE8-4E6F-9EAF-B8EF7DB2F252</string>
</dict>
</plist>
@DhatesCode

This comment has been minimized.

Copy link

@DhatesCode DhatesCode commented Jul 22, 2016

Cool stuff, man. I posted about this on the TM mailing list. It almost works, but it doesn't seem to remove all the line breaks (such as after an em dash or after punctuation), or insert spaces after commas. I'd help but I don't understand this stuff at all. :P I'm used to working with markup and styling.

Would be really badass if you could could make it do that stuff as well as retain line breaks after things inside brackets, such as [blah]

Brackets are being used in the closed-captioning for sounds.

At any rate, much appreciated. I'm broke and in bad health. It's always nice to get some help. ;)

@DhatesCode

This comment has been minimized.

Copy link

@DhatesCode DhatesCode commented Jul 22, 2016

One thing I found is that doing an Unwrap Paragraph command took care of the other line breaks. The I did a find and replace on "," to change it to ", ". After that it would just be adding 2 lines breaks before and after []. Boring, so if you don't want to do it, no big deal. This has already saved me heaps of time.

Cheers.

Xero

@loadedsith

This comment has been minimized.

Copy link
Owner Author

@loadedsith loadedsith commented Jul 23, 2016

It doesn't insert spaces after commas because i thought you asked for your third step to be to remove these spaces. Probably should have asked before I made it that way, lol, as that's an insane thing to request.

You could probably do a simple find and replace for the brackets thing, same as you did for the commas (did you know you could replace with multiple lines? you can).

If you'll need this in the future I bet I could modify them, but I assume this is probably close enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment