Sha256: c9cd38b217fa9349aa0e1462aa2c256f71d910dd7d1b1c8aa292e4bc83ad1be3

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module SpotifyToMp3
  class App
    def initialize(track_id_resolver, grooveshark)
      @track_id_resolver = track_id_resolver
      @grooveshark = grooveshark
    end

    def run
      file = ARGV.first or raise "No songs file specified. Usage: #{$0} file"
      FileTrackIds.new(file).each do |track_id|
        begin
          puts "Resolving \"#{track_id}\""
          track = @track_id_resolver.resolve(track_id)

          puts "Searching \"#{track}\" on Grooveshark"
          grooveshark_track = @grooveshark.get_track(track.grooveshark_query)

          print "Found \"#{grooveshark_track}\""
          if File.exists?(grooveshark_track.filename)
            # To know about songs no longer in download list
            FileUtils.touch grooveshark_track.filename 

            puts ", already exists, skipping"
          else
            puts ", downloading..."
            @grooveshark.download(grooveshark_track)
          end
        rescue Exception => exception # For some reason without the "Exception" it is ignored
          puts exception.message.red
          # Continue with the next track
        end
      end
    rescue
      puts "#{$!}".red
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spotify-to-mp3-0.5.4 lib/spotify_to_mp3/app.rb
spotify-to-mp3-0.5.3 lib/spotify_to_mp3/app.rb
spotify-to-mp3-0.5.2 lib/spotify_to_mp3/app.rb
spotify-to-mp3-0.5.1 lib/spotify_to_mp3/app.rb