WolfPack/wolfpack

224 lines
7.9 KiB
Plaintext
Raw Normal View History

Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
#!/bin/bash
2016-08-30 13:17:18 -05:00
source /usr/local/src/SharedLibraries/Bash/header
# Logging
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
export logfile='/var/log/wolfpack.log'
function helptext {
echo '
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/\____ xxxxxxxxxxxxx AniNIX::WolfPack
// ~ / _\_____ Let loose the wolves to hunt, run,
/ \ .. \/ and be free. They shall repay you
// /~_____/ with their prey.
/// \\/ / ~dev@aninix.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wolfpack --alpha ~~ Tell the alpha to send the
pack members hunting.
wolfpack --member <pup> ~~ Send a member to train a pup
and bring back results.
wolfpack --stop-torrent ~~ Stop any transmission-cli
processes
Available pup types (all pups are line-delimited with the type and
result location as the first two lines):
torrent ~~ Torrent the result of the
search term.
Will remove search line on
success.
shows ~~ Download the episode in a
show and increment. Shows
are listed in format
S01E01#Show terms
download ~~ Takes a list of commands to
run to arrive at a URL to
grab and downloads the last
URL.
search ~~ Uses the Google search
engine to return the top
five results for the search
terms on each line.
'
}
function torrent {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument."
return;
fi
2016-08-30 13:17:18 -05:00
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
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
export downloaddir=$(head -n 2 "$1" | tail -n 1)
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
2016-08-30 13:17:18 -05:00
logstatement "Transmission is still running. Aborting."
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
return;
fi
for i in $(tail -n +3 "$1"); do
2016-08-30 13:17:18 -05:00
getmagnetlink "$i"
torrentlink
if [ ! -z "$magnetlink" ]; then
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
sed -i "/$i/d" "$1"
2016-08-30 13:17:18 -05:00
logstatement "Downloaded and removed $i"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
fi
done
}
function shows {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument."
return;
fi
if [ "$(pgrep -afc transmission-cli)" -ne 0 ]; then
2016-08-30 13:17:18 -05:00
logstatement "Transmission is still running. Aborting."
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
return;
fi
2016-08-30 13:17:18 -05:00
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
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
export downloaddir=$(head -n 2 "$1" | tail -n 1)
echo "Would download to "$downloaddir
for i in $(tail -n +3 "$1"); do
2016-08-30 13:17:18 -05:00
export searchsegment="$(echo $i | tr '#' "$searchunifier")"
getmagnetlink "$searchsegment"
if [ ! -z "$magnetlink" ]; then
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
# We found an episode.
2016-08-30 13:17:18 -05:00
torrentlink
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
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"
2016-08-30 13:17:18 -05:00
logstatement "$i was downloaded and pup updated."
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
rm -f "$downloaddir"/*/*.txt # Including this to avoid breaking Plex
rm -f "$downloaddir"/*/*.nfo
else
# We didn't -- is there a new season?
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 newseason=$(printf "%02d\n" $((${season#0} + 1)))
2016-08-30 13:17:18 -05:00
export newsearch="$(echo $searchsegment | sed 's/S'$season'E'$episode'/S'$newseason'E01/')"
getmagnetlink "$newsearch"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
if [ "$magnetlinki" != "" ]; then
2016-08-30 13:17:18 -05:00
torrentlink
logstatement "$newsearch Downloaded and pup updated."
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
sed -i "s/$i/S"$newseason"E01#"$searchterms"/" "$1"
else
2016-08-30 13:17:18 -05:00
logstatement "No new season found after $searchterms"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
fi
fi
done
}
function download {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument."
return;
fi
# Second line in the file is the directory to download to.
export downloaddir=$(head -n 2 "$1" | tail -n 1)
# The third line and any following lines should be
for i in $(tail -n +3 "$1"); do
#echo EVALUATING: $i
if [ "$i" == "" ]; then continue; fi
export comm=$(echo $i | sed "s#PREVRESULT#$nexturl#g" -)
export nexturl=$(bash -c "$comm")
#echo Found next url: $nexturl
done
export filename="$downloaddir"/"$(echo "$nexturl" | rev | cut -f 1 -d \/ | rev)"
#if file doesn't already exist....
if [ ! -f "$filename" ]; then
2016-08-30 13:17:18 -05:00
logstatement "Downloading $nexturl to $filename ..."
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
export dedupterm="$(echo $1 | cut -f 1 -d '.' | rev | cut -f 1 -d '/' | rev)"
for i in $(find "$downloaddir" | grep -i "$dedupterm"); do
2016-08-30 13:17:18 -05:00
logstatement "Deduped! Removed $i from $downloaddir"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
rm -Rf $i;
done
wget -q -O "$filename" "$nexturl"
2016-08-30 13:17:18 -05:00
logstatement "Downloaded"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
fi
}
function search {
if [ "$1" == "" ] || [ $(wc -l "$1" | cut -f 1 -d ' ') -lt 3 ]; then
echo "Need a valid argument."
return;
fi
export downloaddir=$(head -n 2 "$1" | tail -n 1)
for i in $(tail -n +3 "$1"); do
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"
2016-08-30 13:17:18 -05:00
logstatement "Ran search for $searchstring to $file"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
done
}
function stoptorrent {
# TODO This is destructive to all other transmission-CLI clients on the box.
killall transmission-cli
}
2016-08-30 13:17:18 -05:00
configuretorrent /usr/local/etc/WolfPack/torrentengine
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
if [ "$1" == "" ]; then
helptext;
exit;
fi
2016-08-30 13:17:18 -05:00
logstatement "--- $(date) ---"
logstatement "Started $1 $2 on $(uname -n)"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
case "$1" in
"--alpha")
if [ "$2" == "" ]; then
export basedir="/usr/local/etc/WolfPack"
else
export basedir="$2";
fi
2016-08-30 13:17:18 -05:00
logstatement "Starting members from pup in $basedir"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
for i in $(find "$basedir" -type f | grep '.pup'); do
/usr/local/bin/wolfpack --member "$i";
done
;;
"--member")
2016-08-30 13:17:18 -05:00
logstatement "Spawning a member for $2"
Converting from Bazaar. Old log: ------------------------------------------------------------ revno: 8 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:52:29 -0500 message: Clearing some read statements ------------------------------------------------------------ revno: 7 committer: root <root@aninix.net> branch nick: WolfPack timestamp: Tue 2016-07-19 13:36:23 -0500 message: Fix for torrent protocol ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Mon 2016-07-18 10:23:17 -0500 message: Massive fixes; offloading updates; torrent function pup type updated ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Tue 2016-05-31 14:42:28 -0500 message: Removing ghost-wolfpack in favor of systemd vpn client. ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Sun 2016-05-15 21:35:02 -0500 message: Updated to include privacy VPN and offloading options. ------------------------------------------------------------ revno: 3 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 20:51:23 -0500 message: Adding ghost-wolfpack script for sites using VPNs for privacy ------------------------------------------------------------ revno: 2 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 15:58:05 -0500 message: Updated to use the googler package from the ArchLinux AUR for google searches and store as text files. Sufficient for now. ------------------------------------------------------------ revno: 1 committer: dev <dev@aninix.net> branch nick: WolfPack timestamp: Thu 2016-05-12 14:45:12 -0500 message: Adding all but search example -- search API is still in flux with no good command-line search option.
2016-08-04 12:08:16 -05:00
whatismyip | tee -a /var/log/wolfpack.log
case "$(head -n 1 "$2")" in
"shows")
shows "$2"
;;
"torrent")
torrent "$2"
;;
"search")
search "$2"
;;
"download")
download "$2"
;;
*)
echo "Bad pup type."
;;
esac
;;
"--stoptorrent")
stoptorrent
;;
*)
helptext
;;
esac
2016-08-30 13:17:18 -05:00
logstatement "Exited $1"
logstatement "--- $(date) ---"
logstatement " "