Sha256: 0690acb3bc7ba4c75fe5f29ba7dbffef8fbca8013a9d31f3d6867edd989edef2
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# Main class, receives an input for STDIN and calls respective Downloaders class YoutubeSongDownloader def initialize(args) if args.length.zero? || args[0] == '-h' || args[0] == '--help' SimpleLogger.print_help_message exit 0 else @input = args[0] @counter = Counter.new @counter.current = 1 @settings = FileSettings.new(args[1]) end end def download if @input.include?('.txt') download_file_songs(@input) else @counter.total = 1 download_playlist_or_song(@input) end SimpleLogger.done(@settings) end def download_file_songs(filename) @counter.total = File.open(filename).readlines.size File.open(filename).each_line.with_index do |input, line_number| @counter.current = line_number + 1 download_playlist_or_song(input) end end def download_playlist_or_song(input) if PlaylistDownloader.playlist?(input) @counter.playlist = true PlaylistDownloader.download(input, @counter, @settings) else @counter.playlist = false SongDownloader.download(input, @counter, @settings) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ytsongdw-0.2.0 | lib/youtube_song_downloader.rb |
ytsongdw-0.1.4 | lib/youtube_song_downloader.rb |
ytsongdw-0.1.3 | lib/youtube_song_downloader.rb |