mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-15 06:22:50 +00:00
Individually proxy images and thumbnails
This commit is contained in:
parent
e466be8946
commit
c586de66ba
4 changed files with 28 additions and 9 deletions
12
src/proxy.rs
12
src/proxy.rs
|
@ -4,9 +4,6 @@ use tide::{Request, Response};
|
|||
|
||||
pub async fn handler(req: Request<()>) -> tide::Result {
|
||||
let domains = vec![
|
||||
// THUMBNAILS
|
||||
"a.thumbs.redditmedia.com",
|
||||
"b.thumbs.redditmedia.com",
|
||||
// EMOJI
|
||||
"emoji.redditmedia.com",
|
||||
// ICONS
|
||||
|
@ -15,8 +12,6 @@ pub async fn handler(req: Request<()>) -> tide::Result {
|
|||
// PREVIEWS
|
||||
"preview.redd.it",
|
||||
"external-preview.redd.it",
|
||||
// MEDIA
|
||||
"i.redd.it",
|
||||
];
|
||||
|
||||
let decoded = decode(req.param("url").unwrap_or_default()).map(|bytes| String::from_utf8(bytes).unwrap_or_default());
|
||||
|
@ -49,6 +44,13 @@ pub async fn image(req: Request<()>) -> tide::Result {
|
|||
request(url).await
|
||||
}
|
||||
|
||||
pub async fn thumbnail(req: Request<()>) -> tide::Result {
|
||||
let id = req.param("id").unwrap_or_default();
|
||||
let point = req.param("point").unwrap_or_default();
|
||||
let url = format!("https://{}.thumbs.redditmedia.com/{}", point, id);
|
||||
request(url).await
|
||||
}
|
||||
|
||||
async fn request(url: String) -> tide::Result {
|
||||
let http = surf::get(url).await.unwrap();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue