tangled
alpha
login
or
join now
benharri.org
/
dotfiles
0
fork
atom
my shell and tool configurations
0
fork
atom
overview
issues
pulls
pipelines
print tourney stuff for copypaste
benharri.org
1 year ago
78a7e03b
1db21f0f
+23
-1
1 changed file
expand all
collapse all
unified
split
bin
bin
tcpp
+23
-1
bin/bin/tcpp
···
1
#!/bin/sh
0
0
2
3
# get players + names
4
playersjson=$(curl -s "https://app.matchplay.events/api/tournaments/$1?includePlayers=1" \
0
5
-H "Content-Type: application/json" \
6
-H "Accept: application/json")
7
···
10
11
# get standings for finals
12
standingsids=$(curl -s "https://app.matchplay.events/api/tournaments/$finalsId/standings" \
0
13
-H "Content-Type: application/json" \
14
-H "Accept: application/json" \
15
| jq -r '.[] | .playerId')
···
17
# look up ifpa tourneys in TC for the date from matchplay
18
d=$(printf %s "$playersjson" | jq -r ".data.startUtc")
19
shortdate=$(date --date "$d" +"%B %-d")
20
-
ifpa=$(curl -s 'https://api.ifpapinball.com/v1/calendar/search?api_key=GET_YOUR_OWN&address=Traverse%20City&m=3')
0
21
ifpatourney=$(printf %s "$ifpa" | jq -r ".calendar[] | select(.start_date == \"$(date --date "$d" +"%F")\").tournament_id")
22
23
# set author, excerpt, and categories based on day-of-week
···
44
# pull names from original tournament json by ids from standings
45
# gotta be a better way to do this
46
player1=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n1 | tail -n1)).name")
0
47
player2=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n2 | tail -n1)).name")
0
48
player3=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n3 | tail -n1)).name")
0
49
player4=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n4 | tail -n1)).name")
0
50
51
# create the post draft and save the id
52
postid=$(sudo -Hu www-data wp --path=/var/www/tcpinball.org \
···
72
73
# drop a link to the editor so i can attach the featured pic before publishing
74
printf "https://tcpinball.org/wp-admin/post.php?action=edit&post=%s\n" "$postid"
0
0
0
0
0
0
0
0
0
0
0
0
0
75
···
1
#!/bin/sh
2
+
matchplayApiKey=$(cat ~/Sync/Notes/keys/matchplayapikey.txt)
3
+
ifpaApiKey=$(cat ~/Sync/Notes/keys/ifpa-api-key.txt)
4
5
# get players + names
6
playersjson=$(curl -s "https://app.matchplay.events/api/tournaments/$1?includePlayers=1" \
7
+
-H "Authorization: Bearer $matchplayApiKey" \
8
-H "Content-Type: application/json" \
9
-H "Accept: application/json")
10
···
13
14
# get standings for finals
15
standingsids=$(curl -s "https://app.matchplay.events/api/tournaments/$finalsId/standings" \
16
+
-H "Authorization: Bearer $matchplayApiKey" \
17
-H "Content-Type: application/json" \
18
-H "Accept: application/json" \
19
| jq -r '.[] | .playerId')
···
21
# look up ifpa tourneys in TC for the date from matchplay
22
d=$(printf %s "$playersjson" | jq -r ".data.startUtc")
23
shortdate=$(date --date "$d" +"%B %-d")
24
+
25
+
ifpa=$(curl -s "https://api.ifpapinball.com/v1/calendar/search?api_key=$ifpaApiKey&address=Traverse%20City&m=3")
26
ifpatourney=$(printf %s "$ifpa" | jq -r ".calendar[] | select(.start_date == \"$(date --date "$d" +"%F")\").tournament_id")
27
28
# set author, excerpt, and categories based on day-of-week
···
49
# pull names from original tournament json by ids from standings
50
# gotta be a better way to do this
51
player1=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n1 | tail -n1)).name")
52
+
p1ifpa=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n1 | tail -n1)).ifpaId")
53
player2=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n2 | tail -n1)).name")
54
+
p2ifpa=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n2 | tail -n1)).ifpaId")
55
player3=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n3 | tail -n1)).name")
56
+
p3ifpa=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n3 | tail -n1)).ifpaId")
57
player4=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n4 | tail -n1)).name")
58
+
p4ifpa=$(printf %s "$playersjson" | jq -r ".data.players | .[] | select(.playerId == $(printf %s "$standingsids" | head -n4 | tail -n1)).ifpaId")
59
60
# create the post draft and save the id
61
postid=$(sudo -Hu www-data wp --path=/var/www/tcpinball.org \
···
81
82
# drop a link to the editor so i can attach the featured pic before publishing
83
printf "https://tcpinball.org/wp-admin/post.php?action=edit&post=%s\n" "$postid"
84
+
printf "https://www.ifpapinball.com/tournaments/manage/submit_results/?t=%s\n" "$ifpatourney"
85
+
86
+
printf "\nqualifying\n"
87
+
printf "https://app.matchplay.events/tournaments/%s/standings\n" "$1"
88
+
printf "\nfinals\n"
89
+
printf "https://app.matchplay.events/tournaments/%s/standings\n" "$finalsId"
90
+
91
+
printf "\n"
92
+
printf "1,%s,%s\n" "$player1" "$p1ifpa"
93
+
printf "2,%s,%s\n" "$player2" "$p2ifpa"
94
+
printf "3,%s,%s\n" "$player3" "$p3ifpa"
95
+
printf "4,%s,%s\n" "$player4" "$p4ifpa"
96
+
printf "\nplus https://app.matchplay.events/tournaments/%s/ifpa\n" "$1"
97