pass magnet file to deluge-console, xargs, one-liner

22,43,55 * * * * debian-deluged /var/lib/deluged/deluge.sh
Script:
#!/bin/bash

curl -sL https://rarbg2018.org/rssdd.php?category=53 | \
grep -E -o "magnet.*</link>" | \
sed "s|</link>||" | \
xmlstarlet unesc | \
while IFS= read -r MAGNET 
do {

# if file does not exist then creat it
[[ ! -f ~/already.log ]] && touch ${HOME}/already.log

HASH=$(echo "$MAGNET" | grep -Eo "[0-9a-f]{40}")
echo "checking $HASH"

# check if this magnet has been already downloaded
grep "$HASH" ${HOME}/already.log > /dev/null

# if it is NOT, then:
if [ $? -ne 0 ]; then

# print magent URL on screen
echo "$HASH not found. Adding magnet"

# mark it as downloaded
echo "$HASH" >> ${HOME}/already.log

echo "$MAGNET" | xargs -I{} deluge-console -c /var/lib/deluged/config add '{}'
fi

} done

No comments: