Skip to content

Instantly share code, notes, and snippets.

@jdeluyck
Created June 27, 2020 17:09
Show Gist options
  • Save jdeluyck/41b66a5a02e856a0e7da447ee93153e6 to your computer and use it in GitHub Desktop.
Save jdeluyck/41b66a5a02e856a0e7da447ee93153e6 to your computer and use it in GitHub Desktop.
Quick and dirty script to download video files from teachable that youtube-dl flakes out on (for now)
from html.parser import HTMLParser
import urllib.request
import re
import argparse
import wget
regex = r"\"url\":\"(.*?.bin)\""
ap = argparse.ArgumentParser("DL")
ap.add_argument("-v", "--video", dest="video", required=True)
ap.add_argument("-f", "--filename", dest="fn", required=True)
args = ap.parse_args()
link = "https://fast.wistia.net/embed/iframe/{}?videoFoam=true".format(args.video)
foo = urllib.request.urlopen(link)
txt = foo.read().decode("utf-8")
print("Link: ", link)
matches = re.search(regex, txt)
if matches:
bin = matches.group(1)
else:
print ("Can't find bin file...")
exit (1)
print ("Downloading ", bin, " to ", args.fn)
wget.download(bin, args.fn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment