Skip to content

Instantly share code, notes, and snippets.

@yesmar
Created February 10, 2018 19:40
Show Gist options
  • Save yesmar/2994a69010fab373ec95e3a80c630904 to your computer and use it in GitHub Desktop.
Save yesmar/2994a69010fab373ec95e3a80c630904 to your computer and use it in GitHub Desktop.
Pull down Apple's HD screensaver vids from Phobos
#!/usr/bin/env ruby
# atv_vidslurp.rb, 20161216 yesmar@gmail.com
# Pull down Apple's HD screensaver vids from Phobos.
require 'net/http'
require 'json'
PHOBOS_URL='http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json'
uri = URI(PHOBOS_URL)
response = Net::HTTP.get(uri)
root = JSON.parse(response)
root.each { |collection|
collection['assets'].each { |asset|
if asset['type'] =~ /video/i
filebase = File.basename(asset['url'])
detail = "#{asset['accessibilityLabel']} #{asset['timeOfDay']}"
filename = "#{detail.split.collect(&:downcase).join('_')}_#{filebase}"
puts "▶︎ #{filename}"
system("curl -#L #{asset['url']} -o #{filename}")
end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment