Guest User

Untitled

a guest
Feb 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Loop through watch directory
  4. for filename in /path/to/watch/directory/*.magnet; do
  5. # Assign the contents of the magnet file to a variable
  6. magnet="`cat "$filename"`"
  7. # Check if magnet file contains hash
  8. [[ "$magnet" =~ xt=urn:btih:([^&/]+) ]] || exit;
  9. # cd to watch directory
  10. cd /path/to/watch/directory/
  11. # Create torrent file with data in expected format
  12. echo "d10:magnet-uri${#magnet}:${magnet}e" > "meta-${BASH_REMATCH[1]}.torrent"
  13. # Delete the magnet file
  14. rm "$filename"
  15. done
Add Comment
Please, Sign In to add comment