Skip to content

Instantly share code, notes, and snippets.

@delebedev
Last active August 29, 2015 14:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delebedev/8823bf1dc09274fb06a8 to your computer and use it in GitHub Desktop.
Save delebedev/8823bf1dc09274fb06a8 to your computer and use it in GitHub Desktop.
Get all fresh WWDC sessions at once
#!/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
@shiroginne
Copy link

next if Dir.entries(WWDC_DIR).include?(file)

;)

@delebedev
Copy link
Author

@freemansion
Copy link

Receive message: gimmeWWDC.rb:10:in `

': uninitialized constant FileUtils (NameError)
should to add: require 'fileutils'

@wanderwaltz
Copy link

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