Skip to content

Commit

Permalink
Several URL list fixes (#1007)
Browse files Browse the repository at this point in the history
* Fix crash when a given VOD/Clip is not found

* Fix queue button remaining disabled on error
  • Loading branch information
ScrubN authored Mar 24, 2024
1 parent d02269d commit 63e2984
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions TwitchDownloaderWPF/WindowUrlList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e)
{
btnQueue.IsEnabled = false;
List<string> idList = new List<string>();
List<string> urlList = new List<string>(textList.Text.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
List<string> invalidList = new List<string>();
List<string> errorList = new List<string>();
List<TaskData> dataList = new List<TaskData>();
Dictionary<string, string> idDict = new Dictionary<string, string>();

foreach (var url in urlList)
var urls = textList.Text.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
foreach (var url in urls)
{
string id = PageChatDownload.ValidateUrl(url);

Expand All @@ -49,6 +49,7 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e)
if (invalidList.Count > 0)
{
MessageBox.Show(Translations.Strings.UnableToParseInputsMessage + Environment.NewLine + string.Join(Environment.NewLine, invalidList.ToArray()), Translations.Strings.UnableToParseInputs, MessageBoxButton.OK, MessageBoxImage.Error);
btnQueue.IsEnabled = true;
return;
}

Expand Down Expand Up @@ -84,9 +85,8 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e)
continue;

string id = taskDict[task.Id];
if (!task.IsFaulted)
if (!task.IsFaulted && task.Result.data.video is { } videoInfo)
{
var videoInfo = task.Result.data.video;
var thumbUrl = videoInfo.thumbnailURLs.FirstOrDefault();
if (!ThumbnailService.TryGetThumb(thumbUrl, out var thumbnail))
{
Expand Down Expand Up @@ -123,9 +123,8 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e)
continue;

string id = taskDict[task.Id];
if (!task.IsFaulted)
if (!task.IsFaulted && task.Result.data.clip is { } clipInfo)
{
var clipInfo = task.Result.data.clip;
var thumbUrl = clipInfo.thumbnailURL;
if (!ThumbnailService.TryGetThumb(thumbUrl, out var thumbnail))
{
Expand Down Expand Up @@ -153,6 +152,7 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e)
if (errorList.Count > 0)
{
MessageBox.Show(Translations.Strings.UnableToGetInfoMessage + Environment.NewLine + string.Join(Environment.NewLine, errorList.ToArray()), Translations.Strings.UnableToGetInfo, MessageBoxButton.OK, MessageBoxImage.Error);
btnQueue.IsEnabled = true;
return;
}

Expand Down

0 comments on commit 63e2984

Please sign in to comment.