Skip to content

Commit

Permalink
Switch to region-agnostic media browser title formats (#392)
Browse files Browse the repository at this point in the history
* Switch to media browser title formats that are more suitable for international users

* Continue to validate y-m-d
  • Loading branch information
NickM-27 authored Jan 2, 2023
1 parent f8c3fba commit b929870
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions custom_components/frigate/media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
],
}
Expand Down Expand Up @@ -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,
Expand All @@ -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",
},
],
}
Expand Down

0 comments on commit b929870

Please sign in to comment.