Skip to content

Instantly share code, notes, and snippets.

@XueshiQiao
Forked from nriley/extract.py
Last active April 8, 2018 02:20
Show Gist options
  • Save XueshiQiao/5976402 to your computer and use it in GitHub Desktop.
Save XueshiQiao/5976402 to your computer and use it in GitHub Desktop.
import requests
import os, re, sys
RE_SD_VIDEO = re.compile(
r'<a href="(http://devstreaming.apple.com/videos/wwdc/2013/[^"]*-SD.mov)')
RE_WEBVTT = re.compile(r'fileSequence[0-9]+\.webvtt')
# stdin: dump of https://developer.apple.com/wwdc/videos/
for l in sys.stdin:
m = RE_SD_VIDEO.search(l)
if not m:
continue
print "downloading subtitle of video [" + video_url + "]"
video_url = m.group(1)
video_dir = video_url[:video_url.rindex('/')]
session = video_dir[video_dir.rindex('/') + 1:]
prog_index = requests.get(video_dir + '/subtitles/eng/prog_index.m3u8')
os.mkdir(session)
webvtt_names = RE_WEBVTT.findall(prog_index.text)
for webvtt_name in webvtt_names:
webvtt = requests.get(video_dir + '/subtitles/eng/' + webvtt_name)
open(os.path.join(session, webvtt_name), 'w').write(webvtt.text)
@XueshiQiao
Copy link
Author

This Gist is forked from @nriley 's extract.py,
Thx @nriley

How to use:

  1. Open https://developer.apple.com/wwdc/videos/ in Safari, login with _App Developer Account_.
  2. save html to local , such as ~/wwdc_video.html
  3. exec python extract.py < ~/wwdc_video.html

Just waiting for download completed.

After script finish, combine all webvtt files to a whole file with wwdc_combine_webvtt.rb

@shede333
Copy link

老是报下面的错误:

raceback (most recent call last):
File "extract.py", line 1, in
import requests
ImportError: No module named requests

@XueshiQiao
Copy link
Author

@shede333 貌似是没有引入requests这个module

@shede333
Copy link

我用的mac,自带的pathon,这个module难道不是标配?
帮人帮到底吧,应该怎么导入那个module

@huibin1984
Copy link

wwdc 2012及之前的视频有中文字幕可以抓么?

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