Class: Torrent

Inherits:
Object
  • Object
show all
Includes:
OpenURI::OpenRead
Defined in:
lib/torrent.rb

Class Method Summary collapse

Class Method Details

.download(link, http_options = {}, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/torrent.rb', line 7

def self.download(link, http_options = {}, options = {})
  return if options[:dry_run]

  uri = URI.parse(link)
  download_dir = http_options.delete(:download_dir)
  torrent = uri.read(http_options)
  t = Transmission::Client.new(options[:transmission_server], options[:transmission_port])
  t.add_torrent('metainfo' => Base64.encode64(torrent), 'download-dir' => download_dir)
end