From 9bec7306739153436a3a00d9db6276c6e05f624e Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Thu, 26 Dec 2024 00:33:00 -0500 Subject: [PATCH] Fix crash caused by downloading clips created by now deleted users (#1274) --- TwitchDownloaderCore/ChatDownloader.cs | 6 +++--- TwitchDownloaderCore/Tools/FfmpegMetadata.cs | 2 +- TwitchDownloaderWPF/PageChatDownload.xaml.cs | 4 ++-- TwitchDownloaderWPF/PageChatUpdate.xaml.cs | 4 ++-- TwitchDownloaderWPF/PageClipDownload.xaml.cs | 4 ++-- TwitchDownloaderWPF/WindowMassDownload.xaml.cs | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TwitchDownloaderCore/ChatDownloader.cs b/TwitchDownloaderCore/ChatDownloader.cs index 1c0c639e..53aaefe0 100644 --- a/TwitchDownloaderCore/ChatDownloader.cs +++ b/TwitchDownloaderCore/ChatDownloader.cs @@ -387,9 +387,9 @@ private async Task DownloadAsyncImpl(FileInfo outputFileInfo, FileStream outputF chatRoot.streamer.id = int.Parse(clipInfoResponse.data.clip.broadcaster.id); chatRoot.clipper = new Clipper { - name = clipInfoResponse.data.clip.curator.displayName, - login = clipInfoResponse.data.clip.curator.login, - id = int.Parse(clipInfoResponse.data.clip.curator.id), + name = clipInfoResponse.data.clip.curator?.displayName, + login = clipInfoResponse.data.clip.curator?.login, + id = int.Parse(clipInfoResponse.data.clip.curator?.id ?? "0"), }; chatRoot.video.title = clipInfoResponse.data.clip.title; chatRoot.video.created_at = clipInfoResponse.data.clip.createdAt; diff --git a/TwitchDownloaderCore/Tools/FfmpegMetadata.cs b/TwitchDownloaderCore/Tools/FfmpegMetadata.cs index 7d29df09..5b6b6e02 100644 --- a/TwitchDownloaderCore/Tools/FfmpegMetadata.cs +++ b/TwitchDownloaderCore/Tools/FfmpegMetadata.cs @@ -32,7 +32,7 @@ public static async Task SerializeAsync(string filePath, string videoId, Clip cl await using var sw = new StreamWriter(fs) { NewLine = LINE_FEED }; var streamer = GetUserName(clip.broadcaster.displayName, clip.broadcaster.login); - var clipper = GetUserName(clip.curator.displayName, clip.curator.login); + var clipper = GetUserName(clip.curator?.displayName, clip.curator?.login); await SerializeGlobalMetadata(sw, streamer, videoId, clip.title, clip.createdAt, clip.viewCount, game: clip.game?.displayName, clipper: clipper); await SerializeChapters(sw, videoMomentEdges); diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs index adcdaab7..a3333536 100644 --- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs @@ -198,8 +198,8 @@ private async Task GetVideoInfo() currentVideoTime = Settings.Default.UTCVideoTime ? clipCreatedAt : clipCreatedAt.ToLocalTime(); textTitle.Text = clipInfo.data.clip.title; streamerId = clipInfo.data.clip.broadcaster?.id; - clipper = clipInfo.data.clip.curator.displayName; - clipperId = clipInfo.data.clip.curator.id; + clipper = clipInfo.data.clip.curator?.displayName ?? Translations.Strings.UnknownUser; + clipperId = clipInfo.data.clip.curator?.id; labelLength.Text = vodLength.ToString("c"); SetEnabled(true); diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs index 9bc92d01..dc682d61 100644 --- a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs +++ b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs @@ -172,8 +172,8 @@ private async void btnBrowse_Click(object sender, RoutedEventArgs e) labelLength.Text = VideoLength.ToString("c"); ViewCount = clipInfo.data.clip.viewCount; Game = clipInfo.data.clip.game?.displayName; - ClipperName ??= clipInfo.data.clip.curator.displayName; - ClipperId ??= clipInfo.data.clip.curator.id; + ClipperName ??= clipInfo.data.clip.curator?.displayName ?? Translations.Strings.UnknownUser; + ClipperId ??= clipInfo.data.clip.curator?.id; var thumbUrl = clipInfo.data.clip.thumbnailURL; if (!ThumbnailService.TryGetThumb(thumbUrl, out var image)) diff --git a/TwitchDownloaderWPF/PageClipDownload.xaml.cs b/TwitchDownloaderWPF/PageClipDownload.xaml.cs index 0761acc7..3a98693b 100644 --- a/TwitchDownloaderWPF/PageClipDownload.xaml.cs +++ b/TwitchDownloaderWPF/PageClipDownload.xaml.cs @@ -75,8 +75,8 @@ private async Task GetClipInfo() clipLength = TimeSpan.FromSeconds(taskClipInfo.Result.data.clip.durationSeconds); textStreamer.Text = clipData.data.clip.broadcaster?.displayName ?? Translations.Strings.UnknownUser; streamerId = clipData.data.clip.broadcaster?.id; - clipperName = clipData.data.clip.curator.displayName; - clipperId = clipData.data.clip.curator.id; + clipperName = clipData.data.clip.curator?.displayName ?? Translations.Strings.UnknownUser; + clipperId = clipData.data.clip.curator?.id; var clipCreatedAt = clipData.data.clip.createdAt; textCreatedAt.Text = Settings.Default.UTCVideoTime ? clipCreatedAt.ToString(CultureInfo.CurrentCulture) : clipCreatedAt.ToLocalTime().ToString(CultureInfo.CurrentCulture); currentVideoTime = Settings.Default.UTCVideoTime ? clipCreatedAt : clipCreatedAt.ToLocalTime(); diff --git a/TwitchDownloaderWPF/WindowMassDownload.xaml.cs b/TwitchDownloaderWPF/WindowMassDownload.xaml.cs index b02245ad..a4c3e929 100644 --- a/TwitchDownloaderWPF/WindowMassDownload.xaml.cs +++ b/TwitchDownloaderWPF/WindowMassDownload.xaml.cs @@ -211,8 +211,8 @@ private async Task UpdateList() Views = clip.node.viewCount, StreamerName = currentChannel.displayName, StreamerId = currentChannel.id, - ClipperName = clip.node.curator.displayName, - ClipperId = clip.node.curator.id, + ClipperName = clip.node.curator?.displayName ?? Translations.Strings.UnknownUser, + ClipperId = clip.node.curator?.id, Game = clip.node.game?.displayName ?? Translations.Strings.UnknownGame, Thumbnail = thumbnail });