Skip to content

Instantly share code, notes, and snippets.

@Techbrunch
Created December 6, 2015 22:33
Show Gist options
  • Save Techbrunch/d7c55bb7813533b01501 to your computer and use it in GitHub Desktop.
Save Techbrunch/d7c55bb7813533b01501 to your computer and use it in GitHub Desktop.
import os, re, requests
rootdir = '_posts'
for subdir, dirs, files in os.walk(rootdir):
for file in files:
filename = os.path.join(subdir, file)
print filename
f = open(filename, "r")
contents = f.read()
f.close()
contents = re.sub('\[video.*?type="vimeo".*?clip_id="(.*?)".*?\]', '<iframe src="//player.vimeo.com/video/\\1?title=0&amp;byline=0" width="500" height="281" frameborder="0"> </iframe>', contents)
contents = re.sub('\[video.*?type="youtube".*?clip_id="(.*?)".*?\]', '<iframe width="560" height="315" src="http://www.youtube.com/embed/\\1" frameborder="0"> </iframe>', contents)
f = open(filename, "w")
f.write("".join(contents))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment