Getting Daily Alerts for MLB Condensed Games

30 years ago I spent a couple of summers working in New Jersey, and got drawn into the crazy world of New York Mets baseball.

Back then, keeping in touch when back home meant scouring the International Herald Tribune for any baseball news, but for the last decade I’ve been a subscriber to MLB TV which has been fantastic.

When considering renewing this year’s subscription, I realised I hardly watch any live games any more. Most games are played in the evening US Eastern Time or later, so what I generally do is wait until the next morning and try to watch the condensed game – around 5 minutes of “Match Of The Day” style highlights – without knowing the score.

Accessing MLB Condensed Games for free

MLB are a lot less precious with their highlights packages than the Premier League (surprise, surprise!), and make a lot of content available for free on both YouTube and within the MLB TV app for free.

However within the MLB TV app you can’t get notifications for when new condensed games are available without a paid subscription (which is fair enough!), and it’s really hard to check when a the video is ready without finding out the score, or some information about the game via the other videos already published.

However, the excellent Baseball Theater had figured out that the configuration for the mobile apps is held in the open, so that gave me the idea of hacking together a similar solution to send alerts as soon as there is a new condensed game is ready for viewing.

My MLB Condensed Games alert system

It’s all a bit Heath-Robinson, but my system works as below. Note the code is all avaialble on GitHub, and the below is copied from the readme.md of the repo:

There are 2 main entry points – designed to be run from AWS Lambda:

  1. lambdaCondensedGame,js – Checks whether a condensed game stream is available for a given team on a given day
  2. lambdaMonitor.js – Will see if a condensed game has been added, and if so sends a Slack message saying a new game is ready, plus a link to the stream

Condensed Game function

This function reads from the POSTed JSON formatted like:


	gameDate: "2019-04-26",
	team: "nym"

You must also send a HTTP header of MLBAPIRequest with a value set as an environment variable of the same name.

This will then:

  1. Build URL like http://gd2.mlb.com/components/game/mlb/year_2018/month_06/day_26/master_scoreboard.xml (using the incoming date)
  2. Look for <game> node where home_file_code=”nym” or away_file_code=”nym” (using the incoming team)
  3. Pick up game_pk attribute to get the URL e.g. “https://statsapi.mlb.com/api/v1/game/530594/content?language=en”
  4. Find in the media.epgAlternate nodes the “Extended Highlights” section, and then find the item that is the condensed game video (if it exists)
  5. Pick the correct URL node – the video that has a value that ends in .mp4

Assuming that a condensed game is found, the function then returns JSON like:


	"opponent": "pit",
	"date": "2019-04-26",
	"url": "http://mediadownloads.mlb.com/mlbam/mp4/2018/06/27/2202032583/1530076464641/asset_1200K.mp4",
	"mediaType": "Extended Highlights" 

Note:

  • The opponent attribute can null if no game has been found
  • The url attribute can null if no condensed game stream has been found for the game
  • The mediaType attribute can null or “Extended Highlights” (I experimented with also getting the “Recap” for a while)

Configuration – Environment variables

  • MLBAPIRequest: The value to be sent in the header of any request

Monitoring function

This function saves the last found game data in an S3 bucket, and then is designed to run on a schedule to do the following:

  • Looks at date in saved game data JSON from the last successful run
  • If date is today, we’re done (we don’t cope with double-headers yet!)
  • Otherwise, call the condensed game function for either yesterday or today (if the last game was yesterday), and if the result has a url attribute
    • Save the latest game data JSON to S3
    • Call Slack sending the url attribute in a mesage
    • Call an IFTTT web hook that sends an iOS notification, clicking on which opens the viedo URL

You can setup a schedule in Cloudwatch to run every N minutes.

Configuration – Environment variables

  • S3ACCESSKEYID: Access Key for the S3 bucket to save game data
  • S3DATABUCKET: Name of the S3 bucket to save game data
  • S3DATAFILE: Name of the file to save game data in
  • S3SECRETACCESSKEY: Access Secret for the S3 bucket to save game data
  • SLACK_WEBHOOK_URL: URL of the webhook to send the Slack message to
  • TEAM: Team abbreviation to monitor e.g. nym
  • IFTTT_EVENT_NAME: Name of the IFTTT event to send the notification call to
  • IFTTT_MAKER_KEY: Name of the IFTTT maker key to enable IFTTT calls

Summary

Everything is working really well so far, and I’m getting exactly what I need. Very happy! I may still subscribe to MLB TV later in the season if I’m missing the weekend live games – or indeed if the Mets get in a playoff race – but for now I can keep wtaching the highlights without it.

The MLB “API” was a bit in flux for the first few weeks of the season. It’s not a public API so that’s to be expected, but hopefully it will be stable for a while now.

I also built an iOS Shortcut to call the API directly, so if for some reason the video URL changed, or I missed/deleted the notification by accident.

If you want to set something similar up for yourself and if the GitHub instructions aren’t clear, let me know and I’ll try to help you out!

find the cost of your paper

Sep 13, Grand Remembrances

Today is Grandparents Day in the United States. Being a Grand is a special honor. I feel very blessed that my wife and I have two grandchildren. We were able to visit them today. Yes, we are still being cautious with the coronavirus, but we also find it very difficult to not see them when they live so close. So today we did drop by to visit Jacob (age 10) and Sophia (age 7) along with their parents. We brought donuts and caught up with them. Our grandchildren are still pretty young and this is a precious time in their lives – and ours!

I wish I had known my grandparents better. We never lived in the same place. Dad was a career Air Force pilot, so we moved around a lot. But we did get to see them once in a while when they would visit us, or we them.

A Plague of Giants

There are five known magical ‘kennings’ or types: air, water, fire, earth, and plants. Each nation specializes in of these kennings, and the magic influences the society. There’s a big pitfall with this diversity of ability and locale–not everyone gets along.

Enter the Hathrim giants, or ‘lavaborn’ whose kenning is fire. Where they live the trees that fuel their fire are long gone, but the giants are definitely not welcome anywhere else. They’re big, they’re violent, and they’re ruthless. When a volcano erupts and they are forced to evacuate, they take the opportunity to relocate. They don’t care that it’s in a place where they aren’t wanted.

I first read Kevin Hearne’s Iron Druid books and loved them (also the quirky The Tales of Pell), so was curious about this new venture, starting with A PLAGUE OF GIANTS. Think Avatar: The Last Airbender meets Jim Butcher’s Codex Alera series. Elemental magic, a variety of races, different lands. And it’s all thrown at you from page one.

But this story is told a little differently. It starts at the end of the war, after a difficult victory, and a bard with earth kenning uses his magic to re-tell the story of the war to a city of refugees. And it’s this movement back and forth in time and between key players in this war that we get a singularly grand view of the war as a whole. Hearne uses this method to great effect.

There are so many interesting characters in this book that I can’t cover them all here. Often in books like this such a large cast of ‘main’ character can make the storytelling suffer, especially since they don’t have a lot of interaction with each other for the first 3/4 of the book–but it doesn’t suffer, thankfully. And the characterization is good enough, despite these short bursts, that by the end we understand these people and care about what happens to them.

If there were a main character it would be Dervan, a historian who is assigned to record (also spy on?) the bard’s stories. He finds himself caught up in machinations he feels unfit to survive. Fintan is the bard from another country, who at first is rather mysterious and his true personality is hidden by the stories he tells; it takes a while to understand him. Gorin Mogen is the leader of the Hathrim giants who decide to find a new land to settle. He’s hard to like, but as far as villains go, you understand his motivations and he can be even a little convincing. There’s Abhi, the son of hunters, who decides hunting isn’t the life for him–and unexpectedly finds himself on a quest for the sixth kenning. And Gondel Vedd, a scholar of linguistics who finds himself tasked with finding a way to communicate with a race of giants never seen before (definitely not Hathrim) and stumbles onto a mystery no one could have guessed: there may be a seventh kenning.

There are other characters, but what makes them all interesting is that they’re regular people (well, maybe not Gorin Mogen or the viceroy–he’s a piece of work) who become heroes in their own little ways, whether it’s the teenage girl who isn’t afraid to share vital information, to the scholars who suddenly find how crucial their minds are to the survival of a nation, to the humble public servants who find bravery when they need it most. This is a story of loss, love, redemption, courage, unity, and overcoming despair to not give up. All very human experiences by simple people who do extraordinary things.

Hearne’s worldbuilding is engaging. He doesn’t bottle feed you, at first it feels like drinking from a hydrant, but then you settle in and pick up things along the way. Then he shows you stuff with a punch to the gut. This is no fluffy world with simple magic without price. All the magic has a price, and more often than not it leads you straight to death’s door. For most people just the seeking of the magic will kill you. I particularly enjoyed the scenes with Ahbi and his discovery of the sixth kenning and everything associated with it. But giants? I mean, really? It isn’t bad enough fighting people who can control fire that you have to add that they’re twice the size of normal people? For Hearne if it’s war, the stakes are pretty high, and it gets ugly.

The benefit of the storytelling style is that the book, despite its length, moves along steadily (Hearne is no novice, here). The bits of story lead you along without annoying cliffhangers (mostly), and I never got bored with the switch between characters. It was easy to move between them, and they were recognizable enough that I got lost or confused. The end of the novel felt a little abrupt, but I guess that has more to do with I was ready for the story to continue, despite the exiting climax.

If you’re looking for epic fantasy with fun storytelling and clever worldbuilding, check out A PLAGUE OF GIANTS.

The post A Plague of Giants appeared first on Elitist Book Reviews.

The Artwork Of Gary Choo

Gary Choo is a concept artist/illustrator based in Singapore. I’ve know Gary for a good many years ( 17, actually ), working together in animation studios in Singapore like Silicon Illusions and Lucasfilm. Gary currently runs an art team at Mighty Bear Games, but when time allows he also draws covers for Marvel comics, and they’re amazing –

The Art Of Gary Choo
The Art Of Gary Choo
The Art Of Gary Choo
The Art Of Gary Choo
The Art Of Gary Choo

To see more of Gary’s work or to engage him for freelance work, head down to his ArtStation.

The post The Art Of Gary Choo appeared first on Halcyon Realms – Art Book Reviews – Anime, Manga, Film, Photography.

27