|
|
|
@@ -1,7 +1,10 @@
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
source /usr/local/src/SharedLibraries/Bash/header
|
|
|
|
|
configuretorrent /usr/local/etc/WolfPack/torrentengine
|
|
|
|
|
if [ -z "$3" ]; then
|
|
|
|
|
configuretorrent /usr/local/etc/WolfPack/torrentengine
|
|
|
|
|
else
|
|
|
|
|
configuretorrent "$3"
|
|
|
|
|
fi
|
|
|
|
|
export IFS="
|
|
|
|
|
"
|
|
|
|
|
export logfile='/var/log/wolfpack.log'
|
|
|
|
@@ -15,12 +18,11 @@ function helptext {
|
|
|
|
|
// /~_____/ with their prey.
|
|
|
|
|
/// \\/ / ~dev@aninix.net
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
wolfpack --alpha ~~ Tell the alpha to send the
|
|
|
|
|
wolfpack --alpha [enginefile] ~~ Tell the alpha to send the
|
|
|
|
|
pack members hunting.
|
|
|
|
|
wolfpack --member <pup> ~~ Send a member to train a pup
|
|
|
|
|
wolfpack --member <pup> [enginefile] ~~ Send a member to train a pup
|
|
|
|
|
and bring back results.
|
|
|
|
|
wolfpack --stop-torrent ~~ Stop any transmission-cli
|
|
|
|
|
processes
|
|
|
|
|
wolfpack --help ~~ Show this helptext
|
|
|
|
|
|
|
|
|
|
Available pup types (all pups are line-delimited with the type and
|
|
|
|
|
result location as the first two lines):
|
|
|
|
@@ -45,11 +47,20 @@ function helptext {
|
|
|
|
|
|
|
|
|
|
function privacycheck {
|
|
|
|
|
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ' | tail -n 1)" ]; then
|
|
|
|
|
echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 2>&1 | tee -a $logfile
|
|
|
|
|
echo "ERROR: Should not torrent directly from the AniNIX main IP for privacy reasons" 2>&1 | tee -a $logfile
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function nextairdate {
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
|
echo "Need a show to search for"
|
|
|
|
|
exit 1;
|
|
|
|
|
fi
|
|
|
|
|
wget -q -O - https://www.episodate.com/tv-show/"$(echo $1 | sed 's/[ \t]*$//' | sed 's/^[ \t]*//' | tr ' ' '-' | tr '[:upper:]' '[:lower:]')"?season=99 | tr '>' '\n' | grep episode_datetime_convert | head -n 1 | cut -f 4 -d \" | cut -f 1 -d 'T'
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function transmissioncheck {
|
|
|
|
|
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
|
|
|
|
echo "Transmission is still running. Aborting." | tee -a $logfile
|
|
|
|
@@ -90,12 +101,13 @@ function shows {
|
|
|
|
|
echo "Would download to "$downloaddir
|
|
|
|
|
for i in $(tail -n +3 "$1"); do
|
|
|
|
|
getmagnetlink "$(echo $i | tr '#' "$searchunifier")"
|
|
|
|
|
export sepisode=$(echo $i | cut -f 1 -d '#')
|
|
|
|
|
export searchterms="$(echo $i | cut -f 2 -d '#')"
|
|
|
|
|
export season=$(echo $sepisode | cut -f 1 -d 'E' | cut -f 2 -d 'S')
|
|
|
|
|
export episode=$(echo $sepisode | cut -f 2 -d 'E')
|
|
|
|
|
export newep=$(printf "%02d\n" $((${episode#0} + 1)))
|
|
|
|
|
export newseason="$(printf "%02d\n" $((${season#0} + 1)))"
|
|
|
|
|
sepisode=$(echo $i | cut -f 1 -d '#')
|
|
|
|
|
showName="$(echo $i | cut -f 2 -d '#')"
|
|
|
|
|
searchterms="$showName"' '"$(echo $i | cut -f 2 -d '#')"
|
|
|
|
|
season=$(echo $sepisode | cut -f 1 -d 'E' | cut -f 2 -d 'S')
|
|
|
|
|
episode=$(echo $sepisode | cut -f 2 -d 'E')
|
|
|
|
|
newep=$(printf "%02d\n" $((${episode#0} + 1)))
|
|
|
|
|
newseason="$(printf "%02d\n" $((${season#0} + 1)))"
|
|
|
|
|
if [ "$magnetlink" != "" ]; then
|
|
|
|
|
# We found an episode.
|
|
|
|
|
echo $i | tee -a $logfile
|
|
|
|
@@ -115,7 +127,15 @@ function shows {
|
|
|
|
|
/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"
|
|
|
|
|
else
|
|
|
|
|
echo "No new season found for $searchterms" | tee -a $logfile
|
|
|
|
|
nextAirDate="$(nextairdate "$showName")"
|
|
|
|
|
if [ ! -z "$nextAirDate" ]; then
|
|
|
|
|
echo "No new season found for $showName -- next airs $(nextairdate "$showName")" | tee -a $logfile
|
|
|
|
|
if [ "$(date -s "$nextAirDate" -u +%s)" -lt "$(date -u +%s)" ]; then
|
|
|
|
|
echo ERROR: Should have found a new episode for $searchterms and did not -- check your provider\! | tee -a $logfile
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "No new season found for $showName" | tee -a $logfile
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
@@ -164,7 +184,6 @@ function search {
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" == "" ]; then
|
|
|
|
|
helptext;
|
|
|
|
|
exit 1;
|
|
|
|
@@ -182,7 +201,7 @@ case "$1" in
|
|
|
|
|
fi
|
|
|
|
|
echo "Starting members from pup in "$basedir | tee -a $logfile
|
|
|
|
|
for i in $(find "$basedir" -type f | grep '.pup'); do
|
|
|
|
|
/usr/local/bin/wolfpack --member "$i";
|
|
|
|
|
/usr/local/bin/wolfpack --member "$i" "$3";
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|