summaryrefslogtreecommitdiff
path: root/bin/extra/magnet2torrent
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-02-24 15:06:36 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-02-24 15:06:36 +0100
commitb625ace8c9fbb9df6be17b1c3b1519ac6325d8b9 (patch)
tree15b9aeecff5fd78d17f1355c3f36f315c1095364 /bin/extra/magnet2torrent
parent0bf822bd012e63fbfcc8bd6cab6c033d98e8cad2 (diff)
parent363f4b6dd28fd4d7b30f8a669efea4b16f96a268 (diff)
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin/extra/magnet2torrent')
-rwxr-xr-xbin/extra/magnet2torrent27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/extra/magnet2torrent b/bin/extra/magnet2torrent
new file mode 100755
index 0000000..0a1f83e
--- /dev/null
+++ b/bin/extra/magnet2torrent
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#################################
+# #
+# Bash script to convert a #
+# magnet link to a torrent file #
+# #
+# StrickStuff.com #
+# #
+#################################
+
+
+# Check that the user entered a valid magnet link
+if [ "$#" -ne 1 ] || [ "${1##*magnet*}" ]
+then
+ echo "Usage: $0 "
+ exit 1
+fi
+
+# Extract the info hash from the magnet link
+hash="${1##*btih:}"
+hash="${hash%%&*}"
+
+# Download the torrent file from a torrent website
+torrent_file="${hash}.torrent"
+wget "https://itorrents.org/torrent/${hash}.torrent" -O "$torrent_file"
+echo "Torrent file written to ${torrent_file}"