Just. Do. It.
Like many beginners, I have my fair share of imposter syndrome. At times stuck in tutorial purgatory; whose entire livelihood would crumble without google and stack overflow. At some point, you have to bite off more than you can chew. Sink or swim.
The 28 point league gave me the perfect opportunity to do this. It was a simple hobby gambling league honestly. $90 bucks a head to get in for the NFL regular season, with 18 weeks to win a decent cash pot. If nobody wins for a given week, it rolls over to the next week. It was almost like it was designed to be automated!
Based off these conditions, you can generate some psuedocode for the processes:
Get the data
Use the Python requests
and json
modules to get the data from ESPN's api endpoint, and put it in a data structure that's easy to parse.
Process the data
Once a week, determine how many teams won for the week (i.e. scored 28 points). Apply the following logic
if teams_won == 1:
winner found
reset pot
else:
rollover
add to pot
Determine status from data
Using the results gathered from processing, I generate an HTML email template that contains a weekly breakdown with NFL team logos.
Takeaways
The final piece of the automation puzzle is to have this all occur without me having to touch anything. Thankfully I had a spare RP4 that I wasn't actively using. I cloned the repo, set up a cronjob set to execute and plopped it next to the router. Between the first and last weeks of regular season play, I get an email with the latest updates about the league.
Sadly, there have been minor hiccups along the way. Unforeseen edge cases such as unhandled game status', failure to get data at times. My initial stab at just doing it wasn't entirely successful. However, it did give me a sense of accomplishment cobbling together something useful for once and not just from a tutorial. I did it.
...Tutorial coming soon ;)