Created
February 10, 2018 19:40
-
-
Save yesmar/2994a69010fab373ec95e3a80c630904 to your computer and use it in GitHub Desktop.
Pull down Apple's HD screensaver vids from Phobos
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 | |
# 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