From 7606250cf4aca9fd5c7aba72cb19f27137dc0bf5 Mon Sep 17 00:00:00 2001 From: lay295 Date: Thu, 14 Jan 2021 20:47:11 -0500 Subject: [PATCH] Skip comments with null commenter --- TwitchDownloaderCore/ChatRenderer.cs | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/TwitchDownloaderCore/ChatRenderer.cs b/TwitchDownloaderCore/ChatRenderer.cs index 0d09cac3..3da1b8a3 100644 --- a/TwitchDownloaderCore/ChatRenderer.cs +++ b/TwitchDownloaderCore/ChatRenderer.cs @@ -73,7 +73,7 @@ await Task.Run(() => { if (comment.source != "chat") continue; - if (comment.message.fragments == null) + if (comment.message.fragments == null || comment.commenter == null) continue; if (comment.message.user_notice_params != null && comment.message.user_notice_params.msg_id != null) { @@ -484,22 +484,26 @@ public static SKBitmap DrawTimestamp(SKBitmap sectionImage, List image public SKBitmap DrawBadges(SKBitmap sectionImage, List imageList, ChatRenderOptions renderOptions, List chatBadges, Comment comment, Size canvasSize, ref Point drawPos) { //A little easter egg for my Twitch username won't hurt :) - if (comment.commenter.name == "ilovekeepo69" && chatBadges.Any(x => x.Name == "ilovekeepo69")) + try { - SKBitmap badgeImage = chatBadges.Where(x => x.Name == "ilovekeepo69").First().Versions["1"]; - using (SKCanvas sectionImageCanvas = new SKCanvas(sectionImage)) + if (comment.commenter.name == "ilovekeepo69" && chatBadges.Any(x => x.Name == "ilovekeepo69")) { - float imageRatio = (float)(renderOptions.EmoteScale * 0.5); - float imageSize = badgeImage.Width * imageRatio; - float left = (float)drawPos.X; - float right = imageSize + left; - float top = (float)((sectionImage.Height - imageSize) / 2); - float bottom = imageSize + top; - SKRect drawBox = new SKRect(left, top, right, bottom); - sectionImageCanvas.DrawBitmap(badgeImage, drawBox, imagePaint); - drawPos.X += (int)Math.Floor(20 * renderOptions.EmoteScale); + SKBitmap badgeImage = chatBadges.Where(x => x.Name == "ilovekeepo69").First().Versions["1"]; + using (SKCanvas sectionImageCanvas = new SKCanvas(sectionImage)) + { + float imageRatio = (float)(renderOptions.EmoteScale * 0.5); + float imageSize = badgeImage.Width * imageRatio; + float left = (float)drawPos.X; + float right = imageSize + left; + float top = (float)((sectionImage.Height - imageSize) / 2); + float bottom = imageSize + top; + SKRect drawBox = new SKRect(left, top, right, bottom); + sectionImageCanvas.DrawBitmap(badgeImage, drawBox, imagePaint); + drawPos.X += (int)Math.Floor(20 * renderOptions.EmoteScale); + } } } + catch { } if (comment.message.user_badges != null) {