From 05b4439b61f84ee4b44282918e623ea757aa8356 Mon Sep 17 00:00:00 2001 From: example Date: Wed, 16 Nov 2016 18:11:48 -0600 Subject: [PATCH] Adding date/time show tracking under new function, error tracking for critical functions --- 1337x.torrentengine.sample | 2 +- test-torrent-engine | 2 ++ torrentdownloads.torrentengine.sample | 6 ++++ torrentproject.torrentengine.sample | 2 +- tpb.torrentengine.sample | 2 +- wolfpack | 51 ++++++++++++++++++--------- 6 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 torrentdownloads.torrentengine.sample diff --git a/1337x.torrentengine.sample b/1337x.torrentengine.sample index 19461f7..f772250 100755 --- a/1337x.torrentengine.sample +++ b/1337x.torrentengine.sample @@ -1,6 +1,6 @@ torrentengine=https://1337x.to/search/%s/1/ torrentterms=printf https://1337x.to; grep "/torrent/" | head -n 1 | cut -f 10 -d \" magnetposition=4 -torrentdebugging=true +torrentdebugging=false searchunifier=+ magnetseparator=" diff --git a/test-torrent-engine b/test-torrent-engine index 025a2ca..e904d94 100755 --- a/test-torrent-engine +++ b/test-torrent-engine @@ -15,3 +15,5 @@ fi header Getting magnet link. getmagnetlink "$(echo $1 | tr '#' "$searchunifier")" +echo +echo Found: $magnetlink diff --git a/torrentdownloads.torrentengine.sample b/torrentdownloads.torrentengine.sample new file mode 100644 index 0000000..2f9ff8e --- /dev/null +++ b/torrentdownloads.torrentengine.sample @@ -0,0 +1,6 @@ +torrentengine=https://www.torrentdownloads.me/search/?search=%s +torrentterms=printf https://www.torrentdownloads.me/; grep "/torrent/" | head -n 1 | cut -f 78 -d \" +magnetposition=4 +torrentdebugging=false +searchunifier=+ +magnetseparator=" diff --git a/torrentproject.torrentengine.sample b/torrentproject.torrentengine.sample index c8aceda..0f5bfae 100644 --- a/torrentproject.torrentengine.sample +++ b/torrentproject.torrentengine.sample @@ -1,6 +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 +torrentdebugging=false searchunifier=+ magnetseparator=' diff --git a/tpb.torrentengine.sample b/tpb.torrentengine.sample index 030138a..676ff05 100644 --- a/tpb.torrentengine.sample +++ b/tpb.torrentengine.sample @@ -1,6 +1,6 @@ torrentengine=https://thepiratebay.org/search/%s/0/99/0/ torrentterms=printf https://thepiratebay.org; grep "/torrent/" | head -n 1 | cut -f 4 -d \" magnetposition=4 -torrentdebugging=true +torrentdebugging=false searchunifier=%20 magnetseparator=" diff --git a/wolfpack b/wolfpack index 98386f1..e0015a4 100755 --- a/wolfpack +++ b/wolfpack @@ -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 ~~ Send a member to train a pup + wolfpack --member [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 ;;