mirror of
https://github.com/spikecodes/libreddit.git
synced 2026-01-25 14:04:07 +01:00
Individually proxy images and thumbnails
This commit is contained in:
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user