Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@eleijonmarck
Forked from bouchard/download.rb
Created October 28, 2019 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eleijonmarck/f8a3fbe0074f72f26fdaa2d6fd737fac to your computer and use it in GitHub Desktop.
Save eleijonmarck/f8a3fbe0074f72f26fdaa2d6fd737fac 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment