Skip to content

Commit 2fc547c

Browse files
committed
Increase retry count and improve video format handling
Updated the `tryCount` default value in `GetVideoBytesAsync` from 3 to 5 to allow more retry attempts. Modified the `contentType` check to support all video formats by matching `"video/"` instead of only `"video/mp4"`. Adjusted the sequence of `PostAsync` and `Task.Delay` calls for better operation flow.
1 parent 80ffd2b commit 2fc547c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/Blink/BlinkClient.VideoMethods.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public async Task<IEnumerable<BlinkVideoInfo>> GetVideosFromSingleModuleAsync()
7575
/// <returns>Video as byte array</returns>
7676
/// <exception cref="BlinkClientException">Thrown when not authorized</exception>
7777
/// <exception cref="BlinkClientException">Thrown when video data is not valid. Please create an issue if you see this error.</exception>
78-
public async Task<byte[]> GetVideoBytesAsync(BlinkVideoInfo video, int tryCount = 3)
78+
public async Task<byte[]> GetVideoBytesAsync(BlinkVideoInfo video, int tryCount = 5)
7979
{
8080
if (_accountId == null)
8181
{
@@ -94,12 +94,12 @@ public async Task<byte[]> GetVideoBytesAsync(BlinkVideoInfo video, int tryCount
9494
var httpClient = await GetHttpClientAsync();
9595
while (count++ < tryCount)
9696
{
97-
await httpClient.PostAsync(url, null);
9897
await Task.Delay(GeneralSleepTime);
98+
await httpClient.PostAsync(url, null);
9999

100100
response = await httpClient.GetAsync(url);
101101
contentType = response.Content.Headers.ContentType?.MediaType ?? string.Empty;
102-
if (contentType == "video/mp4")
102+
if (contentType.StartsWith("video/"))
103103
{
104104
return await response.Content.ReadAsByteArrayAsync();
105105
}

0 commit comments

Comments
 (0)