Created
June 10, 2015 14:17
-
-
Save pbendersky/95863e36f42b8deaf684 to your computer and use it in GitHub Desktop.
WWDC 2015 Video Downloader
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
require 'open-uri' | |
require 'nokogiri' | |
require 'yaml' | |
require 'mail' | |
WWDC_MAIN_URL="https://developer.apple.com/videos/wwdc/2015/" | |
def video_urls | |
doc = Nokogiri::HTML(open(WWDC_MAIN_URL)) | |
videos = Array.new | |
doc.xpath("//ul[contains(@class, 'list_videos')]/li/a").each do |video_url| | |
url = video_url.xpath("@href").to_s | |
videos << url | |
end | |
videos | |
end | |
def download_video_url(url) | |
full_url = WWDC_MAIN_URL + url | |
doc = Nokogiri::HTML(open(full_url)) | |
doc.xpath("//section[@class = 'col-25']/ul/li/a[text() = 'HD']/@href").each do |download_url| | |
output = download_url.to_s.split("/").last.split("?").first | |
system "wget #{download_url.to_s} -nc -O #{output}" | |
end | |
end | |
video_urls.each do |url| | |
download_video_url(url) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment