2 # Algorithm borrowed from http://wiki.rtorrent.org/MagnetUri and adapted to work with zsh.
5 function magnet_to_torrent() {
6 [[ "$1" =~ xt=urn:btih:([^\&/]+) ]] || return 1
10 if [[ "$1" =~ dn=([^\&/]+) ]];then
16 echo "d10:magnet-uri${#1}:${1}e" > "$filename.torrent"