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
This commit is contained in:
@@ -330,29 +330,14 @@ impl Anime2UseCases {
|
|||||||
self.cache()
|
self.cache()
|
||||||
.get_or_set(&cache_key, DETAIL_CACHE_TTL, || async {
|
.get_or_set(&cache_key, DETAIL_CACHE_TTL, || async {
|
||||||
let detail_url = self.repository.detail_url(&slug);
|
let detail_url = self.repository.detail_url(&slug);
|
||||||
let image_url = self.repository.detail_image_url(&slug);
|
let detail_html = self
|
||||||
let (detail_html, image_html) = tokio::join!(
|
.repository
|
||||||
self.repository.fetch_html(&detail_url),
|
.fetch_html(&detail_url)
|
||||||
self.repository.fetch_html(&image_url)
|
.await
|
||||||
);
|
.map_err(|e| e.to_string())?;
|
||||||
let detail_html = detail_html.map_err(|e| e.to_string())?;
|
|
||||||
let image_html = image_html.ok();
|
|
||||||
|
|
||||||
let mut data = tokio::task::spawn_blocking(move || {
|
let mut data = tokio::task::spawn_blocking(move || {
|
||||||
let mut data =
|
parser::parse_anime_detail(&detail_html).map_err(|e| e.to_string())
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())??;
|
.map_err(|e| e.to_string())??;
|
||||||
@@ -372,7 +357,6 @@ impl Anime2UseCases {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Recommendation in modules::anime2::types implements HasPoster
|
|
||||||
apply_cached_posters(
|
apply_cached_posters(
|
||||||
&mut data.recommendations,
|
&mut data.recommendations,
|
||||||
self.db.clone(),
|
self.db.clone(),
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ use crate::domain::error::ScrapingError;
|
|||||||
use crate::domain::repository::ScrapingRepository;
|
use crate::domain::repository::ScrapingRepository;
|
||||||
use crate::infrastructure::scraping::proxy_fetch::fetch_with_proxy_only;
|
use crate::infrastructure::scraping::proxy_fetch::fetch_with_proxy_only;
|
||||||
|
|
||||||
const BASE_URL: &str = "https://alqanime.si";
|
const BASE_URL: &str = "https://alqanime.net";
|
||||||
const BASE_DETAIL_URL: &str = "https://alqanime.net";
|
|
||||||
|
|
||||||
pub struct AlqanimeRepository;
|
pub struct AlqanimeRepository;
|
||||||
|
|
||||||
@@ -38,11 +37,7 @@ impl AlqanimeRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn detail_url(&self, slug: &str) -> String {
|
pub fn detail_url(&self, slug: &str) -> String {
|
||||||
format!("{}/{}/", BASE_DETAIL_URL, slug)
|
format!("{}/{}/", BASE_URL, slug)
|
||||||
}
|
|
||||||
|
|
||||||
pub fn detail_image_url(&self, slug: &str) -> String {
|
|
||||||
format!("{}/anime/{}/", BASE_URL, slug)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn genre_page_url(&self, genre_slug: &str, page: u32) -> String {
|
pub fn genre_page_url(&self, genre_slug: &str, page: u32) -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user