mirror of
https://github.com/jcreek/YouTubeChannelDownloader.git
synced 2026-07-12 18:53:46 +00:00
fix(1): Add error handling and retry after 2 minutes for each video
This commit is contained in:
@@ -39,12 +39,36 @@ namespace YouTubeChannelDownloader
|
|||||||
foreach (YouTubeVideo video in newVideos)
|
foreach (YouTubeVideo video in newVideos)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Starting {channel.Title} - {video.PlaylistVideo.Title}");
|
Console.WriteLine($"Starting {channel.Title} - {video.PlaylistVideo.Title}");
|
||||||
string pathString = await DownloadVideoAsync(video, channel.Title);
|
try
|
||||||
await RecordSuccessfulVideoDownload(video, channel.Title);
|
{
|
||||||
|
string pathString = await DownloadVideoAsync(video, channel.Title);
|
||||||
|
await RecordSuccessfulVideoDownload(video, channel.Title);
|
||||||
|
|
||||||
// TODO? - set this up with a discard to run in a separate thread so more downloads can happen, need to be careful of error handling and logging
|
// TODO? - set this up with a discard to run in a separate thread so more downloads can happen, need to be careful of error handling and logging
|
||||||
TransferFileToNasShare(pathString);
|
TransferFileToNasShare(pathString);
|
||||||
DeleteLocalFile(pathString);
|
DeleteLocalFile(pathString);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Wait a few minutes then try again
|
||||||
|
int minutesToWait = 2;
|
||||||
|
await Task.Delay(minutesToWait * 60 * 1000);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string pathString = await DownloadVideoAsync(video, channel.Title);
|
||||||
|
await RecordSuccessfulVideoDownload(video, channel.Title);
|
||||||
|
|
||||||
|
// TODO? - set this up with a discard to run in a separate thread so more downloads can happen, need to be careful of error handling and logging
|
||||||
|
TransferFileToNasShare(pathString);
|
||||||
|
DeleteLocalFile(pathString);
|
||||||
|
}
|
||||||
|
catch (Exception ex2)
|
||||||
|
{
|
||||||
|
// Give up on this video, and log the error
|
||||||
|
Console.WriteLine($"Unable to process video after retrying due to error: {ex2.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user