Last active
November 8, 2020 05:01
-
-
Save jfeilbach/ab0c19ff06e3358213039a3693a628b0 to your computer and use it in GitHub Desktop.
Move torrent from qbittorrent to Transmission read ${1} and ${2} from input
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
#!/bin/bash | |
NC='\033[0m' # No color | |
Green='\033[0;32m' # Green | |
White='\033[0;37m' # White | |
Red='\033[0;31m' # Red | |
dldir=/dl_1 | |
mnt1=/mnt/picard_e/ | |
mnt2=/mnt/picard_f/ | |
mnt3=/mnt/picard_g/ | |
queue=/home/jason/queue | |
finish=/home/jason/finish | |
pause () { | |
arg1=$1 | |
hash=$arg1 | |
echo -e "\n${White} Name = ${White}${name}${NC}${NC}" | |
echo -e "\n${White} Hash = ${White}${hash}${NC}${NC}" | |
echo "" | |
url1=http://picard:8080/api/v2/auth/login | |
url2=http://picard:8080/api/v2/torrents/pause?hashes=$hash | |
echo -e "URL1 = ${White}${url1}${NC}" | |
curl -s -c ~/cookie.txt -i --header 'Referer: http://picard:8080' --data 'username=admin&password=<>' "$url1" |head -n 1 | |
echo -e "URL2 = ${White}${url2}${NC}" | |
curl -s -b ~/cookie.txt -i "$url2" | head -n 1 | |
} | |
add () { | |
echo -e "\n${Green} Adding torrent ${White}${name}${NC} to Transmission.${NC}\n" | |
/usr/bin/transmission-remote --add ${queue}/${hash}.torrent --download-dir ${dldir} --start-paused --verify --no-trash-torrent | |
} | |
move () { | |
src=${mnt}${name} | |
echo -e " Will transfer from ${White}${src}${NC}.\n" | |
rsync -avh --stats --progress "${src}" ${dldir} | |
} | |
search_mnt () { | |
for m in $mnt1 $mnt2 $mnt3; do | |
search=${m}${name} | |
ls -d "${search}" > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
export mnt=${m} | |
echo -e "\n${Green}Files found in ${mnt}.${NC}\n" | |
return 0 | |
fi | |
done | |
if [ "$mnt" = "" ]; then | |
echo -e "${Red} Warning \$mnt variable is empty. Cound not find files in any mount points. Exiting.${NC}\n" | |
read -p $'\e[33mPress Enter to continue...\e[0m' | |
fi | |
} | |
name="${1}" | |
hash="${2}" | |
search_mnt "${name}" | |
move "${name}" | |
cp -v ${queue}/$hash.torrent ${finish} | |
pause $hash | |
add $hash | |
unset hash name url1 url2 src | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
step 2 of 3