diff --git a/content.sh b/content.sh index 5cd0d62..ee12b70 100755 --- a/content.sh +++ b/content.sh @@ -1,7 +1,19 @@ #!/bin/bash -gamePk=$(./livepk.sh) -if [[ "$gamePk" = 'null' ]] +while getopts 't:' opt +do + case $opt in + t) + team=$OPTARG + ;; + ?) + exit 1 + ;; + esac +done + +gamePk=$(./livepk.sh -t $team) +if [[ -z $gamePk || "$gamePk" = 'null' ]] then exit 1 fi diff --git a/livepk.sh b/livepk.sh index ee9fc0d..a69e07c 100755 --- a/livepk.sh +++ b/livepk.sh @@ -1,4 +1,22 @@ #!/bin/bash +while getopts 't:' opt +do + case $opt in + t) + team=$OPTARG + ;; + ?) + exit 1 + ;; + esac +done + +if [[ -z $team ]] +then + echo "$0:" '-t is required' >&2 + exit 1 +fi + # grab most recently started live pk, if multiple -echo $(mlblive schedule -t $TEAM | jq '.dates[].games | map(select(.status.abstractGameState == "Live"))[-1].gamePk') +echo $(mlblive schedule -t $team | jq '.dates[].games | map(select(.status.abstractGameState == "Live"))[-1].gamePk') diff --git a/subscribe.sh b/subscribe.sh index 5370cee..79a759c 100755 --- a/subscribe.sh +++ b/subscribe.sh @@ -1,7 +1,19 @@ #!/bin/bash -gamePk=$(./livepk.sh) -if [[ "$gamePk" = 'null' ]] +while getopts 't:' opt +do + case $opt in + t) + team=$OPTARG + ;; + ?) + exit 1 + ;; + esac +done + +gamePk=$(./livepk.sh -t $team) +if [[ -z $gamePk || "$gamePk" = 'null' ]] then exit 1 fi