-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support Invidious image proxy endpoints #257
base: main
Are you sure you want to change the base?
Conversation
@@ -183,6 +133,13 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> { | |||
return Ok(response.finish()); | |||
} | |||
|
|||
#[cfg(feature = "invidious")] | |||
if matches!(req.path().get(0..4), Some("/vi/") | Some("/sb/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Invidious endpoints be backwards compatible with Piped? For example, both Invidious and Piped can download video previews via /vi/
, but Piped requests them with query (/vi/MYSQe4uuSOA/hq720.jpg?host=i.ytimg.com&qhash=...&rs=...&sqp=...
) while Invidious requests them without query (/vi/MYSQe4uuSOA/mqdefault.jpg
).
With the current approach they are not backwards compatible, so if a Piped client sends a request to a proxy with invidious
feature enabled, qhash
and other parameters will not be used and validated. This allows avoiding unnecessary checks for instances running only Piped or only Invidious, but will cause problems for instances running both.
If they need to be backwards compatible, a check that the query is empty could be added here, for example.
}; | ||
|
||
#[cfg(feature = "avif")] | ||
if content_type == "image/webp" || content_type == "image/jpeg" && avif { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this check supposed to be like that?
if content_type == "image/webp" || content_type == "image/jpeg" && avif { | |
if (content_type == "image/webp" || content_type == "image/jpeg") && avif { |
Now image/webp
is always transcoded regardless of the presence of avif
in the query, because this check is computed as
if content_type == "image/webp" || (content_type == "image/jpeg" && avif) {
image_response: Response, | ||
http_response: &mut HttpResponseBuilder, | ||
#[cfg(feature = "avif")] avif: bool, | ||
) -> Result<Either<HttpResponse, Response>, Box<dyn std::error::Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What behavior is expected in case of transcoding errors? Should the server return 500 Internal Server Error
(as it is now) or the original image?
So, this is an attempt to add support for Invidious-specific image endpoints.
I marked PR as a draft because I have some questions about expected behavior.
closes #111