#!/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 |
Hi, does this still work? If it does, can you give me an usage example? Thanks |
+1 |