@@ -52,6 +52,7 @@ def __init__(self, hass: HomeAssistant) -> None:
52
52
verify_ssl = False ,
53
53
ssl_cipher = SSLCipherList .INSECURE ,
54
54
)
55
+ self ._vod_type : str | None = None
55
56
56
57
async def get (
57
58
self ,
@@ -68,6 +69,8 @@ async def get(
68
69
69
70
filename_decoded = urlsafe_b64decode (filename .encode ("utf-8" )).decode ("utf-8" )
70
71
ch = int (channel )
72
+ if self ._vod_type is not None :
73
+ vod_type = self ._vod_type
71
74
try :
72
75
host = get_host (self .hass , config_entry_id )
73
76
except Unresolvable :
@@ -127,6 +130,25 @@ async def get(
127
130
"apolication/octet-stream" ,
128
131
]:
129
132
err_str = f"Reolink playback expected video/mp4 but got { reolink_response .content_type } "
133
+ if (
134
+ reolink_response .content_type == "video/x-flv"
135
+ and vod_type == VodRequestType .PLAYBACK .value
136
+ ):
137
+ # next time use DOWNLOAD immediately
138
+ self ._vod_type = VodRequestType .DOWNLOAD .value
139
+ _LOGGER .debug (
140
+ "%s, retrying using download instead of playback cmd" , err_str
141
+ )
142
+ return await self .get (
143
+ request ,
144
+ config_entry_id ,
145
+ channel ,
146
+ stream_res ,
147
+ self ._vod_type ,
148
+ filename ,
149
+ retry ,
150
+ )
151
+
130
152
_LOGGER .error (err_str )
131
153
if reolink_response .content_type == "text/html" :
132
154
text = await reolink_response .text ()
@@ -140,7 +162,10 @@ async def get(
140
162
reolink_response .reason ,
141
163
response_headers ,
142
164
)
143
- response_headers ["Content-Type" ] = "video/mp4"
165
+ if "Content-Type" not in response_headers :
166
+ response_headers ["Content-Type" ] = reolink_response .content_type
167
+ if response_headers ["Content-Type" ] == "apolication/octet-stream" :
168
+ response_headers ["Content-Type" ] = "application/octet-stream"
144
169
145
170
response = web .StreamResponse (
146
171
status = reolink_response .status ,
0 commit comments