feat: prefer maxresdefault.jpg thumbnail if available
This commit is contained in:
parent
e11fcb8268
commit
4710387f1b
1 changed files with 31 additions and 8 deletions
|
|
@ -1020,14 +1020,37 @@ impl DownloadQuery {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(thumbnail) = thumbnail {
|
if let Some(thumbnail) = thumbnail {
|
||||||
let resp = self
|
// Attempt to get the higher resolution, uncropped maxresdefault.jpg thumbnail if available
|
||||||
.dl
|
let mut resp = None;
|
||||||
.i
|
if thumbnail.height != thumbnail.width {
|
||||||
.http
|
if let Ok(x) = self
|
||||||
.get(thumbnail.url)
|
.dl
|
||||||
.send()
|
.i
|
||||||
.await?
|
.http
|
||||||
.error_for_status()?;
|
.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
|
let img_type = resp
|
||||||
.headers()
|
.headers()
|
||||||
.get(header::CONTENT_TYPE)
|
.get(header::CONTENT_TYPE)
|
||||||
|
|
|
||||||
Reference in a new issue