Skip to content

Commit ca18152

Browse files
committed
Add a little badge easter egg for my username
1 parent a1fa85a commit ca18152

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

TwitchDownloaderCLI/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Path to JSON chat file input.
9292
(Default: 4) Size of outline if outline is enabled.
9393

9494
**-f/-\-font**
95-
(Default: Ariel) Font to use.
95+
(Default: Arial) Font to use.
9696

9797
**-\-font-size**
9898
(Default: 12) Size of font.

TwitchDownloaderCore/ChatRenderer.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,24 @@ public static SKBitmap DrawTimestamp(SKBitmap sectionImage, List<SKBitmap> image
463463
}
464464
public SKBitmap DrawBadges(SKBitmap sectionImage, List<SKBitmap> imageList, ChatRenderOptions renderOptions, List<ChatBadge> chatBadges, Comment comment, Size canvasSize, ref Point drawPos)
465465
{
466+
//A little easter egg for my Twitch username won't hurt :)
467+
if (comment.commenter.name == "ilovekeepo69" && chatBadges.Any(x => x.Name == "ilovekeepo69"))
468+
{
469+
SKBitmap badgeImage = chatBadges.Where(x => x.Name == "ilovekeepo69").First().Versions["1"];
470+
using (SKCanvas sectionImageCanvas = new SKCanvas(sectionImage))
471+
{
472+
float imageRatio = (float)(renderOptions.EmoteScale * 0.5);
473+
float imageSize = badgeImage.Width * imageRatio;
474+
float left = (float)drawPos.X;
475+
float right = imageSize + left;
476+
float top = (float)((sectionImage.Height - imageSize) / 2);
477+
float bottom = imageSize + top;
478+
SKRect drawBox = new SKRect(left, top, right, bottom);
479+
sectionImageCanvas.DrawBitmap(badgeImage, drawBox, imagePaint);
480+
drawPos.X += (int)Math.Floor(20 * renderOptions.EmoteScale);
481+
}
482+
}
483+
466484
if (comment.message.user_badges != null)
467485
{
468486
foreach (var badge in comment.message.user_badges)
@@ -502,7 +520,6 @@ public SKBitmap DrawBadges(SKBitmap sectionImage, List<SKBitmap> imageList, Chat
502520
}
503521
}
504522
}
505-
506523
return sectionImage;
507524
}
508525
public static SKBitmap DrawUsername(SKBitmap sectionImage, List<SKBitmap> imageList, ChatRenderOptions renderOptions, SKPaint nameFont, string userName, SKColor userColor, Size canvasSize, ref Point drawPos)

TwitchDownloaderCore/TwitchHelper.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,20 @@ public static List<ChatBadge> GetChatBadges(int streamerId)
397397

398398
chatBadges.Add(new ChatBadge() { Name = name, Versions = versions });
399399
}
400+
401+
try
402+
{
403+
byte[] bytes = client.DownloadData("https://cdn.betterttv.net/emote/58493695987aab42df852e0f/2x");
404+
MemoryStream ms = new MemoryStream(bytes);
405+
SKBitmap badgeImage = SKBitmap.Decode(ms);
406+
SKBitmap scaledBitmap = new SKBitmap(36, 36);
407+
using (SKCanvas canvas = new SKCanvas(scaledBitmap))
408+
{
409+
canvas.DrawBitmap(badgeImage, new SKRect(0, 0, 36, 36), new SKPaint());
410+
}
411+
chatBadges.Add(new ChatBadge() { Name = "ilovekeepo69", Versions = new Dictionary<string, SKBitmap>() { { "1", scaledBitmap } } });
412+
}
413+
catch { }
400414
}
401415

402416
return chatBadges;

0 commit comments

Comments
 (0)