Skip to content

Instantly share code, notes, and snippets.

@cvogt
Forked from alexeygrigorev/vimeo-download.py
Last active December 26, 2018 08:29
Show Gist options
  • Select an option

  • Save cvogt/1e46597e39bfe0e0aee8d5348123ca03 to your computer and use it in GitHub Desktop.

Select an option

Save cvogt/1e46597e39bfe0e0aee8d5348123ca03 to your computer and use it in GitHub Desktop.

Revisions

  1. cvogt revised this gist Dec 26, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion vimeo-download.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/usr/bin/env python2.7
    #based on https://gist.github.com/alexeygrigorev/a1bc540925054b71e1a7268e50ad55cd#file-vimeo-download-py
    # https://gist.github.com/cvogt/1e46597e39bfe0e0aee8d5348123ca03
    # based on https://gist.github.com/alexeygrigorev/a1bc540925054b71e1a7268e50ad55cd#file-vimeo-download-py
    # also see https://github.com/eMBee/vimeo-download

    import requests
    import base64
  2. cvogt revised this gist Dec 26, 2018. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions vimeo-download.py
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,15 @@
    #!/usr/bin/env python2.7
    #based on https://gist.github.com/alexeygrigorev/a1bc540925054b71e1a7268e50ad55cd#file-vimeo-download-py

    import requests
    import base64
    import sys
    from tqdm import tqdm


    master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1'
    base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
    master_json_url = sys.argv[1]
    print ("downloading " + master_json_url)
    base_url = master_json_url[:master_json_url.rfind('/', 0, -1) + 1]

    resp = requests.get(master_json_url)
    content = resp.json()
    @@ -15,12 +20,12 @@
    video_base_url = base_url + video['base_url']
    print 'base url:', video_base_url

    filename = 'video_%d.mp4' % video['id']
    filename = 'video_%s.mp4' % video['id']
    print 'saving to %s' % filename

    video_file = open(filename, 'wb')

    init_segment = base64.b64decode(video['init_segment'])
    init_segment = video['init_segment']
    video_file.write(init_segment)

    for segment in tqdm(video['segments']):
  3. @alexeygrigorev alexeygrigorev created this gist Sep 17, 2016.
    38 changes: 38 additions & 0 deletions vimeo-download.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import requests
    import base64
    from tqdm import tqdm


    master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1'
    base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]

    resp = requests.get(master_json_url)
    content = resp.json()

    heights = [(i, d['height']) for (i, d) in enumerate(content['video'])]
    idx, _ = max(heights, key=lambda (_, h): h)
    video = content['video'][idx]
    video_base_url = base_url + video['base_url']
    print 'base url:', video_base_url

    filename = 'video_%d.mp4' % video['id']
    print 'saving to %s' % filename

    video_file = open(filename, 'wb')

    init_segment = base64.b64decode(video['init_segment'])
    video_file.write(init_segment)

    for segment in tqdm(video['segments']):
    segment_url = video_base_url + segment['url']
    resp = requests.get(segment_url, stream=True)
    if resp.status_code != 200:
    print 'not 200!'
    print resp
    print segment_url
    break
    for chunk in resp:
    video_file.write(chunk)

    video_file.flush()
    video_file.close()