Created
December 4, 2010 13:39
-
-
Save Arthur/728186 to your computer and use it in GitHub Desktop.
use rtmpdump to get arte videos mp4 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
require "rexml/document" | |
rtmpdump = '~/Downloads/rtmpdump-2.1/rtmpdump' | |
url = ARGV.pop | |
html = open(url).read | |
xml_url = html.scan(/http:.+asPlayerXml\.xml/).last | |
xml = open(xml_url).read | |
# puts xml | |
parsed = REXML::Document.new(xml) | |
ref_xml_url = parsed.elements["*/videos/video[@lang='fr']"].attributes["ref"] | |
puts ref_xml_url | |
name = ref_xml_url.split('/').last.split(',').first | |
puts name | |
xml = open(ref_xml_url).read | |
# puts xml | |
parsed = REXML::Document.new(xml) | |
url = parsed.elements["video/urls/url[@quality='hd']"].text | |
100.times do | |
puts name | |
result = `#{rtmpdump} -e -r '#{url}' -o '#{name}.tmp.mp4'` | |
puts result | |
break if result =~ /Download complete/ | |
end | |
system("mv '#{name}.tmp.mp4' '#{name}.mp4'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment