Skip to content

Instantly share code, notes, and snippets.

@bouchard
Created December 31, 2014 23:51
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save bouchard/d98b610caf95a4c8e217 to your computer and use it in GitHub Desktop.
Save bouchard/d98b610caf95a4c8e217 to your computer and use it in GitHub Desktop.
Download Private but Embedded Vimeo Videos
#!/usr/bin/env ruby
require 'nokogiri'
require 'net/http'
require 'shellwords'
require 'json'
source = Net::HTTP.get('www.domain.com', '/thepagethathasthevideos/')
doc = Nokogiri::HTML(source)
ids = doc.css('a').map{ |a| a.attr('data-vimeoid') }.compact.uniq
ids.each_with_index do |id, i|
puts "Downloading #{i + 1}: #{id}"
request = `curl 'http://player.vimeo.com/video/#{id}?api=1&player_id=video#{id}&title=0&byline=0&portrait=0' -H 'Pragma: no-cache' -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: http://www.artofthetitle.com/feature/top-10-title-sequences-of-2014/' -H 'Connection: keep-alive' -H 'Cache-Control: no-cache' --compressed`
beginning_string = %|h=!1,k=!1,a=|
end_string = %|;if(a.request)if("object"|
json = JSON.parse(request.split(beginning_string)[1].split(end_string)[0])
url = json['request']['files']['h264']['hd']['url']
title = json['video']['title']
t = [
%|curl #{Shellwords.escape(url)} >> #{Shellwords.escape(title)}.mp4|
].join(' && ')
`#{t}`
end
@jotapeg
Copy link

jotapeg commented May 10, 2016

Hi, does this still work? If it does, can you give me an usage example? Thanks

@rberts
Copy link

rberts commented May 30, 2016

+1

@Tusko
Copy link

Tusko commented Feb 14, 2020

@denisokvrn
Copy link

thanks! it's work. but in curl need change Referer. Write your site, where the private video is located. 'Referer: https://github.com' for example. I didn't use script, I execute curl (with my videoId and referer) and get urls for download from the response

@jpruiz114
Copy link

I tried this but it isn't working for me.

@jpruiz114
Copy link

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