Privacy fix and Makefile standardization; code reuse

This commit is contained in:
cxford
2016-09-28 14:12:16 -05:00
parent 10335ae2df
commit bef501886a
2 changed files with 25 additions and 17 deletions

View File

@@ -43,15 +43,28 @@ search ~~ Uses the Google search
'
}
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
exit 1
fi
}
function transmissioncheck {
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a $logfile
exit 0;
fi
}
function torrent {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument."
return;
fi
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then
echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 1>&2
exit 1
fi
transmissioncheck;
privacycheck;
export downloaddir=$(head -n 2 "$1" | tail -n 1)
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a $logfile
@@ -82,21 +95,15 @@ function shows {
echo "Need a valid argument."
return;
fi
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
echo "Transmission is still running. Aborting." | tee -a $logfile
return;
fi
if [ "$(whatismyip)" == "$(nslookup aninix.net | grep Address | cut -f 2 -d ' ')" ]; then
echo "Should not torrent directly from the AniNIX main IP for privacy reasons" 1>&2
exit 1
fi
transmissioncheck;
privacycheck;
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 '#' '+' | 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 \")
export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d $magnetseparator)
if [ $torrentdebugging == "true" ]; then
echo $searchstring
echo $searchlink
@@ -129,7 +136,7 @@ function shows {
export newseason=$(printf "%02d\n" $((${season#0} + 1)))
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 \")
export magnetlink=$(wget -q -O - "$searchresult" | grep 'magnet:?' | cut -f $magnetposition -d $magnetseparator)
if [ $torrentdebugging == "true" ]; then
echo $newseason
echo $newsearch