Skip to content

Instantly share code, notes, and snippets.

@ohac
Created May 19, 2014 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohac/80d2539ae5d49144c438 to your computer and use it in GitHub Desktop.
Save ohac/80d2539ae5d49144c438 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'fileutils'
=begin
~/.aria2/aria2.conf example
---
seed-ratio=0.0
dht-entry-point=192.168.0.1:6881
dht-listen-port=6881
bt-enable-lpd
bt-save-metadata
=end
def system2(cmd)
`#{cmd}`
end
target = ARGV[0]
exit unless target
tracker = ''
torrent = "#{target}.torrent"
FileUtils.rm_f(torrent)
result = system2("mktorrent -a '#{tracker}' '#{target}'")
result = system2("aria2c -S '#{torrent}'")
magnet = result.split("\n").find{|l| /^Magnet URI: / === l}
puts magnet.split('&')[0]
exec("aria2c -V -q '#{torrent}'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment