Skip to content

Instantly share code, notes, and snippets.

@webdevotion
Created May 23, 2013 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save webdevotion/5635755 to your computer and use it in GitHub Desktop.
Save webdevotion/5635755 to your computer and use it in GitHub Desktop.
The Vimeo API currently does not allow you to fetch the direct links for private Pro videos through their API. This `rake` task fetches the HTTP Live Streaming link so you can you `MPMoviePlayerController` in you iOS applications in stead of a webview.
namespace :vimeo do
desc "Get Vimeo HTTP Live Streaming link for private Pro videos"
task :direct => :environment do |t,args|
your_video_id = "66666666" # change this to your video id
loginURL = "https://vimeo.com/log_in"
videoFormAction = "/#{your_video_id}/settings/file"
videoURL = "https://vimeo.com/#{videoFormAction}"
a = Mechanize.new { |agent|
agent.follow_meta_refresh = true
}
a.get(loginURL) do |loginPage|
# set xsrft token necessary to login
token = loginPage.body.match(/xsrft: '(.*)',/)[1]
cookie = Mechanize::Cookie.new("xsrft",token)
cookie.domain = ".vimeo.com"
cookie.path = "/"
a.cookie_jar.add(a.history.last.uri,cookie)
# submit the login form
privateMemberPage = a.post('#{loginURL}',{
"email" => "email@example.com",
"password" => "superprivate",
"action" => "login",
"service" => "vimeo",
"token" => token
})
vimeo_http_live_stream = "something went wrong"
videoFileSettingsPage = a.get(videoURL) do |videoPage|
results = videoPage.body.scan(/value="(.*)" class="media_url" readonly/)
vimeo_http_live_stream = results.last[0]
end
puts "vimeo_http_live_stream: #{vimeo_http_live_stream}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment