Created
July 24, 2013 21:14
-
-
Save mlincoln/6074598 to your computer and use it in GitHub Desktop.
takes a directory of mp4 videos and creates a jwplayer embed page for each one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import re | |
| import inspect | |
| def makeembeds(): | |
| path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) | |
| if not os.path.exists("embeds"): | |
| os.makedirs("embeds") | |
| filelist = os.listdir(path) | |
| for file in filelist: | |
| if "mp4" in file: | |
| segmentvideo = re.search('(.*)\.', file).group(1) | |
| lecturename = re.search('/([^/]+?)$' , path).group(1) | |
| f = open(os.path.join(path + '/embeds' , segmentvideo + ".html"), 'w') | |
| embedscript = ''' | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="http://d37ccv6h3uok2k.cloudfront.net/masic_player/jwplayer.js" ></script> | |
| <script type="text/javascript">jwplayer.key="xU1gxzJPE4w0ekq8WaJEZ2r/fRmLJZaEu3x28ubId8Q=";</script> | |
| <title></title> | |
| <style type="text/css"> | |
| html,body { height:100%; width:100%; padding:0; margin:0; } | |
| #player { height:100%; width:100%; padding:0; margin:-3px; } | |
| </style> | |
| </head> | |
| <body> | |
| <div align="center" id="mediaplayer"></div> | |
| <script type="text/javascript"> | |
| jwplayer("mediaplayer").setup({ | |
| playlist: [{ | |
| image: "http://d37ccv6h3uok2k.cloudfront.net/masic_player/EECS_firstframe.png", | |
| sources: [ | |
| { file: "rtmp://s3knyh22euss0r.cloudfront.net/cfx/st/mp4:EE241A/''' + lecturename + '''/''' + segmentvideo + '''.mp4" }, | |
| { file: "http://masic.s3.amazonaws.com/EE241A/''' + lecturename + '''/''' + segmentvideo + '''.mp4" } | |
| ] | |
| }], | |
| primary: "flash", | |
| width: "100%", | |
| height: "100%", | |
| stretching: "uniform", | |
| skin: "http://d37ccv6h3uok2k.cloudfront.net/masic_player/skins/bekle.xml", | |
| }); | |
| </script> | |
| </body> | |
| </html> | |
| ''' | |
| f.write(embedscript) | |
| f.close() | |
| makeembeds() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment