Advertisement
17Genr

magnetify - shell script to convert magnet hashes to links

Jan 19th, 2014
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.21 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # magnetify - dress up a magnet hash so you can make it clickable or use it in a torrent client
  4. #             that supports magnet links, like tranmission (www.transmissionbt.com/‎).
  5. #
  6. # HEY!: why can't you just add the magnet hash directly into the torrent client?
  7. #
  8. # Language: sh
  9. # Author: Burton Samograd <burton@samograd.ca>
  10. # License: GPL3 or higher if applicable
  11. # Copyleft 2014
  12.  
  13. # The idiom ${x?"error message"} will test to see if the variable is set, and print the
  14. # message "error message" and exit the shell (returning an error code) if it isn't.
  15. #
  16. # $1 is the first command line argument given to the script, followed by $2, $3...
  17. # It's good to put these $n variables into names at the top of the script so you
  18. # don't lose track of them.  Good variable names are very im-por-tant.
  19. #
  20. # To get all arguments usefully use "$@" (don't ask), but if you don't have spaces
  21. # in your filenames (I mean, who does that these days?) you can use the old skool $*
  22. #
  23. hash=${1?"usage: magnetify <torrent magnet link hash>"}
  24. echo "magnet:?xt=urn:btih:$hash"
  25.  
  26. exit 0 # return success, but don't dot (.) this or you'll kill your shell
  27.  
  28. # tested with 71b4bcd801233939144ebf24ecf33d0fbdb6f317, #worksforme
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement