diff --git a/frigate/http.py b/frigate/http.py index cd827c998..16e6361af 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -1,5 +1,5 @@ import base64 -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import copy import glob import logging @@ -801,7 +801,6 @@ def get_recordings_storage_usage(): def recordings_summary(camera_name): tz_name = request.args.get("timezone", default="utc", type=str) tz_offset = f"{int(datetime.now(pytz.timezone(tz_name)).utcoffset().total_seconds()/60/60)} hour" - logger.error(f"The difference is {tz_offset}") recording_groups = ( Recordings.select( fn.strftime( @@ -1023,12 +1022,12 @@ def vod_ts(camera_name, start_ts, end_ts): ) -@bp.route("/vod////") -def vod_hour(year_month, day, hour, camera_name): - tz_name = request.args.get("timezone", "utc") - start_date = datetime.strptime(f"{year_month}-{day} {hour}", "%Y-%m-%d %H").replace( - tzinfo=pytz.timezone(tz_name) - ) +# TODO make this nicer when vod module is removed +@bp.route("/vod/////") +def vod_hour(year_month, day, hour, camera_name, tz_name): + tz_name = tz_name.replace("_", "/") + parts = year_month.split("-") + start_date = datetime(int(parts[0]), int(parts[1]), int(day), int(hour), tzinfo=pytz.timezone(tz_name)).astimezone(timezone.utc) end_date = start_date + timedelta(hours=1) - timedelta(milliseconds=1) start_ts = start_date.timestamp() end_ts = end_date.timestamp() diff --git a/web/src/routes/Recording.jsx b/web/src/routes/Recording.jsx index 7002535e7..ee862e8bb 100644 --- a/web/src/routes/Recording.jsx +++ b/web/src/routes/Recording.jsx @@ -10,7 +10,7 @@ import useSWR from 'swr'; export default function Recording({ camera, date, hour = '00', minute = '00', second = '00' }) { const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - //const timezone = "America/Chicago" + //const timezone = 'America/Chicago'; const currentDate = useMemo( () => (date ? parseISO(`${date}T${hour || '00'}:${minute || '00'}:${second || '00'}`) : new Date()), [date, hour, minute, second] @@ -24,7 +24,6 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se const recordingParams = { before: getUnixTime(endOfHour(currentDate)), after: getUnixTime(startOfHour(currentDate)), - timezone, }; const { data: recordings } = useSWR([`${camera}/recordings`, recordingParams], { revalidateOnFocus: false }); @@ -71,14 +70,17 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se description: `${camera} recording @ ${h.hour}:00.`, sources: [ { - src: `${apiHost}/vod/${year}-${month}/${day}/${h.hour}/${camera}/master.m3u8`, + src: `${apiHost}/vod/${year}-${month}/${day}/${h.hour}/${camera}/${timezone.replaceAll( + '/', + '_' + )}/master.m3u8`, type: 'application/vnd.apple.mpegurl', }, ], }; }) .reverse(); - }, [apiHost, date, recordingsSummary, camera]); + }, [apiHost, date, recordingsSummary, camera, timezone]); const playlistIndex = useMemo(() => { const index = playlist.findIndex((item) => item.name === hour);