Skip to content

Instantly share code, notes, and snippets.

@elamperti
Last active January 17, 2021 20:15
Show Gist options
  • Save elamperti/d1ced3a405090fc6e4805307a0dc78c1 to your computer and use it in GitHub Desktop.
Save elamperti/d1ced3a405090fc6e4805307a0dc78c1 to your computer and use it in GitHub Desktop.
Cron script to transform magnet links into .torrent files
#!/bin/bash
## Follow the guide:
## https://github.com/elamperti/dotfiles/blob/master/docs/sonarr-with-tixati.md
## Or see the magnet2torrent.py script here:
## https://github.com/elamperti/Magnet2Torrent
magnet_folder=$USER/.sonarr
if [ ! -d "${magnet_folder}" ]; then
echo "Magnet folder not found"
exit 1
fi
pushd "${magnet_folder}" &>/dev/null
for magnet_file in *.magnet; do
if [ -f "$magnet_file" ]; then
torrent_file="${magnet_file%.magnet}.torrent"
echo "Creating $torrent_file"
/home/$USER/bin/magnet2torrent.py "${magnet_file}" "${torrent_file}"
if [ $? -eq 0 ]; then
rm "${magnet_file}" && echo "Removed magnet file ${magnet_file}"
fi
fi
done
popd &>/dev/null
@elamperti
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment