Skip to content

Commit

Permalink
Fix crash caused by downloading clips created by now deleted users (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN authored Dec 26, 2024
1 parent 87a84c5 commit 9bec730
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions TwitchDownloaderCore/ChatDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion TwitchDownloaderCore/Tools/FfmpegMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions TwitchDownloaderWPF/PageChatDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions TwitchDownloaderWPF/PageChatUpdate.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions TwitchDownloaderWPF/PageClipDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions TwitchDownloaderWPF/WindowMassDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down

0 comments on commit 9bec730

Please sign in to comment.