fix: stop the YouTube covers coming out blurry and cropped

The ytimg variants are 16:9, so picking one by width handed a square tile far
fewer pixels than it needed: a 96px cover got the 120x90 file and kept 90px
after the crop. They are chosen by their short side now, the album art is
preferred over the video frame when the search returns both, and the display
sizes account for the tiles being up to 180px on a 2x screen.
This commit is contained in:
2026-07-20 19:05:44 +02:00
parent 3cbf64a191
commit ff6103cd58
4 changed files with 17 additions and 11 deletions
@@ -2,6 +2,9 @@ namespace Musify.Infrastructure.Services
{
public static class YouTubeThumbnail
{
public static bool IsSquare(string url) =>
url.Contains("googleusercontent.com", StringComparison.OrdinalIgnoreCase);
public static string WithSize(string url, int size)
{
if (string.IsNullOrEmpty(url))
@@ -40,9 +43,9 @@ namespace Musify.Infrastructure.Services
private static string YtImgFileName(int size) => size switch
{
<= 120 => "default.jpg",
<= 320 => "mqdefault.jpg",
<= 480 => "hqdefault.jpg",
<= 90 => "default.jpg",
<= 180 => "mqdefault.jpg",
<= 360 => "hqdefault.jpg",
_ => "maxresdefault.jpg"
};