Last active
March 27, 2020 10:55
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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