Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "json"
- require "open-uri"
- require "fileutils"
- @hash
- File.open("youtube-list.json") do |j|
- @hash = JSON.load(j)
- end
- # thumbnails という名前のディレクトリを作る処理をかけ
- FileUtils.mkdir_p("thumbnails") unless File.exist?("thumbnails")
- @hash.each_with_index do |data, i|
- File.open("thumbnails/#{i}-#{data["published_at"]}.jpg", "wb") do |file|
- open(data["thumbnails"]) do |img|
- file.puts img.read
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement