diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs index 207e8041..a959d462 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlEmbedSpecs.cs @@ -181,8 +181,14 @@ public class HtmlEmbedSpecs ); // Assert - var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src"); - iframeUrl.Should().StartWith("https://www.youtube.com/embed/qOWW4OlgbvE"); + // Check that the YouTube video thumbnail image exists with the correct video ID + var youtubeThumbnailSrc = message + .QuerySelectorAll("img") + .Select(e => e.GetAttribute("src")) + .WhereNotNull() + .FirstOrDefault(s => s.Contains("qOWW4OlgbvE", StringComparison.Ordinal)); + + youtubeThumbnailSrc.Should().NotBeNull(); } [Fact] diff --git a/DiscordChatExporter.Core/Discord/Data/Embeds/YouTubeVideoEmbedProjection.cs b/DiscordChatExporter.Core/Discord/Data/Embeds/YouTubeVideoEmbedProjection.cs index ce13bdfd..f6d095d2 100644 --- a/DiscordChatExporter.Core/Discord/Data/Embeds/YouTubeVideoEmbedProjection.cs +++ b/DiscordChatExporter.Core/Discord/Data/Embeds/YouTubeVideoEmbedProjection.cs @@ -2,7 +2,10 @@ public partial record YouTubeVideoEmbedProjection(string VideoId) { - public string Url { get; } = $"https://www.youtube.com/embed/{VideoId}"; + public string Url { get; } = $"https://www.youtube.com/watch?v={VideoId}"; + + // Using hqdefault.jpg which is guaranteed to exist for all YouTube videos + public string ThumbnailUrl { get; } = $"https://i.ytimg.com/vi/{VideoId}/hqdefault.jpg"; } public partial record YouTubeVideoEmbedProjection diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index e27fad2b..641c2ada 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -424,9 +424,11 @@ } - @* Video player *@ + @* Video thumbnail *@
- + + YouTube video thumbnail +
diff --git a/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml b/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml index 9e746e16..792612c7 100644 --- a/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/PreambleTemplate.cshtml @@ -711,9 +711,11 @@ margin-top: 0.6rem; } - .chatlog__embed-youtube { - border: 0; + .chatlog__embed-youtube-thumbnail { + max-width: 400px; + max-height: 225px; border-radius: 3px; + cursor: pointer; } .chatlog__sticker {