Last active
May 26, 2019 23:16
-
-
Save jfeilbach/ccc493fff119c417f385a4989a838518 to your computer and use it in GitHub Desktop.
Check for download availability on Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # MacOS torrent availbility notification and start download | |
| # use gnu sed (/usr/local/bin/gsed) provided by brew instead of macos sed | |
| NAME='Monaco' | |
| EXCLUDE='Qualifying|Show|Notebook|SD' | |
| URL='https://www.ettv.to/user/smcgill1969' | |
| DOM='https://www.ettv.to' | |
| HOST='localhost' | |
| PORT='9091' | |
| PEERS='1024' | |
| OPTS='--stop --start-paused --peers ${PEERS}' | |
| #OPTS='--start --no-start-paused --peers ${PEERS}' | |
| if ! [ -x "$(command -v gsed)" ]; then | |
| echo 'Error: gnu sed is not installed. Exiting.' >&2 | |
| exit 1 | |
| fi | |
| clear | |
| while [[ true ]]; do | |
| curl -fs ${URL} | grep Formula.1 | grep ${NAME} | egrep -v "${EXCLUDE}" | |
| if [[ $? -eq 0 ]]; then | |
| `say -v Daniel "Jason please start downloading the "${NAME}" Formula one race now. Thank you."` | |
| echo "Download the $NAME race now." | |
| DL=$(curl -fs ${URL} | grep Formula.1 | grep ${NAME} | egrep -v "${EXCLUDE}" | awk 'BEGIN{ | |
| RS="</a>" | |
| IGNORECASE=1 | |
| } | |
| { | |
| for(o=1;o<=NF;o++){ | |
| if ( $o ~ /href/){ | |
| gsub(/.*href=\042/,"",$o) | |
| gsub(/\042.*/,"",$o) | |
| print $(o) | |
| } | |
| } | |
| }') | |
| echo -e "Checking ${DOM}${DL} ...\n" | |
| MAG=$(curl -fs ${DOM}${DL} | gsed -rn '/magnet/{s/.*(magnet:[^"]*).*/\1/g;p}') | |
| echo Magnet link is \"${MAG}\" | |
| # size=${#MAG} | |
| # echo $size | |
| if [[ -n "${MAG}" ]]; then | |
| echo "Got magnet link" | |
| /usr/local/bin/transmission-remote ${HOST}:${PORT} --add ${MAG} ${OPTS} | |
| exit 0 | |
| else | |
| echo magnet link not found. | |
| exit 2 | |
| fi | |
| else | |
| echo -ne "\r Last checked: $(/bin/date)" | |
| for i in {30..01} | |
| do | |
| tput cup 1 $l | |
| echo -n " $i seconds until next check..." | |
| sleep 1 | |
| done | |
| echo "checking now..." | |
| clear | |
| fi | |
| # sleep 60 | |
| done | |
| # to do | |
| # get download URL from page ... DONE | |
| # get magnet link from download page ... DONE | |
| # check for null var string ... test still returning null | |
| # add magnet to transmission start downloading ... DONE | |
| # set per torrent settings on torrent in transmission ... DONE | |
| # notify via audio ... DONE | |
| # notify via email ... | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment