Fix Reolink playback of recodings (#134652)

This commit is contained in:
starkillerOG 2025-01-06 18:54:32 +01:00 committed by Franck Nijhof
parent a9a14381d3
commit a14f6faaaf
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 5 additions and 5 deletions

View File

@ -2,9 +2,9 @@
from __future__ import annotations from __future__ import annotations
from base64 import urlsafe_b64decode, urlsafe_b64encode
from http import HTTPStatus from http import HTTPStatus
import logging import logging
from urllib import parse
from aiohttp import ClientError, ClientTimeout, web from aiohttp import ClientError, ClientTimeout, web
from reolink_aio.enums import VodRequestType from reolink_aio.enums import VodRequestType
@ -31,7 +31,7 @@ def async_generate_playback_proxy_url(
return url_format.format( return url_format.format(
config_entry_id=config_entry_id, config_entry_id=config_entry_id,
channel=channel, channel=channel,
filename=parse.quote(filename, safe=""), filename=urlsafe_b64encode(filename.encode("utf-8")).decode("utf-8"),
stream_res=stream_res, stream_res=stream_res,
vod_type=vod_type, vod_type=vod_type,
) )
@ -66,7 +66,7 @@ class PlaybackProxyView(HomeAssistantView):
"""Get playback proxy video response.""" """Get playback proxy video response."""
retry = retry - 1 retry = retry - 1
filename = parse.unquote(filename) filename_decoded = urlsafe_b64decode(filename.encode("utf-8")).decode("utf-8")
ch = int(channel) ch = int(channel)
try: try:
host = get_host(self.hass, config_entry_id) host = get_host(self.hass, config_entry_id)
@ -77,7 +77,7 @@ class PlaybackProxyView(HomeAssistantView):
try: try:
mime_type, reolink_url = await host.api.get_vod_source( mime_type, reolink_url = await host.api.get_vod_source(
ch, filename, stream_res, VodRequestType(vod_type) ch, filename_decoded, stream_res, VodRequestType(vod_type)
) )
except ReolinkError as err: except ReolinkError as err:
_LOGGER.warning("Reolink playback proxy error: %s", str(err)) _LOGGER.warning("Reolink playback proxy error: %s", str(err))

View File

@ -22,7 +22,7 @@ TEST_DAY = 14
TEST_DAY2 = 15 TEST_DAY2 = 15
TEST_HOUR = 13 TEST_HOUR = 13
TEST_MINUTE = 12 TEST_MINUTE = 12
TEST_FILE_NAME_MP4 = f"{TEST_YEAR}{TEST_MONTH}{TEST_DAY}{TEST_HOUR}{TEST_MINUTE}00.mp4" TEST_FILE_NAME_MP4 = f"Mp4Record/{TEST_YEAR}-{TEST_MONTH}-{TEST_DAY}/RecS04_{TEST_YEAR}{TEST_MONTH}{TEST_DAY}{TEST_HOUR}{TEST_MINUTE}00_123456_AB123C.mp4"
TEST_STREAM = "sub" TEST_STREAM = "sub"
TEST_CHANNEL = "0" TEST_CHANNEL = "0"
TEST_VOD_TYPE = VodRequestType.PLAYBACK.value TEST_VOD_TYPE = VodRequestType.PLAYBACK.value