feat: prefer maxresdefault.jpg thumbnail if available

This commit is contained in:
ThetaDev 2025-01-12 23:56:50 +01:00
parent a7f8c789b1
commit a8e97f411a
No known key found for this signature in database
GPG key ID: E319D3C5148D65B6

View file

@ -1020,14 +1020,37 @@ impl DownloadQuery {
};
if let Some(thumbnail) = thumbnail {
let resp = self
.dl
.i
.http
.get(thumbnail.url)
.send()
.await?
.error_for_status()?;
// Attempt to get the higher resolution, uncropped maxresdefault.jpg thumbnail if available
let mut resp = None;
if thumbnail.height != thumbnail.width {
if let Ok(x) = self
.dl
.i
.http
.get(format!(
"https://i.ytimg.com/vi/{}/maxresdefault.jpg",
track.id
))
.send()
.await?
.error_for_status()
{
resp = Some(x);
}
}
let resp = match resp {
Some(resp) => resp,
None => self
.dl
.i
.http
.get(thumbnail.url)
.send()
.await?
.error_for_status()?,
};
let img_type = resp
.headers()
.get(header::CONTENT_TYPE)