def download(torrent)
      return [:failed, 'no download link available'].red unless torrent[:download]

      # Lazy hack. Future Me won't be happy ¯\_(ツ)_/¯
      unless (uri = URI(URI.encode torrent[:download])).scheme
        uri = URI(URI.encode "https:#{torrent[:download]}")
      end
      uri.query = nil

      file = "#{ @options[:output] || '.' }/" \
             "#{ torrent[:title].tr(' ', ?.).gsub(/[^a-z0-9()_.-]/i, '') }.torrent"

      fail '404 File Not Found' if (res = Net::HTTP.start(uri.host) do |http|
        http.get uri
      end).code == '404'

      File.open(File.expand_path(file), 'w') { |f| f.write res.body }

      :done.green
    rescue => e
      [:failed, e.message].red
    end
def download(torrent)
      return [:failed, 'no download link available'].red unless torrent[:download]

      # Lazy hack. Future Me won't be happy ¯\_(ツ)_/¯
      unless (uri = URI(URI.encode torrent[:download])).scheme
        uri = URI(URI.encode "https:#{torrent[:download]}")
      end
      uri.query = nil

      file = "#{ @options[:output] || '.' }/" \
             "#{ torrent[:title].tr(' ', ?.).gsub(/[^a-z0-9()_.-]/i, '') }.torrent"

      fail '404 File Not Found' if (res = Net::HTTP.start(uri.host) do |http|
        http.get uri
      end).code == '404'

      File.open(File.expand_path(file), 'w') { |f| f.write res.body }

      :done.green
    rescue => e
      [:failed, e.message].red
    end
Download the torrent to either the output directory or the working directory