Skip to content

Commit 8b7df01

Browse files
authored
Merge pull request #4661 from eracknaphobia/plugin.video.mlbtv@matrix
[plugin.video.mlbtv@matrix] 2025.4.14+matrix.1
2 parents 8d38644 + 0c9279f commit 8b7df01

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

plugin.video.mlbtv/addon.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="plugin.video.mlbtv" name="MLB.TV®" version="2025.4.8+matrix.1" provider-name="eracknaphobia, tonywagner">
2+
<addon id="plugin.video.mlbtv" name="MLB.TV®" version="2025.4.14+matrix.1" provider-name="eracknaphobia, tonywagner">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
<import addon="script.module.pytz" />
@@ -22,12 +22,7 @@
2222
</description>
2323
<disclaimer lang="en_GB">Requires an MLB.tv account</disclaimer>
2424
<news>
25-
- automatic blackout/entitlement detection
26-
- support for SNLA and SNY subscriptions
27-
- skip timing, game changer, and hide scores ticker updates for 2025
28-
- jump to live when skipping start dialog and allowing spoilers
29-
- restored Big Inning schedule
30-
- fixed Catch Up option
25+
- Fix play favorite team on launch (thanks thromer and tonywagner)
3126
</news>
3227
<language>en</language>
3328
<platform>all</platform>

plugin.video.mlbtv/resources/lib/mlb.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ def create_game_listitem(game, game_day, start_inning, today, nonentitlement_dat
230230
desc = ''
231231

232232
is_free = False
233-
if 'content' in game and 'media' in game['content'] and 'freeGame' in game['content']['media']:
234-
is_free = game['content']['media']['freeGame']
233+
if 'broadcasts' in game and len(game['broadcasts']) > 0 and 'freeGame' in game['broadcasts'][0] and game['broadcasts'][0]['freeGame'] is True:
234+
is_free = True
235235

236236
fav_game = False
237237
if game['teams']['away']['team']['name'] in FAV_TEAM:
@@ -741,7 +741,7 @@ def stream_select(game_pk, spoiler='True', suspended='False', start_inning='Fals
741741
# check if our favorite team (if defined) is associated with this stream
742742
# or if no favorite team match, look for the home or national streams
743743
#if (FAV_TEAM != 'None' and 'mediaFeedSubType' in item and item['mediaFeedSubType'] == getFavTeamId()) or (selected_content_id is None and 'mediaFeedType' in item and (item['mediaFeedType'] == 'HOME' or item['mediaFeedType'] == 'NATIONAL' )):
744-
if (FAV_TEAM != 'None' and ((item['homeAway'] == 'home' and json_source['dates'][0]['games'][0]['teams']['home']['team']['id'] == getFavTeamId()) or (item['homeAway'] == 'away' and json_source['dates'][0]['games'][0]['teams']['away']['team']['id'] == getFavTeamId()))) or (selected_content_id is None and (item['homeAway'] == 'home' or item['isNational'] == True )):
744+
if (FAV_TEAM != 'None' and ((item['homeAway'] == 'home' and str(json_source['dates'][0]['games'][0]['teams']['home']['team']['id']) == str(getFavTeamId())) or (item['homeAway'] == 'away' and str(json_source['dates'][0]['games'][0]['teams']['away']['team']['id']) == str(getFavTeamId())))) or (selected_content_id is None and (item['homeAway'] == 'home' or item['isNational'] == True )):
745745
# prefer live streams (suspended games can have both a live and archived stream available)
746746
if item['mediaState']['mediaStateCode'] == 'MEDIA_ON':
747747
selected_content_id = item['mediaId']
@@ -751,7 +751,7 @@ def stream_select(game_pk, spoiler='True', suspended='False', start_inning='Fals
751751
# selected_media_type = item['mediaFeedType']
752752
# once we've found a fav team live stream, we don't need to search any further
753753
#if FAV_TEAM != 'None' and 'mediaFeedSubType' in item and item['mediaFeedSubType'] == getFavTeamId():
754-
if FAV_TEAM != 'None' and ((item['homeAway'] == 'home' and json_source['dates'][0]['games'][0]['teams']['home']['team']['id'] == getFavTeamId()) or (item['homeAway'] == 'away' and json_source['dates'][0]['games'][0]['teams']['away']['team']['id'] == getFavTeamId())):
754+
if FAV_TEAM != 'None' and ((item['homeAway'] == 'home' and str(json_source['dates'][0]['games'][0]['teams']['home']['team']['id']) == str(getFavTeamId())) or (item['homeAway'] == 'away' and str(json_source['dates'][0]['games'][0]['teams']['away']['team']['id']) == str(getFavTeamId()))):
755755
break
756756
# fall back to the first available archive stream, but keep search in case there is a live stream (suspended)
757757
elif item['mediaState']['mediaStateCode'] == 'MEDIA_ARCHIVE' and selected_content_id is None:
@@ -1518,9 +1518,10 @@ def live_fav_game():
15181518
settings.setSetting(id='auto_play_game_checked', value=str(now))
15191519

15201520
url = API_URL + '/api/v1/schedule'
1521-
url += '?hydrate=game(content(media(epg))),team'
1521+
url += '?hydrate=broadcasts'
15221522
url += '&sportId=1,51'
15231523
url += '&date=' + game_day
1524+
url += '&teamId=' + fav_team_id
15241525

15251526
headers = {
15261527
'User-Agent': UA_PC
@@ -1532,7 +1533,8 @@ def live_fav_game():
15321533

15331534
if 'dates' in json_source and len(json_source['dates']) > 0 and 'games' in json_source['dates'][0]:
15341535
games = json_source['dates'][0]['games']
1535-
nonentitlement_data = get_nonentitlement_data()
1536+
nonentitlement_data = get_nonentitlement_data(game_day)
1537+
found = False
15361538
for game in games:
15371539
try:
15381540
# only check games that include our fav team
@@ -1541,19 +1543,26 @@ def live_fav_game():
15411543
if game['status']['abstractGameState'] != 'Final':
15421544
# only check games that are entitled and not blacked out
15431545
if str(game['gamePk']) not in nonentitlement_data:
1544-
if 'content' in game and 'media' in game['content'] and 'epg' in game['content']['media'] and len(game['content']['media']['epg']) > 0 and 'items' in game['content']['media']['epg'][0]:
1545-
for epg in game['content']['media']['epg'][0]['items']:
1546+
mediaStateCode = None
1547+
for broadcast in game.get('broadcasts', []):
1548+
mediaStateCode = broadcast.get('mediaState', {}).get('mediaStateCode', '')
1549+
if mediaStateCode:
15461550
# if media is off, assume it is still upcoming
1547-
if epg['mediaState'] == 'MEDIA_OFF':
1551+
if mediaStateCode == 'MEDIA_OFF':
15481552
if game['status']['startTimeTBD'] is True:
15491553
upcoming_game = 'TBD'
15501554
else:
15511555
upcoming_game = parse(game['gameDate']) - timedelta(minutes=10)
1556+
found = True
15521557
# if media is on, that means it is live
1553-
elif game_pk is None and epg['mediaState'] == 'MEDIA_ON':
1558+
elif game_pk is None and mediaStateCode == 'MEDIA_ON':
15541559
game_pk = str(game['gamePk'])
15551560
xbmc.log('Found live fav game ' + game_pk)
1556-
break
1561+
found = True
1562+
if found:
1563+
break # broadcast loop
1564+
if found:
1565+
break # game loop
15571566
except:
15581567
pass
15591568

0 commit comments

Comments
 (0)