Adding more torrent engines and switching to a file for engine conf
This commit is contained in:
parent
ecb464af55
commit
10335ae2df
@ -1,5 +1,6 @@
|
|||||||
torrentengine=https://1337x.to/search/%s/1/
|
torrentengine="https://1337x.to/search/%s/1/"
|
||||||
torrentterms=printf https://1337x.to; grep "/torrent/" | head -n 1 | cut -f 2 -d \"
|
torrentterms='printf https://1337x.to; grep "/torrent/" | head -n 1 | cut -f 2 -d \"'
|
||||||
magnetposition=4
|
magnetposition='4'
|
||||||
torrentdebugging=true
|
torrentdebugging='false'
|
||||||
searchunifier=+
|
searchunifier='+'
|
||||||
|
magnetseparator=\"
|
||||||
|
6
Makefile
6
Makefile
@ -23,9 +23,11 @@ reverse:
|
|||||||
cp /usr/local/bin/wolfpack* .
|
cp /usr/local/bin/wolfpack* .
|
||||||
cp /root/bin/offload-wolfpack .
|
cp /root/bin/offload-wolfpack .
|
||||||
|
|
||||||
|
checkperm: /usr/local/etc/WolfPack/
|
||||||
|
chmod -R ug+rw /usr/local/etc/WolfPack/
|
||||||
|
chmod 0770 /usr/local/etc/WolfPack/
|
||||||
|
|
||||||
offload: offload-wolfpack /root/.ssh/id_rsa /root/.ssh/id_rsa.pub
|
offload: offload-wolfpack /root/.ssh/id_rsa /root/.ssh/id_rsa.pub
|
||||||
cp offload-wolfpack /root/bin
|
cp offload-wolfpack /root/bin
|
||||||
chmod 0700 /root/bin/offload-wolfpack
|
chmod 0700 /root/bin/offload-wolfpack
|
||||||
chown root:root /root/bin/offload-wolfpack
|
chown root:root /root/bin/offload-wolfpack
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$(pgrep -afc wolfpack)" -ne 1 ]; then
|
||||||
|
echo WolfPack is already working elsewhere.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
/usr/local/bin/wolfpack --alpha
|
/usr/local/bin/wolfpack --alpha
|
||||||
sleep 10
|
sleep 10
|
||||||
rsync -avz /srv/yggdrasil/new_acquisition/* cxford@10.0.1.3:/srv/yggdrasil/new_acquisition &>>/var/log/wolfpack.log
|
rsync -avz /srv/yggdrasil/new_acquisition/* cxford@10.0.1.3:/srv/yggdrasil/new_acquisition &>>/var/log/wolfpack.log
|
||||||
|
6
torrentproject.torrentengine.sample
Normal file
6
torrentproject.torrentengine.sample
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
torrentengine='http://torrentproject.se/?t=%s'
|
||||||
|
torrentterms="printf http://torrentproject.se; grep "verified" | head -n 1 | cut -f 2 -d \' | head -n 1"
|
||||||
|
magnetposition='2'
|
||||||
|
torrentdebugging='true'
|
||||||
|
searchunifier='+'
|
||||||
|
magnetseparator=\'
|
98
wolfpack
98
wolfpack
@ -1,10 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /usr/local/src/SharedLibraries/Bash/header
|
source /usr/local/etc/WolfPack/torrentengine
|
||||||
|
export IFS="
|
||||||
# Logging
|
"
|
||||||
export logfile='/var/log/wolfpack.log'
|
export logfile='/var/log/wolfpack.log'
|
||||||
|
|
||||||
|
|
||||||
function helptext {
|
function helptext {
|
||||||
echo '
|
echo '
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -53,15 +54,25 @@ function torrent {
|
|||||||
fi
|
fi
|
||||||
export downloaddir=$(head -n 2 "$1" | tail -n 1)
|
export downloaddir=$(head -n 2 "$1" | tail -n 1)
|
||||||
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
||||||
logstatement "Transmission is still running. Aborting."
|
echo "Transmission is still running. Aborting." | tee -a $logfile
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
for i in $(tail -n +3 "$1"); do
|
for i in $(tail -n +3 "$1"); do
|
||||||
getmagnetlink "$i"
|
export searchstring="$(echo $i | sed 's/ /+/g')"
|
||||||
torrentlink
|
export searchlink="$(printf "$torrentengine" "$searchstring")"
|
||||||
if [ ! -z "$magnetlink" ]; then
|
export searchresult=$(wget -q -O - "$searchlink" | bash -c "$torrentterms")
|
||||||
|
export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d $magnetseparator)
|
||||||
|
if [ $torrentdebugging == "true" ]; then
|
||||||
|
echo $searchstring
|
||||||
|
echo $searchlink
|
||||||
|
echo $searchresult
|
||||||
|
echo $magnetlink
|
||||||
|
read
|
||||||
|
fi
|
||||||
|
if [ "$magnetlink" != "" ]; then
|
||||||
|
/usr/bin/transmission-cli -d 1000 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
|
||||||
sed -i "/$i/d" "$1"
|
sed -i "/$i/d" "$1"
|
||||||
logstatement "Downloaded and removed $i"
|
echo Downloaded and removed $i | tee -a $logfile
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -72,7 +83,7 @@ function shows {
|
|||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
||||||
logstatement "Transmission is still running. Aborting."
|
echo "Transmission is still running. Aborting." | tee -a $logfile
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then
|
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then
|
||||||
@ -82,20 +93,33 @@ function shows {
|
|||||||
export downloaddir=$(head -n 2 "$1" | tail -n 1)
|
export downloaddir=$(head -n 2 "$1" | tail -n 1)
|
||||||
echo "Would download to "$downloaddir
|
echo "Would download to "$downloaddir
|
||||||
for i in $(tail -n +3 "$1"); do
|
for i in $(tail -n +3 "$1"); do
|
||||||
export searchsegment="$(echo $i | tr '#' "$searchunifier")"
|
export searchsegment="$(echo $i | tr '#' '+' | tr ' ' '+')"
|
||||||
getmagnetlink "$searchsegment"
|
export searchlink="$(printf "$torrentengine" "$searchsegment")"
|
||||||
if [ ! -z "$magnetlink" ]; then
|
export searchresult=$(wget -q -O - "$searchlink" | bash -c "$torrentterms")
|
||||||
|
export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d \")
|
||||||
|
if [ $torrentdebugging == "true" ]; then
|
||||||
|
echo $searchstring
|
||||||
|
echo $searchlink
|
||||||
|
echo $searchresult
|
||||||
|
echo $magnetlink
|
||||||
|
read
|
||||||
|
fi
|
||||||
|
if [ "$magnetlink" != "" ]; then
|
||||||
# We found an episode.
|
# We found an episode.
|
||||||
torrentlink
|
echo $i | tee -a $logfile
|
||||||
|
/usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
|
||||||
export sepisode=$(echo $i | cut -f 1 -d '#')
|
export sepisode=$(echo $i | cut -f 1 -d '#')
|
||||||
export searchterms="$(echo $i | cut -f 2 -d '#')"
|
export searchterms="$(echo $i | cut -f 2 -d '#')"
|
||||||
export season=$(echo $sepisode | cut -f 1 -d 'E' | cut -f 2 -d 'S')
|
export season=$(echo $sepisode | cut -f 1 -d 'E' | cut -f 2 -d 'S')
|
||||||
export episode=$(echo $sepisode | cut -f 2 -d 'E')
|
export episode=$(echo $sepisode | cut -f 2 -d 'E')
|
||||||
export ep=$(printf "%02d\n" $((${episode#0} + 1)))
|
export ep=$(printf "%02d\n" $((${episode#0} + 1)))
|
||||||
sed -i "s/$i/S"$season"E"$ep"#"$searchterms"/" "$1"
|
sed -i "s/$i/S"$season"E"$ep"#"$searchterms"/" "$1"
|
||||||
logstatement "$i was downloaded and pup updated."
|
echo Downloaded and pup updated. | tee -a $logfile
|
||||||
|
rm -Rf ~/.config/transmission/resume/*
|
||||||
|
rm -Rf ~/.config/transmission/torrents/*
|
||||||
rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Plex
|
rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Plex
|
||||||
rm -f "$downloaddir"/*/*.nfo
|
rm -f "$downloaddir"/*/*.nfo
|
||||||
|
echo | tee -a $logfile
|
||||||
else
|
else
|
||||||
# We didn't -- is there a new season?
|
# We didn't -- is there a new season?
|
||||||
export sepisode=$(echo $i | cut -f 1 -d '#')
|
export sepisode=$(echo $i | cut -f 1 -d '#')
|
||||||
@ -103,14 +127,22 @@ function shows {
|
|||||||
export season=$(echo $sepisode | cut -f 1 -d 'E' | cut -f 2 -d 'S')
|
export season=$(echo $sepisode | cut -f 1 -d 'E' | cut -f 2 -d 'S')
|
||||||
export episode=$(echo $sepisode | cut -f 2 -d 'E')
|
export episode=$(echo $sepisode | cut -f 2 -d 'E')
|
||||||
export newseason=$(printf "%02d\n" $((${season#0} + 1)))
|
export newseason=$(printf "%02d\n" $((${season#0} + 1)))
|
||||||
export newsearch="$(echo $searchsegment | sed 's/S'$season'E'$episode'/S'$newseason'E01/')"
|
export newsearch="$(echo $searchlink | sed 's/S'$season'E'$episode'/S'$newseason'E01/')"
|
||||||
getmagnetlink "$newsearch"
|
export searchresult=$(wget -q -O - "$newsearch" | bash -c "$torrentterms")
|
||||||
if [ "$magnetlinki" != "" ]; then
|
export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d \")
|
||||||
torrentlink
|
if [ $torrentdebugging == "true" ]; then
|
||||||
logstatement "$newsearch Downloaded and pup updated."
|
echo $newseason
|
||||||
|
echo $newsearch
|
||||||
|
echo $searchresult
|
||||||
|
echo $magnetlink
|
||||||
|
read
|
||||||
|
fi
|
||||||
|
if [ "$magnetlink" != "" ]; then
|
||||||
|
echo "S"$newseason"E01" $searchterms | tee -a $logfile
|
||||||
|
/usr/bin/transmission-cli -d 600 -u 1 -er -w "$downloaddir" -b -f "/usr/local/bin/wolfpack-stoptorrent" "$magnetlink"
|
||||||
sed -i "s/$i/S"$newseason"E01#"$searchterms"/" "$1"
|
sed -i "s/$i/S"$newseason"E01#"$searchterms"/" "$1"
|
||||||
else
|
else
|
||||||
logstatement "No new season found after $searchterms"
|
echo "No new season found for" $searchterms | tee -a $logfile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -134,14 +166,14 @@ function download {
|
|||||||
export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)"
|
export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)"
|
||||||
#if file doesn't already exist....
|
#if file doesn't already exist....
|
||||||
if [ ! -f "$filename" ]; then
|
if [ ! -f "$filename" ]; then
|
||||||
logstatement "Downloading $nexturl to $filename ..."
|
echo Downloading $nexturl to $filename ... | tee -a $logfile
|
||||||
export dedupterm="$(echo $1 | cut -f 1 -d '.' | rev | cut -f 1 -d '/' | rev)"
|
export dedupterm="$(echo $1 | cut -f 1 -d '.' | rev | cut -f 1 -d '/' | rev)"
|
||||||
for i in $(find "$downloaddir" | grep -i "$dedupterm"); do
|
for i in $(find "$downloaddir" | grep -i "$dedupterm"); do
|
||||||
logstatement "Deduped! Removed $i from $downloaddir"
|
echo Deduped! Removed $i from $downloaddir | tee -a $logfile
|
||||||
rm -Rf $i;
|
rm -Rf $i;
|
||||||
done
|
done
|
||||||
wget -q -O "$filename" "$nexturl"
|
wget -q -O "$filename" "$nexturl"
|
||||||
logstatement "Downloaded"
|
echo Downloaded | tee -a $logfile
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +187,7 @@ function search {
|
|||||||
export searchstring=$(echo $i | sed 's/ /+/g')
|
export searchstring=$(echo $i | sed 's/ /+/g')
|
||||||
export file="$downloaddir"/$searchstring'.txt'
|
export file="$downloaddir"/$searchstring'.txt'
|
||||||
echo | googler --count=5 -C -x "$searchstring" | grep -v 'Enter n, p, result' > "$file"
|
echo | googler --count=5 -C -x "$searchstring" | grep -v 'Enter n, p, result' > "$file"
|
||||||
logstatement "Ran search for $searchstring to $file"
|
echo 'Ran search for '$searchstring' to '$file | tee -a $logfile
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,15 +196,13 @@ function stoptorrent {
|
|||||||
killall transmission-cli
|
killall transmission-cli
|
||||||
}
|
}
|
||||||
|
|
||||||
configuretorrent /usr/local/etc/WolfPack/torrentengine
|
|
||||||
|
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
helptext;
|
helptext;
|
||||||
exit;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
logstatement "--- $(date) ---"
|
echo '---' $(date) '---' | tee -a $logfile
|
||||||
logstatement "Started $1 $2 on $(uname -n)"
|
echo Started "$1" "$2" on $(uname -n) | tee -a $logfile
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--alpha")
|
"--alpha")
|
||||||
@ -181,14 +211,14 @@ case "$1" in
|
|||||||
else
|
else
|
||||||
export basedir="$2";
|
export basedir="$2";
|
||||||
fi
|
fi
|
||||||
logstatement "Starting members from pup in $basedir"
|
echo "Starting members from pup in "$basedir | tee -a $logfile
|
||||||
for i in $(find "$basedir" -type f | grep '.pup'); do
|
for i in $(find "$basedir" -type f | grep '.pup'); do
|
||||||
/usr/local/bin/wolfpack --member "$i";
|
/usr/local/bin/wolfpack --member "$i";
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"--member")
|
"--member")
|
||||||
logstatement "Spawning a member for $2"
|
echo "Spawning a member for "$2 | tee -a $logfile
|
||||||
whatismyip | tee -a /var/log/wolfpack.log
|
whatismyip | tee -a /var/log/wolfpack.log
|
||||||
case "$(head -n 1 "$2")" in
|
case "$(head -n 1 "$2")" in
|
||||||
"shows")
|
"shows")
|
||||||
@ -218,6 +248,6 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
logstatement "Exited $1"
|
echo "Exited "$1 | tee -a $logfile
|
||||||
logstatement "--- $(date) ---"
|
echo '---' "$(date)" '---' | tee -a $logfile
|
||||||
logstatement " "
|
echo | tee -a $logfile
|
||||||
|
Loading…
Reference in New Issue
Block a user