class Object
Public Instance Methods
get_video(name, link, pass)
click to toggle source
Replace this with ruby binding
# File lib/aa-vimeo-downloader.rb, line 116 def get_video(name, link, pass) title = "#{name}.%(ext)s" command = %{youtube-dl --video-password "#{pass}" -o "#{title}" #{link}} YoutubeDL.download link, { "video-password": pass, "o": title } # begin # PTY.spawn(command) do |stdout, _stdin, _pid| # begin # stdout.each { |line| print line } # rescue Errno::EIO # end # end # rescue PTY::ChildExited # puts "The child process exited!" # end end
has_youtube_dl?()
click to toggle source
should be able to remove this once binding works correctly
# File lib/aa-vimeo-downloader.rb, line 46 def has_youtube_dl? if `which youtube-dl` =~ /^$/ print <<~HEREDOC The dependency 'youtube_dl' is not installed. To install this program, see https://rg3.github.io/youtube-dl/download.html Are you using OSX or Linux and would like to install youtube_dl automatically? HEREDOC print "[Y/N]: " if STDIN.gets =~ /y/i raise "Install failed; please install manually" unless install_youtube_dl return true else abort('Install youtube_dl to use this program') end end end
install_youtube_dl()
click to toggle source
# File lib/aa-vimeo-downloader.rb, line 68 def install_youtube_dl `sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl` `sudo chmod a+rx /usr/local/bin/youtube-dl` `which youtube-dl` =~ /^$/ end
make_video_dir(creds, links)
click to toggle source
# File lib/aa-vimeo-downloader.rb, line 96 def make_video_dir(creds, links) vdirname = "#{creds.day}_videos" Dir.mkdir vdirname unless Dir.exists?(vdirname) Dir.chdir vdirname p "Created the directory #{vdirname}" links.each do |name, link| if Dir.entries('.').find { |e| e.index name } puts "#{name} already exists; continuing to next video" else get_video(name, link, creds.vimeo_password) end end p "#{vdirname} successfully created with #{Dir.entries('.').reject { |e| e =~ /^\./ }.count} videos" print `ls -1` end