module SimpleLogger
Simple STDOUT logger containing all texts
Public Class Methods
base_progress(_element, counter)
click to toggle source
# File lib/simple_logger.rb, line 15 def self.base_progress(_element, counter) "#{counter.current}/#{counter.total}" end
couldnt_fetch_playlist_url()
click to toggle source
# File lib/simple_logger.rb, line 50 def self.couldnt_fetch_playlist_url log "COULDN'T FETCH PLAYLIST VIDEO URLS" end
done(settings)
click to toggle source
# File lib/simple_logger.rb, line 54 def self.done(settings) log "DONE (see the folder '#{settings.folder}')" end
downloading(song)
click to toggle source
# File lib/simple_logger.rb, line 37 def self.downloading(song) log "DOWNLOADING #{song.url}/#{song.name}" end
finished_downloading()
click to toggle source
# File lib/simple_logger.rb, line 41 def self.finished_downloading log 'FINISHED' log '' end
found_no_results(url)
click to toggle source
# File lib/simple_logger.rb, line 46 def self.found_no_results(url) log "DIDNT FIND ANY RESULTS FOR #{url}" end
log(text)
click to toggle source
# File lib/simple_logger.rb, line 3 def self.log(text) puts "# #{text}" end
maximum_number_of_tries()
click to toggle source
# File lib/simple_logger.rb, line 29 def self.maximum_number_of_tries log 'MAXIMUM NUMBER OF TRIES EXCEEDED' end
playlist_progress(element, counter)
click to toggle source
# File lib/simple_logger.rb, line 23 def self.playlist_progress(element, counter) log "#{base_progress(element, counter)}" \ " <#{counter.playlist_current}/#{counter.playlist_total}>" \ " - #{element.name}" end
print_help_message()
click to toggle source
# File lib/simple_logger.rb, line 58 def self.print_help_message log 'You should pass one or two parameters: The song name/youtube url or the file' log 'containing all youtube songs/urls to download and an optional folder to download' log 'it to (defaults to ~/Music)' log 'make sure youve run `bundle install` first to download dependencies and then one of:' log 'Example1: bundle exec download_m4a.rb test.txt' log 'Example2: bundle exec download_m4a.rb "https://www.youtube.com/watch?v=bM7SZ5SBzyY"' log 'Example3: bundle exec download_m4a.rb "https://www.youtube.com/playlist?list=PL9B23A78D3D249A74"' log 'Example4: bundle exec download_m4a.rb "Titanic Song"' end
progress(element, counter)
click to toggle source
# File lib/simple_logger.rb, line 7 def self.progress(element, counter) if counter.playlist playlist_progress(element, counter) else song_progress(element, counter) end end
retry(url, name, number_of_tries)
click to toggle source
# File lib/simple_logger.rb, line 33 def self.retry(url, name, number_of_tries) log "COULDN'T DOWNLOAD #{url}/#{name} TRY ##{number_of_tries}" end
song_progress(element, counter)
click to toggle source
# File lib/simple_logger.rb, line 19 def self.song_progress(element, counter) log "#{base_progress(element, counter)} - #{element.name}" end