diff --git a/README.md b/README.md index 333f91c94b966e73d558c38766cee4421b6e7dcb..ac8e545cdd913857a11fbfce735fb59885631d34 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,9 @@ Default configuration (change it by superseding in `_config.yml`): flags: '' bin: 'transmission-create' -* `announce` is the URL of the tracker. +* `announce` is the URL of the tracker. It can also be an array. Use + the special value `'random'` if you want to use 3 random trackers from + <https://torrents.me/tracker-list/> * `file` is the torrent filename. diff --git a/lib/jekyll-torrent.rb b/lib/jekyll-torrent.rb index 194e23206dcdf9183ca4bd4ae7a2d2333ea2ec5e..5c66c0eb41ea63a5c1881124b71a823efb65908c 100644 --- a/lib/jekyll-torrent.rb +++ b/lib/jekyll-torrent.rb @@ -14,13 +14,22 @@ module Jekyll def make_torrent # The torrent file is written at the root of the site file = "#{dest}/#{torrent['file']}" + tracker = [torrent[:announce]].flatten + tracker = random_tracker if tracker == 'random' + trackers = tracker.join(' --tracker ') # Delete existing file since `mktorrent` doesn't overwrite it File.delete(file) if File.exists?(file) puts "Generating torrent file at #{file}" # TODO usar popen3 - puts `#{torrent[:bin]} --tracker "#{torrent[:announce]}" --outfile "#{file}" #{torrent[:flags]} "#{dest}"` + puts `#{torrent[:bin]} --tracker #{trackers} --outfile "#{file}" #{torrent[:flags]} "#{dest}"` + end + + def random_tracker + open('https://torrents.me/tracker-list/?download=latest') do |l| + l.read + end.split("\n").sample(3) end # Alias method chain diff --git a/lib/jekyll-torrent/version.rb b/lib/jekyll-torrent/version.rb index 247fa7524dd8cb9af1eaf9afd6040b74428bef42..7392d8d2c429e71c377bef5a6c71a8d9e2585d8b 100644 --- a/lib/jekyll-torrent/version.rb +++ b/lib/jekyll-torrent/version.rb @@ -1,3 +1,3 @@ module JekyllTorrent - VERSION = "0.0.3" + VERSION = "0.0.4" end