Compare commits

...

1 Commits

Author SHA1 Message Date
IAmTomahawkx
3768ee6c57 feat: replace tenor with gifbox
Signed-off-by: IAmTomahawkx <iamtomahawkx@gmail.com>
2026-06-30 11:46:32 -07:00

View File

@@ -10,7 +10,7 @@ use tokio::sync::RwLock;
pub mod types;
const TENOR_API_BASE_URL: &str = "https://tenor.googleapis.com/v2";
const TENOR_API_BASE_URL: &str = "https://compat.gifbox.me/v2";
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TenorError {
@@ -59,7 +59,11 @@ impl Tenor {
}
}
pub async fn request<T: DeserializeOwned>(&self, path: &str, query: &[Option<(&str, &str)>]) -> Result<Arc<T>, TenorError> {
pub async fn request<T: DeserializeOwned>(
&self,
path: &str,
query: &[Option<(&str, &str)>],
) -> Result<Arc<T>, TenorError> {
let response = self
.client
.get(format!("{TENOR_API_BASE_URL}{path}"))
@@ -95,7 +99,9 @@ impl Tenor {
}
}
let res = self.coalescion.execute(unique_key.clone(), || async move {
let res = self
.coalescion
.execute(unique_key.clone(), || async move {
self.request::<types::PaginatedMediaResponse>(
"/search",
&[
@@ -107,9 +113,10 @@ impl Tenor {
Some(("contentfilter", "high")),
Some(("limit", &limit.to_string())),
position.is_empty().then_some(("pos", position)),
is_category.then_some(("component", "categories"))
]
).await
is_category.then_some(("component", "categories")),
],
)
.await
})
.await
.unwrap();
@@ -143,8 +150,9 @@ impl Tenor {
Some(("client_key", "Gifbox")),
Some(("locale", locale)),
Some(("contentfilter", "high")),
]
).await
],
)
.await
})
.await
.unwrap();
@@ -173,7 +181,9 @@ impl Tenor {
}
}
let res = self.coalescion.execute(unique_key.clone(), || async move {
let res = self
.coalescion
.execute(unique_key.clone(), || async move {
self.request::<types::PaginatedMediaResponse>(
"/featured",
&[
@@ -184,8 +194,9 @@ impl Tenor {
Some(("contentfilter", "high")),
Some(("limit", &limit.to_string())),
position.is_empty().then_some(("pos", position)),
]
).await
],
)
.await
})
.await
.unwrap();