From b929870e680c5df41adc9759097ea4f0922a9131 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 2 Jan 2023 11:40:21 -0700 Subject: [PATCH] Switch to region-agnostic media browser title formats (#392) * Switch to media browser title formats that are more suitable for international users * Continue to validate y-m-d --- custom_components/frigate/media_source.py | 10 +++------- tests/test_media_source.py | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/custom_components/frigate/media_source.py b/custom_components/frigate/media_source.py index 57d0420a..1e39f8ab 100644 --- a/custom_components/frigate/media_source.py +++ b/custom_components/frigate/media_source.py @@ -1276,9 +1276,7 @@ def _get_recording_days( for day_item in recording_days: try: - title = dt.datetime.strptime(day_item["day"], "%Y-%m-%d").strftime( - "%B, %d %Y" - ) + dt.datetime.strptime(day_item["day"], "%Y-%m-%d") except ValueError as exc: raise MediaSourceError( "Media source is not valid for %s %s" @@ -1295,7 +1293,7 @@ def _get_recording_days( media_class=MEDIA_CLASS_DIRECTORY, children_media_class=MEDIA_CLASS_DIRECTORY, media_content_type=identifier.media_type, - title=title, + title=day_item["day"], can_play=False, can_expand=True, thumbnail=None, @@ -1320,9 +1318,7 @@ def _get_recording_hours( for hour_data in hour_items: try: - title = dt.datetime.strptime(hour_data["hour"], "%H").strftime( - "%I:00 %p" - ) + title = dt.datetime.strptime(hour_data["hour"], "%H").strftime("%H:00") except ValueError as exc: raise MediaSourceError( "Media source is not valid for %s %s" diff --git a/tests/test_media_source.py b/tests/test_media_source.py index 43b2c3d9..0b97d0c1 100644 --- a/tests/test_media_source.py +++ b/tests/test_media_source.py @@ -763,7 +763,7 @@ async def test_async_browse_media_recordings_root( ), "media_content_type": "video", "thumbnail": None, - "title": "December, 31 2022", + "title": "2022-12-31", } ], } @@ -801,7 +801,7 @@ async def test_async_browse_media_recordings_root( ), "media_content_type": "video", "thumbnail": None, - "title": "01:00 AM", + "title": "01:00", }, { "can_expand": False, @@ -814,7 +814,7 @@ async def test_async_browse_media_recordings_root( ), "media_content_type": "video", "thumbnail": None, - "title": "12:00 AM", + "title": "00:00", }, ], }