Since I have a free moment, I figured I'd jump in here and briefly explain how my HLS proxy works, and how I use it. The NHL servers eventually present me with a URL to fetch the HLS file that actually contains the game footage. Instead of passing that URL straight to Kodi and having it play it, I first prepend my proxy info to the URL, and pass THAT to Kodi to play.
Code:
# About the variables used below:
#
# m3u8_url: The URL that the NHL servers gave me.
# self.hls_server: The host/port for the proxy in the form "http://127.0.0.1:54321".
# game['start_time']: The time that the game started.
# protocol_headers: The headers to ensure get passed to the host we're proxying to.
m3u8_url = self.hls_server + \
'/playlist?url=' + urllib.quote_plus(m3u8_url) + \
'&start_at=' + game['start_time'].strftime('%Y%m%d%H%M%S')
if len(protocol_headers) > 0:
m3u8_url += '&headers=' + urllib.quote(urllib.urlencode(protocol_headers))
So, this hits "/playlist" on the HLS proxy, with the parameters "url" (the URL to proxy to), "start_at" (the start of the game), and optionally "headers" (the headers that need to be passed to the proxied host).
When Kodi attempts to play that URL, the proxy makes a request to "url" to fetch the actual playlist. It then parses the playlist and rewrites relative URLs (/path/to/something) to absolute URLs referencing the proxy (
http://127.0.0.1:54321/path/to/something). It also rewinds the playlist to the desired time (based on the "start_at" parameter), but that's a bit more in-depth than I have time for at the moment.
So really, in order to adapt the proxy for MLB, you'd probably have to make some minor adjustments to the rewind_playlist() function of the proxy, and add something relatively similar to the code that I posted above to make sure that Kodi hits the proxy.
Anyways, my free moment has pretty much passed. If anyone has any questions, I'll do my best to answer them.