1.0-dev11 (Notifications added, removing task after success option added, deleting video temp after error option added)

This commit is contained in:
2022-03-03 00:34:52 +01:00
Unverified
parent d8eb103dcc
commit bcdb1dd246
7 changed files with 85 additions and 19 deletions

View File

@@ -17,7 +17,7 @@ namespace VDownload.Core.Services
{
{ "delete_temp_on_start", true },
{ "twitch_vod_passive_trim", true },
{ "twitch_vod_downloading_chunk_retry_after_error", true },
{ "twitch_vod_downloading_chunk_retry_after_error", false },
{ "twitch_vod_downloading_chunk_max_retries", 10 },
{ "twitch_vod_downloading_chunk_retries_delay", 5000 },
{ "media_transcoding_use_hardware_acceleration", true },
@@ -32,7 +32,10 @@ namespace VDownload.Core.Services
{ "custom_temp_location", false },
{ "max_active_video_task", 5 },
{ "replace_output_file_if_exists", false },
{ "remove_task_when_successfully_ended", false }
{ "remove_task_when_successfully_ended", false },
{ "delete_task_temp_when_ended_with_error", false },
{ "show_notification_when_task_ended_successfully", false },
{ "show_notification_when_task_ended_unsuccessfully", false }
};
#endregion

View File

@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
@@ -266,7 +267,7 @@ namespace VDownload.Core.Services.Sources.Twitch
private static async Task<byte[]> DownloadChunkAsync(Uri chunkUrl, CancellationToken cancellationToken = default)
{
int retriesCount = 0;
while ((bool)Config.GetValue("twitch_vod_downloading_chunk_retry_after_error") && retriesCount < (int)Config.GetValue("twitch_vod_downloading_chunk_max_retries"))
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
try
@@ -276,13 +277,16 @@ namespace VDownload.Core.Services.Sources.Twitch
return await client.DownloadDataTaskAsync(chunkUrl);
}
}
catch
catch (WebException wex)
{
retriesCount++;
await Task.Delay((int)Config.GetValue("twitch_vod_downloading_chunk_retries_delay"));
if ((bool)Config.GetValue("twitch_vod_downloading_chunk_retry_after_error") && retriesCount < (int)Config.GetValue("twitch_vod_downloading_chunk_max_retries"))
{
retriesCount++;
await Task.Delay((int)Config.GetValue("twitch_vod_downloading_chunk_retries_delay"));
}
else throw wex;
}
}
throw new WebException("An error occurs while downloading a Twitch VOD chunk");
}
// WRITE CHUNK TO FILE