Skip to content

Instantly share code, notes, and snippets.

@Goon3r
Last active March 27, 2020 10:55
Show Gist options
  • Save Goon3r/ee45281c41ec9804b0b3c7c3b1936dbb to your computer and use it in GitHub Desktop.
Save Goon3r/ee45281c41ec9804b0b3c7c3b1936dbb to your computer and use it in GitHub Desktop.
Uses inotify to push torrents from watch directory directly into deluge via deluge-console
#!/usr/bin/env bash
DELUGE_HOST=127.0.0.1
DELUGE_PORT=12345
DOWNLOAD_DIR=~/downloads
WATCH_DIR=~/watch
LOG_FILE=~/var/logs/deluge-console-inotify.log
if [ ! -d $(dirname "${LOG_FILE}") ]; then
mkdir -p $(dirname "${LOG_FILE}")
fi
inotifywait -m -e create -e moved_to --format "%w%f" "${WATCH_DIR}" | while read file
do
if [[ "$file" =~ .*torrent$ ]]; then # Only handle torrent files
echo "Adding $file"
echo "Adding $file" >> $LOG_FILE
RESPONSE=$(deluge-console "connect ${DELUGE_HOST}:${DELUGE_PORT}; add \"$file\" -p ${DOWNLOAD_DIR}; exit")
echo $RESPONSE >> $LOG_FILE
rm "$file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment