feat: replace tenor with gifbox

Signed-off-by: IAmTomahawkx <iamtomahawkx@gmail.com>
This commit is contained in:
IAmTomahawkx
2026-06-30 11:46:32 -07:00
parent 7937179db7
commit 3768ee6c57

View File

@@ -10,7 +10,7 @@ use tokio::sync::RwLock;
pub mod types; 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)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum TenorError { 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 let response = self
.client .client
.get(format!("{TENOR_API_BASE_URL}{path}")) .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>( self.request::<types::PaginatedMediaResponse>(
"/search", "/search",
&[ &[
@@ -107,9 +113,10 @@ impl Tenor {
Some(("contentfilter", "high")), Some(("contentfilter", "high")),
Some(("limit", &limit.to_string())), Some(("limit", &limit.to_string())),
position.is_empty().then_some(("pos", position)), position.is_empty().then_some(("pos", position)),
is_category.then_some(("component", "categories")) is_category.then_some(("component", "categories")),
] ],
).await )
.await
}) })
.await .await
.unwrap(); .unwrap();
@@ -143,8 +150,9 @@ impl Tenor {
Some(("client_key", "Gifbox")), Some(("client_key", "Gifbox")),
Some(("locale", locale)), Some(("locale", locale)),
Some(("contentfilter", "high")), Some(("contentfilter", "high")),
] ],
).await )
.await
}) })
.await .await
.unwrap(); .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>( self.request::<types::PaginatedMediaResponse>(
"/featured", "/featured",
&[ &[
@@ -184,8 +194,9 @@ impl Tenor {
Some(("contentfilter", "high")), Some(("contentfilter", "high")),
Some(("limit", &limit.to_string())), Some(("limit", &limit.to_string())),
position.is_empty().then_some(("pos", position)), position.is_empty().then_some(("pos", position)),
] ],
).await )
.await
}) })
.await .await
.unwrap(); .unwrap();