summaryrefslogtreecommitdiff
path: root/bin/extra/magnet2torrent
blob: 0a1f83e08244cd31737a5ebbe660b09870699696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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}"