Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when downloading clips or chats of clips created by now deleted users #1274

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading