Skip to content

Instantly share code, notes, and snippets.

@debuti
Created July 9, 2024 21:15
Show Gist options
  • Save debuti/8ba706862b447d18282810e61e65f871 to your computer and use it in GitHub Desktop.
Save debuti/8ba706862b447d18282810e61e65f871 to your computer and use it in GitHub Desktop.
Generate a torrent file for a file or folder
#!/bin/bash
usage() { echo "Usage: $0 [-u <USR>] [-p <PWD>] <file-or-folder>" 1>&2; exit 1; }
while getopts ":u:p:" o; do
case "${o}" in
u)
u=${OPTARG}
;;
p)
p=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
FILE="$(readlink -f "$1")"
DIRNAME="$(dirname "$FILE")"
transmission-create "$FILE" $(curl -sSf https://ngosang.github.io/trackerslist/trackers_best.txt | sed '/^$/d' | sed 's/^/-t /g')
torrent="$(ls -1t *torrent | head -1)"
transmission-remote --auth=$u:$p -a "$torrent" --no-start-paused --trash-torrent --download-dir "$DIRNAME"
#transmission-remote --auth=$u:$p -l
echo "Send $torrent to share $1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment