mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 07:43:31 -07:00
Address code review feedback
- Use hqdefault.jpg instead of maxresdefault.jpg (guaranteed to exist for all videos) - Extract thumbnail URL logic to GetThumbnailUrl method for better testability Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
parent
c3f89c45b1
commit
b9865dce8c
|
|
@ -4,7 +4,11 @@ public partial record YouTubeVideoEmbedProjection(string VideoId)
|
|||
{
|
||||
public string Url { get; } = $"https://www.youtube.com/watch?v={VideoId}";
|
||||
|
||||
public string ThumbnailUrl { get; } = $"https://i.ytimg.com/vi/{VideoId}/maxresdefault.jpg";
|
||||
// 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 string GetThumbnailUrl(Embed embed) =>
|
||||
embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? ThumbnailUrl;
|
||||
}
|
||||
|
||||
public partial record YouTubeVideoEmbedProjection
|
||||
|
|
|
|||
|
|
@ -427,10 +427,7 @@
|
|||
@* Video thumbnail *@
|
||||
<div class="chatlog__embed-youtube-container">
|
||||
<a href="@youTubeVideoEmbed.Url">
|
||||
@{
|
||||
var thumbnailUrl = embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? youTubeVideoEmbed.ThumbnailUrl;
|
||||
}
|
||||
<img class="chatlog__embed-youtube-thumbnail" src="@await ResolveAssetUrlAsync(thumbnailUrl)" alt="YouTube video thumbnail" loading="lazy" onerror="this.style.visibility='hidden'" data-canonical-url="@thumbnailUrl">
|
||||
<img class="chatlog__embed-youtube-thumbnail" src="@await ResolveAssetUrlAsync(youTubeVideoEmbed.GetThumbnailUrl(embed))" alt="YouTube video thumbnail" loading="lazy" onerror="this.style.visibility='hidden'" data-canonical-url="@youTubeVideoEmbed.GetThumbnailUrl(embed)">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue