Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Created November 24, 2019 01:41
Show Gist options
  • Save Beyarz/d17f0938f34f2d4d029509b158053393 to your computer and use it in GitHub Desktop.
Save Beyarz/d17f0938f34f2d4d029509b158053393 to your computer and use it in GitHub Desktop.
Vimeo CSV downloader
# Video ID Video Title Plays Likes Download URL
1 ID NAME 0 0 https://player.vimeo.com/play/abc&download=1
2 ID NAME 0 0 https://player.vimeo.com/play/efg&download=1
3 ID NAME 0 0 https://player.vimeo.com/play/hij&download=1
# frozen_string_literal: true
require 'roo'
require 'uri'
require 'open-uri'
puts
puts 'Files: '
puts Dir.glob('*.csv')
puts
DIR_NAME = 'Vimeo_downloads'
Dir.exist?(DIR_NAME) || Dir.mkdir(DIR_NAME)
picked_files = []
keep_getting_input = true
print 'File name: '
while keep_getting_input == true
input_file = gets.chomp
if input_file == ''
keep_getting_input = false
puts
else
print 'File name: '
picked_files << input_file
end
end
puts 'Downloading videos...'
picked_files.each do |picked_file|
target = Roo::Spreadsheet.open('./' + picked_file, extension: :csv)
amount = target.last_row
2.upto(amount) do |row|
name = target.cell('C', row)
url = URI(target.cell('F', row))
Kernel.open(url, 'r') do |chunk|
file = File.open("./#{DIR_NAME}/#{name}.mp4", 'w')
file.write chunk.read
file.close
end
end
end
puts 'Done!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment