magnet2torrent 374 B

1234567891011121314
  1. #!/bin/sh
  2. # Original source:
  3. # <http://blog.gonzih.me/blog/2012/02/17/how-to-use-magnet-links-with-rtorrent/>.
  4. DIR="${HOME}/downloads/_torrents/misc"
  5. [[ -d "$DIR" ]] || mkdir --parents "$DIR"
  6. [[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;
  7. FILE="${DIR}/meta-${BASH_REMATCH[1]}.torrent"
  8. echo "d10:magnet-uri${#1}:${1}e" > "$FILE"
  9. notify-send "Magnet link downloaded" "$FILE"