In Files

  • bin/yt_mp3
  • lib/yt_mp3.rb
  • lib/yt_mp3/badge_progress_bar.rb
  • lib/yt_mp3/sync.rb
  • lib/yt_mp3/version.rb
  • lib/yt_mp3/youtube_mp3.rb
  • spec/sync_spec.rb
  • spec/youtube_mp3_spec.rb

YTMp3

Constants

AUTHORS
VERSION

Public Class Methods

download_progress(mp3) click to toggle source
 
               # File lib/yt_mp3.rb, line 17
def self.download_progress(mp3)
  puts ":: #{mp3.url}\n"
  
  bar = BadgeProgressBar.new
  bar.badge = "Converting"

  begin
    mp3.convert do |info|
      bar.count = (info["progress"].to_f * 100).abs
      bar.write
    end

    begin
      mp3.download
    rescue DownloadError => e
      STDERR.puts "Failed to download. Video cannot be converted. Could not exists. (#{e})"
    end
  rescue RequestFailed => e
    STDERR.puts e
  end
end
            
uri?(string) click to toggle source
 
               # File lib/yt_mp3.rb, line 8
def self.uri?(string)
  uri = URI.parse(string)
  %w( http https ).include?(uri.scheme)
rescue URI::BadURIError
  false
rescue URI::InvalidURIError
  false
end