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/
|
||||
torrentterms=printf https://1337x.to; grep "/torrent/" | head -n 1 | cut -f 2 -d \"
|
||||
magnetposition=4
|
||||
torrentdebugging=true
|
||||
searchunifier=+
|
||||
torrentengine="https://1337x.to/search/%s/1/"
|
||||
torrentterms='printf https://1337x.to; grep "/torrent/" | head -n 1 | cut -f 2 -d \"'
|
||||
magnetposition='4'
|
||||
torrentdebugging='false'
|
||||
searchunifier='+'
|
||||
magnetseparator=\"
|
||||
|
6
Makefile
6
Makefile
@ -23,9 +23,11 @@ reverse:
|
||||
cp /usr/local/bin/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
|
||||
cp offload-wolfpack /root/bin
|
||||
chmod 0700 /root/bin/offload-wolfpack
|
||||
chown root:root /root/bin/offload-wolfpack
|
||||
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$(pgrep -afc wolfpack)" -ne 1 ]; then
|
||||
echo WolfPack is already working elsewhere.
|
||||
exit 1
|
||||
fi
|
||||
/usr/local/bin/wolfpack --alpha
|
||||
sleep 10
|
||||
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
|
||||
|
||||
source /usr/local/src/SharedLibraries/Bash/header
|
||||
|
||||
# Logging
|
||||
source /usr/local/etc/WolfPack/torrentengine
|
||||
export IFS="
|
||||
"
|
||||
export logfile='/var/log/wolfpack.log'
|
||||
|
||||
|
||||
function helptext {
|
||||
echo '
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -53,15 +54,25 @@ function torrent {
|
||||
fi
|
||||
export downloaddir=$(head -n 2 "$1" | tail -n 1)
|
||||
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
||||
logstatement "Transmission is still running. Aborting."
|
||||
echo "Transmission is still running. Aborting." | tee -a $logfile
|
||||
return;
|
||||
fi
|
||||
for i in $(tail -n +3 "$1"); do
|
||||
getmagnetlink "$i"
|
||||
torrentlink
|
||||
if [ ! -z "$magnetlink" ]; then
|
||||
export searchstring="$(echo $i | sed 's/ /+/g')"
|
||||
export searchlink="$(printf "$torrentengine" "$searchstring")"
|
||||
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"
|
||||
logstatement "Downloaded and removed $i"
|
||||
echo Downloaded and removed $i | tee -a $logfile
|
||||
fi
|
||||
done
|
||||
}
|
||||
@ -72,7 +83,7 @@ function shows {
|
||||
return;
|
||||
fi
|
||||
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
|
||||
logstatement "Transmission is still running. Aborting."
|
||||
echo "Transmission is still running. Aborting." | tee -a $logfile
|
||||
return;
|
||||
fi
|
||||
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)
|
||||
echo "Would download to "$downloaddir
|
||||
for i in $(tail -n +3 "$1"); do
|
||||
export searchsegment="$(echo $i | tr '#' "$searchunifier")"
|
||||
getmagnetlink "$searchsegment"
|
||||
if [ ! -z "$magnetlink" ]; then
|
||||
export searchsegment="$(echo $i | tr '#' '+' | tr ' ' '+')"
|
||||
export searchlink="$(printf "$torrentengine" "$searchsegment")"
|
||||
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.
|
||||
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 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 ep=$(printf "%02d\n" $((${episode#0} + 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"/*/*.nfo
|
||||
echo | tee -a $logfile
|
||||
else
|
||||
# We didn't -- is there a new season?
|
||||
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 episode=$(echo $sepisode | cut -f 2 -d 'E')
|
||||
export newseason=$(printf "%02d\n" $((${season#0} + 1)))
|
||||
export newsearch="$(echo $searchsegment | sed 's/S'$season'E'$episode'/S'$newseason'E01/')"
|
||||
getmagnetlink "$newsearch"
|
||||
if [ "$magnetlinki" != "" ]; then
|
||||
torrentlink
|
||||
logstatement "$newsearch Downloaded and pup updated."
|
||||
export newsearch="$(echo $searchlink | sed 's/S'$season'E'$episode'/S'$newseason'E01/')"
|
||||
export searchresult=$(wget -q -O - "$newsearch" | bash -c "$torrentterms")
|
||||
export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d \")
|
||||
if [ $torrentdebugging == "true" ]; then
|
||||
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"
|
||||
else
|
||||
logstatement "No new season found after $searchterms"
|
||||
echo "No new season found for" $searchterms | tee -a $logfile
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@ -134,14 +166,14 @@ function download {
|
||||
export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)"
|
||||
#if file doesn't already exist....
|
||||
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)"
|
||||
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;
|
||||
done
|
||||
wget -q -O "$filename" "$nexturl"
|
||||
logstatement "Downloaded"
|
||||
echo Downloaded | tee -a $logfile
|
||||
fi
|
||||
}
|
||||
|
||||
@ -155,7 +187,7 @@ function search {
|
||||
export searchstring=$(echo $i | sed 's/ /+/g')
|
||||
export file="$downloaddir"/$searchstring'.txt'
|
||||
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
|
||||
}
|
||||
|
||||
@ -164,15 +196,13 @@ function stoptorrent {
|
||||
killall transmission-cli
|
||||
}
|
||||
|
||||
configuretorrent /usr/local/etc/WolfPack/torrentengine
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
helptext;
|
||||
exit;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
logstatement "--- $(date) ---"
|
||||
logstatement "Started $1 $2 on $(uname -n)"
|
||||
echo '---' $(date) '---' | tee -a $logfile
|
||||
echo Started "$1" "$2" on $(uname -n) | tee -a $logfile
|
||||
|
||||
case "$1" in
|
||||
"--alpha")
|
||||
@ -181,14 +211,14 @@ case "$1" in
|
||||
else
|
||||
export basedir="$2";
|
||||
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
|
||||
/usr/local/bin/wolfpack --member "$i";
|
||||
done
|
||||
;;
|
||||
|
||||
"--member")
|
||||
logstatement "Spawning a member for $2"
|
||||
echo "Spawning a member for "$2 | tee -a $logfile
|
||||
whatismyip | tee -a /var/log/wolfpack.log
|
||||
case "$(head -n 1 "$2")" in
|
||||
"shows")
|
||||
@ -218,6 +248,6 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
logstatement "Exited $1"
|
||||
logstatement "--- $(date) ---"
|
||||
logstatement " "
|
||||
echo "Exited "$1 | tee -a $logfile
|
||||
echo '---' "$(date)" '---' | tee -a $logfile
|
||||
echo | tee -a $logfile
|
||||
|
Loading…
Reference in New Issue
Block a user