Skip to content

Instantly share code, notes, and snippets.

@pbendersky
Created June 10, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbendersky/95863e36f42b8deaf684 to your computer and use it in GitHub Desktop.
Save pbendersky/95863e36f42b8deaf684 to your computer and use it in GitHub Desktop.
WWDC 2015 Video Downloader
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