Skip to content

Instantly share code, notes, and snippets.

@ediskandarov
Created March 17, 2017 19:53
Show Gist options
  • Save ediskandarov/d9d543d2522525dd413274075f406f82 to your computer and use it in GitHub Desktop.
Save ediskandarov/d9d543d2522525dd413274075f406f82 to your computer and use it in GitHub Desktop.
Snippet to download private vimeo content
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import shutil
import sys
from urlparse import urljoin
import requests
def main(master_url):
master = requests.get(master_url).json()
for video in master['video']:
with open('{id}.mp4'.format(**video), 'wb') as f:
init_segment = video['init_segment'].decode('base64')
f.write(init_segment)
for i, segment in enumerate(video['segments']):
url = urljoin(
urljoin(
urljoin(
master_url,
master['base_url'],
),
video['base_url'],
),
segment['url'],
)
r = requests.get(url)
content = r.content
print 'writing', len(content), 'bytes'
f.write(content)
if __name__ == '__main__':
url = sys.argv[1]
main(url)
@Murphest
Copy link

Nicely done, works well. Do you know how I can use it to download my classes from masterclass.com? It doesn't use a file called master.json but downloads a bunch of .ts files

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