Skip to content

Instantly share code, notes, and snippets.

@codebutler
Created November 29, 2009 00:51
Show Gist options
  • Save codebutler/244726 to your computer and use it in GitHub Desktop.
Save codebutler/244726 to your computer and use it in GitHub Desktop.
Quick script to get the magnet URI for a .torrent file.
#!/usr/bin/ruby
# Quick script to get the magnet URI for a .torrent file.
# Eric Butler <eric@codebutler.com>
# sudo gem install rubytorrent base32
# ruby get_torrent_magnet.rb myfile.torrent
require 'rubygems'
require 'rubytorrent'
require 'base32'
torrent = RubyTorrent::MetaInfo.from_location(ARGV[0])
puts 'magnet:?xt=urn:btih:' + Base32.encode(torrent.info.sha1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment