Convert a Magnet Link to a Torrent File


Posted on December 22, 2021


Start by Installing Aria2
Let's say you have a 5-minute video and you want to chop off a 29-second section from it. We'll assume here that you want to chop off the section that begins after 10 seconds into the video, and that your video file is named "Thriller".

First install Aria2 using these two commands:

sudo apt-get update

sudo apt-get install aria2
Fetch the Torrent File Using Aria2
Let's say you have a photo and you want to convert it into a video. We'll assume here that you want a 5-minute video, and that your photo file is named "Babyface" and the video file will be named "Thriller".

aria2c -d . --bt-metadata-only=true --bt-save-metadata=true --listen-port=6881 magnet-url

aria2c -d . --bt-metadata-only=true --bt-save-metadata=true --listen-port=6881 "magnet:?xt=urn:btih:c580af287f30b369cd4f94bf88ad9c7174f27cc9&dn=Anne.with.an.E.SEASON.01.S01.COMPLETE.720p.WEBRip.2CH.x265.HEVC-PSA&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2780%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2730%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce"
Rename the Torrent File to a Human-Friendly Filename Rather Than a Hash
Let's say you have a photo and you want to convert it into a video. We'll assume here that you want a 5-minute video, and that your photo file is named "Babyface", your audio file is named "Lovely", and the video file will be named "Thriller".

# display a human-friendly filename rather than the hash value # aria2c --show-files hash.torrent | grep Name | cut -c7- aria2c --show-files c580af287f30b369cd4f94bf88ad9c7174f27cc9.torrent | grep Name | cut -c7- # rename the torrent file # mv hash.torrent "$(aria2c --show-files hash.torrent | grep Name | cut -c7-).torrent" mv -vi c580af287f30b369cd4f94bf88ad9c7174f27cc9.torrent "$(aria2c --show-files c580af287f30b369cd4f94bf88ad9c7174f27cc9.torrent | grep Name | cut -c7-).torrent" # rename the torrent file using a different method from the one above # mv hash.torrent " `aria2c -S hash.torrent | grep Name | cut -c7-`.torrent" mv -vi c580af287f30b369cd4f94bf88ad9c7174f27cc9.torrent "`aria2c -S c580af287f30b369cd4f94bf88ad9c7174f27cc9.torrent | grep Name | cut -c7-`.torrent" # create a text file with the filename of the torrent touch "$(aria2c --show-files c580af287f30b369cd4f94bf88ad9c7174f27cc9.torrent | grep Name | cut -c7-).txt"

A simpler method is to crop or scale like crop=550:764, but the above command will work with any input size.

  • If you have any questions or comments, you can contact me on Twitter: @patrickwayodi