Created
May 23, 2013 12:39
-
-
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.
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
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 protected]", | |
"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