From 63e2984c1e9de8cff3878786bdea432ef7a91b00 Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Sun, 24 Mar 2024 16:10:07 -0400 Subject: [PATCH] Several URL list fixes (#1007) * Fix crash when a given VOD/Clip is not found * Fix queue button remaining disabled on error --- TwitchDownloaderWPF/WindowUrlList.xaml.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TwitchDownloaderWPF/WindowUrlList.xaml.cs b/TwitchDownloaderWPF/WindowUrlList.xaml.cs index fd05c7f3..7c237050 100644 --- a/TwitchDownloaderWPF/WindowUrlList.xaml.cs +++ b/TwitchDownloaderWPF/WindowUrlList.xaml.cs @@ -25,13 +25,13 @@ private async void btnQueue_Click(object sender, RoutedEventArgs e) { btnQueue.IsEnabled = false; List idList = new List(); - List urlList = new List(textList.Text.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)); List invalidList = new List(); List errorList = new List(); List dataList = new List(); Dictionary idDict = new Dictionary(); - 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); @@ -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; } @@ -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)) { @@ -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)) { @@ -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; }