github.com/danackerson/baseballgames

Simple Go webserver that crawls MLB.com to get last weeks', free, condensed games.


Install
go get github.com/danackerson/baseballgames

Documentation

With the help of https://github.com/brianmpalma/gameday-api-docs

use the MLB http://gd2.mlb.com open API server and query by date thusly:

http://gd2.mlb.com/components/game/mlb/year_2016/month_03/day_30/grid_ce.json

{ "subject": "grid_mlb_mlb_2016_03_30", "copyright" : "Copyright 2016 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt",

"data" : {"games": {

"game":[{ "game_type":"S", "game_media":{ "newsroom":{}, "homebase":{"media":[ {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED_60","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED_ADS","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED_ADS_60","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED_IRDETO","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED_IRDETO_60","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"HTTP_CLOUD_WIRED_WEB","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"FMS_CLOUD","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"567709283","blackout":"","combined_media_state":"MEDIA_ARCHIVE","free":"NO","playback_scenario":"FLASH_500K_400X224","state":"MEDIA_ARCHIVE","display":"SNY-HD","enhanced":"N","type":"mlbtv_home"}, {"id":"568804783","playback_scenario":"FLASH_450K_400X224","state":"MEDIA_ARCHIVE","type":"condensed_game"}, {"id":"568804783","playback_scenario":"FLASH_1200K_640X360","state":"MEDIA_ARCHIVE","type":"condensed_game"}, {"id":"568804783","playback_scenario":"FLASH_1800K_960X540","state":"MEDIA_ARCHIVE","type":"condensed_game"}, {"id":"568804783","playback_scenario":"FLASH_2500K_1280X720","state":"MEDIA_ARCHIVE","type":"condensed_game"}] } }, "game_nbr":"1","double_header_sw":"N", "away_team_name":"Nationals", "id":"2016/03/30/wasmlb-nynmlb-1", "home_name_abbrev":"NYM", "away_name_abbrev":"WSH", "home_team_id":"121", "away_team_id":"120", "media_state":"media_archive","top_inning":"N", "home_team_name":"Mets","ind":"F","venue_id":"2856","gameday_sw":"Y","home_score":"1","status":"Final","home_code":"nyn","away_score":"12","inning":"9", "game_pk":"469959", ,"venue":"Tradition Field", "home_file_code":"nym","away_file_code":"was","event_time":"12:10 PM",

"calendar_event_id":"14-469959-2016-03-30","group":"MLB","tbd_flag":"N", "away_code":"was" },

Game is located under: http://m.mlb.com/video/v568804783/33016-condensed-game-wshnym

Example 2: {"id":"568831983","playback_scenario":"FLASH_2500K_1280X720","state":"MEDIA_ARCHIVE","type":"condensed_game"},{"id":"567736583","blackout":"","combined_media_state":"MEDIA_ARCHIVE","playback_scenario":"HTTP_CLOUD_AUDIO","state":"MEDIA_OFF","display":"MLB.com","type":"away_audio"},{"id":"567736583","blackout":"","combined_media_state":"MEDIA_ARCHIVE","playback_scenario":"AUDIO_FMS_32K","state":"MEDIA_ARCHIVE","display":"MLB.com","type":"away_audio"},{"id":"567736583","blackout":"","combined_media_state":"MEDIA_ARCHIVE","playback_scenario":"HTTP_CLOUD_AUDIO_TS","state":"MEDIA_ARCHIVE","display":"MLB.com","type":"away_audio"}]}},"game_nbr":"1","double_header_sw":"N","away_team_name":"Blue Jays","id":"2016/03/30/tormlb-minmlb-1","home_name_abbrev":"MIN","media_state":"media_archive","top_inning":"Y","home_team_name":"Twins","ind":"F","venue_id":"2862","gameday_sw":"Y","away_team_id":"141","home_score":"4","status":"Final","home_code":"min","away_score":"3","inning":"9","game_pk":"470388","away_name_abbrev":"TOR","venue":"CenturyLink Sports Complex","home_file_code":"min","away_file_code":"tor","event_time":"1:05 PM","home_team_id":"142","calendar_event_id":"14-470388-2016-03-30","group":"MLB","tbd_flag":"N","away_code":"tor"},{"game_type":"S","game_media":{"newsroom":{},"homebase":{"media":

Game is located under: http://m.mlb.com/video/v568831983/33016-condensed-game-tormin where v568831983 is because this is the "condensed_game" ID and 33016 is March 30, 2016 gameday and 'tor' is toLowerCase("away_name_abbrev") and 'min' is toLowerCase("home_name_abbrev")

In the file mlb-logos.png we have all 30 team logo. Each logo is 195x162 pixels surrounded by a 5px gray border The XxY value before the team ID is the bottom, right-hand corner of the logo

  • use as a sprite image for displaying the team logos by the game listing!

ID Abb Name
108 LAA LA Angels 109 ARI Arizona Diamondbacks 110 BAL Baltimore Orioles 111 BOS Boston Red Sox 112 CHC Chi Cubs
113 CIN Cincinnati Reds 114 CLE Cleveland Indians 115 COL Colorado Rockies 116 DET Detroit Tigers 117 HOU Houston Astros 118 KC Kansas City Royals 119 LAD LA Dodgers 120 WSH Washington Nationals 121 NYM NY Mets 133 OAK Oakland Athletics 134 PIT Pittsburgh Pirates 135 SD San Diego Padres 136 SEA Seattle Mariners 137 SF San Francisco Giants 138 STL St. Louis Cardinals 139 TB Tampa Bay Rays 140 TEX Texas Rangers 141 TOR Toronto Blue Jays 142 MIN Minnesota Twins 143 PHI Philadelphia Phillies 144 ATL Atlanta Braves 145 CWS Chi White Sox 146 MIA Miami Marlins 147 NYY NY Yankees 158 MIL Milwaukee Brewers