Class: YoutubeSync::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/youtube_sync.rb

Instance Method Summary collapse

Instance Method Details

#performObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/youtube_sync.rb', line 31

def perform
  dir, file  = options[:dir], options[:file]
  
  file = File.exist?(file) ? file : File.join(dir, file)
  
  [dir, file].each  do |required|
    say "#{required} not exist", :red and return unless File.exist?(required)
  end
  
  open(file, 'r').each_line do |video|
    video.strip!
    
    if video.start_with? '#'
      say "Skipping  #{video}", :yellow
      next 
    end
    
    say "Downloading: #{video}", :green
    
    `cd #{dir} && viddl-rb -a #{video}`
  end  
  say "Done!", :green
end