Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to region-agnostic media browser title formats #392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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