Last active
August 29, 2015 14:22
-
-
Save delebedev/8823bf1dc09274fb06a8 to your computer and use it in GitHub Desktop.
Get all fresh WWDC sessions at once
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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'json' | |
require 'ostruct' | |
require 'fileutils' | |
PATH = "https://devimages.apple.com.edgekey.net/wwdc-services/ftzj8e4h/6rsxhod7fvdtnjnmgsun/videos.json" | |
WWDC_DIR = "#{Dir.home}/Downloads/wwdc" | |
FileUtils.mkdir_p(WWDC_DIR) unless File.exists?(WWDC_DIR) | |
uri = URI(PATH) | |
json = Net::HTTP.get(uri) | |
sessions = JSON.parse(json)['sessions'].map { |x| OpenStruct.new(x) } | |
sessions.select {|x| x.year == 2015 }.each do |x| | |
sessionURL = x.download_sd | |
file = sessionURL.split('/').last | |
next if Dir.entries(WWDC_DIR).include?(file) | |
command = Thread.new do | |
puts "Downloading session: #{x.title}" | |
`curl #{sessionURL} --output #{WWDC_DIR}/#{file}` | |
end | |
command.join | |
end |
A handy script, thanks for this one. Would be nice to know the total download size beforehand though. Just to be sure there's enough space to get them all.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Receive message: gimmeWWDC.rb:10:in `
': uninitialized constant FileUtils (NameError)should to add: require 'fileutils'