From c035601a366691e3841c11a49f541bae3cb0289f Mon Sep 17 00:00:00 2001 From: asepharyana Date: Wed, 22 Jul 2026 13:41:03 +0700 Subject: [PATCH] feat: migrate anime2 scraper from alqanime.si to alqanime.net - Change BASE_URL from https://alqanime.si to https://alqanime.net - Remove BASE_DETAIL_URL (now same as BASE_URL) - Remove detail_image_url method (no longer needed) - Simplify detail() use case: remove dual-fetch logic that merged results from both domains (now same URL) - Fix CLAUDE.md stale comment --- src/application/anime2/use_cases.rs | 28 +++++------------------ src/infrastructure/repository/alqanime.rs | 9 ++------ 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/application/anime2/use_cases.rs b/src/application/anime2/use_cases.rs index 83e5832..c7f6a86 100644 --- a/src/application/anime2/use_cases.rs +++ b/src/application/anime2/use_cases.rs @@ -330,29 +330,14 @@ impl Anime2UseCases { self.cache() .get_or_set(&cache_key, DETAIL_CACHE_TTL, || async { let detail_url = self.repository.detail_url(&slug); - let image_url = self.repository.detail_image_url(&slug); - let (detail_html, image_html) = tokio::join!( - self.repository.fetch_html(&detail_url), - self.repository.fetch_html(&image_url) - ); - let detail_html = detail_html.map_err(|e| e.to_string())?; - let image_html = image_html.ok(); + let detail_html = self + .repository + .fetch_html(&detail_url) + .await + .map_err(|e| e.to_string())?; let mut data = tokio::task::spawn_blocking(move || { - let mut data = - parser::parse_anime_detail(&detail_html).map_err(|e| e.to_string())?; - if let Some(image_html) = image_html { - if let Ok(image_data) = parser::parse_anime_detail(&image_html) { - if !image_data.poster.is_empty() { - data.poster = image_data.poster; - } - if !image_data.poster2.is_empty() { - data.poster2 = image_data.poster2; - } - data.recommendations = image_data.recommendations; - } - } - Ok::<_, String>(data) + parser::parse_anime_detail(&detail_html).map_err(|e| e.to_string()) }) .await .map_err(|e| e.to_string())??; @@ -372,7 +357,6 @@ impl Anime2UseCases { ) .await; - // Recommendation in modules::anime2::types implements HasPoster apply_cached_posters( &mut data.recommendations, self.db.clone(), diff --git a/src/infrastructure/repository/alqanime.rs b/src/infrastructure/repository/alqanime.rs index 030cd95..8627ad8 100644 --- a/src/infrastructure/repository/alqanime.rs +++ b/src/infrastructure/repository/alqanime.rs @@ -7,8 +7,7 @@ use crate::domain::error::ScrapingError; use crate::domain::repository::ScrapingRepository; use crate::infrastructure::scraping::proxy_fetch::fetch_with_proxy_only; -const BASE_URL: &str = "https://alqanime.si"; -const BASE_DETAIL_URL: &str = "https://alqanime.net"; +const BASE_URL: &str = "https://alqanime.net"; pub struct AlqanimeRepository; @@ -38,11 +37,7 @@ impl AlqanimeRepository { } pub fn detail_url(&self, slug: &str) -> String { - format!("{}/{}/", BASE_DETAIL_URL, slug) - } - - pub fn detail_image_url(&self, slug: &str) -> String { - format!("{}/anime/{}/", BASE_URL, slug) + format!("{}/{}/", BASE_URL, slug) } pub fn genre_page_url(&self, genre_slug: &str, page: u32) -> String {