Skip Navigation
Useful Scripts @lemmy.ml d4nm3d @lemmy.ml

[SHELL] Convert .magnet to .torrent

I use this on my seedbox for anything sonarr grabs and sends to my blackhole that is a .magnet file rather than .torrent.

#!/bin/bash
File="$(find /PATH/TO/MAGNET/FILES -name '*.magnet' -print -quit)"
set -- $File
Filecontents="$(cat "$File")"
set -- $Filecontents
cd /PATH/TO/MAGNET/FILES
[[ "$Filecontents" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"
rm "$File"
0
0 comments