Skip to content

Instantly share code, notes, and snippets.

@Arthur
Created December 4, 2010 13:39
Show Gist options
  • Save Arthur/728186 to your computer and use it in GitHub Desktop.
Save Arthur/728186 to your computer and use it in GitHub Desktop.
use rtmpdump to get arte videos mp4 files
#!/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