Top Level Namespace
Defined Under Namespace
Classes: Aa_vimeo_downloader, Credentials, GitRaw, LinkParser
Instance Method Summary collapse
-
#get_video(name, link, pass) ⇒ Object
Replace this with ruby binding.
-
#has_youtube_dl? ⇒ Boolean
should be able to remove this once binding works correctly.
- #install_youtube_dl ⇒ Object
- #make_video_dir(creds, links) ⇒ Object
Instance Method Details
#get_video(name, link, pass) ⇒ Object
Replace this with ruby binding
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# 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? ⇒ Boolean
should be able to remove this once binding works correctly
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 ⇒ Object
68 69 70 71 72 |
# 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) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# 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 |