organize into folders

This commit is contained in:
filifa
2024-08-08 00:10:11 -05:00
parent 9ecc9a358b
commit 5197766815
11 changed files with 0 additions and 0 deletions

35
games/mlbfinalpost.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -e
while getopts 'd:a:' opt
do
case $opt in
d)
db=$OPTARG
;;
a)
account=$OPTARG
;;
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
# format each row of data retreived from the select statement and pipe to toot
fmt='printf "Final:\n\n%s %s\n%s %s\n\n#baseball #live\n", $1, $2, $3, $4'
post="\"toot post --using $account\""
sqlite3 $db < postfinal.sql | awk -F  "{$fmt | $post; close($post)}"

35
games/mlbgames.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -e
while getopts 'd:t:' opt
do
case $opt in
d)
db=$OPTARG
;;
t)
team=$OPTARG
;;
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
if [[ -z $team ]]
then
echo "$0:" '-t is required' >&2
exit 1
fi
jqFilter='.dates[].games[] | "\(.gamePk)\(.)"'
fmt="OFS=\"\"; print \$1, \$2, 0"
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin games'\""
mlblive schedule -t $team | jq -r "$jqFilter" | awk -F  "{$fmt | $save; close($save)}"

35
games/mlbstartpost.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -e
while getopts 'd:a:' opt
do
case $opt in
d)
db=$OPTARG
;;
a)
account=$OPTARG
;;
?)
exit 1
;;
esac
done
if [[ -z $db ]]
then
echo "$0:" '-d is required' >&2
exit 1
fi
if [[ -z $account ]]
then
echo "$0:" '-a is required' >&2
exit 1
fi
# format each row of data retreived from the select statement and pipe to toot
fmt='printf "Starting soon:\n\n%s (%s-%s) @\n%s (%s-%s)\n\n#baseball #live\n", $1, $2, $3, $4, $5, $6'
post="\"toot post --using $account\""
sqlite3 $db < poststart.sql | awk -F  "{$fmt | $post; close($post)}"

19
games/postfinal.sql Normal file
View File

@@ -0,0 +1,19 @@
.separator 
begin;
select
json ->> 'teams' ->> 'away' ->> 'team' ->> 'name',
json ->> 'teams' ->> 'away' ->> 'score',
json ->> 'teams' ->> 'home' ->> 'team' ->> 'name',
json ->> 'teams' ->> 'home' ->> 'score'
from games
where
json ->> 'status' ->> 'detailedState' = 'Final' and
posted = 0;
update games
set posted = 1
where
json ->> 'status' ->> 'detailedState' = 'Final' and
posted = 0;
commit;

21
games/poststart.sql Normal file
View File

@@ -0,0 +1,21 @@
.separator 
begin;
select
json ->> 'teams' ->> 'away' ->> 'team' ->> 'name',
json ->> 'teams' ->> 'away' ->> 'leagueRecord' ->> 'wins',
json ->> 'teams' ->> 'away' ->> 'leagueRecord' ->> 'losses',
json ->> 'teams' ->> 'home' ->> 'team' ->> 'name',
json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'wins',
json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'losses'
from games
where
json ->> 'status' ->> 'detailedState' = 'Warmup' and
posted = 0;
update games
set posted = 1
where
json ->> 'status' ->> 'detailedState' = 'Warmup' and
posted = 0;
commit;