Fix handling of MLB rain delays, close #252

This commit is contained in:
2025-06-26 17:27:26 -04:00
parent 95b2c8cfc5
commit 1a706153a8

View File

@ -27,8 +27,15 @@
{% set period_str = period_str(team) %} {% set period_str = period_str(team) %}
{% set game_clock = state_attr(team,'clock') | lower %} {% set game_clock = state_attr(team,'clock') | lower %}
{% if state_attr(team,'league') == 'MLB' %} {% if state_attr(team,'league') == 'MLB' %}
{% set inning_parts = game_clock.split(' ') %} {% if 'rain delay' in game_clock %}
in the {{ inning_parts[0] ~ ' of the ' ~ inning_parts[1] ~ ' ' ~ period_str }} {# Handle cases like "Rain Delay, Top 1st" #}
{% set status, inning = game_clock.split(',', 1) %}
{% set inning_parts = inning.split(' ') %}
in a {{ status | trim }} in the {{ inning_parts[1] ~ ' of the ' ~ inning_parts[2] }} {{ period_str }}
{% else %}
{% set inning_parts = game_clock.split(' ') %}
in the {{ inning_parts[0] ~ ' of the ' ~ inning_parts[1] ~ ' ' ~ period_str }}
{% endif %}
{% else %} {% else %}
{% if ' - ' in game_clock %} {% if ' - ' in game_clock %}
{% set clock_time, quarter = game_clock.split(' - ') %} {% set clock_time, quarter = game_clock.split(' - ') %}