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