Skip to content

Commit e147a56

Browse files
Jacob-TateIgnisDa
andauthored
manga_updates includes the volume count and publication status. (#937)
* manga_updates includes the volume count and publication status. Updated to include in metadata. * chore(backend): minor changes * chore(backend): apply clippy lints --------- Co-authored-by: Diptesh Choudhuri <ignisda2001@gmail.com>
1 parent 438d7cc commit e147a56

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

apps/backend/src/providers/manga_updates.rs

+23-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,24 @@ struct MetadataSearchResponse<T> {
146146
results: Vec<T>,
147147
}
148148

149+
impl MangaUpdatesService {
150+
fn extract_status(&self, input: &str) -> (Option<i32>, Option<String>) {
151+
let first_part = input.split("<BR>").next().unwrap_or("").trim();
152+
let parts: Vec<&str> = first_part.split_whitespace().collect();
153+
154+
let volumes = parts.first().and_then(|s| s.parse::<i32>().ok());
155+
let status = parts.get(2).and_then(|&s| {
156+
if s.starts_with('(') && s.ends_with(')') {
157+
Some(s[1..s.len() - 1].to_string())
158+
} else {
159+
None
160+
}
161+
});
162+
163+
(volumes, status)
164+
}
165+
}
166+
149167
#[async_trait]
150168
impl MediaProvider for MangaUpdatesService {
151169
async fn people_search(
@@ -311,14 +329,17 @@ impl MediaProvider for MangaUpdatesService {
311329
});
312330
}
313331
}
332+
333+
let (volumes, status) = self.extract_status(&data.status.clone().unwrap());
334+
314335
Ok(MediaDetails {
315336
identifier: data.series_id.unwrap().to_string(),
316337
title: data.title.unwrap(),
317338
description: data.description,
318339
source: MediaSource::MangaUpdates,
319340
lot: MediaLot::Manga,
320341
people,
321-
production_status: data.status,
342+
production_status: status,
322343
genres: data
323344
.genres
324345
.unwrap_or_default()
@@ -338,8 +359,8 @@ impl MediaProvider for MangaUpdatesService {
338359
publish_year: data.year.and_then(|y| y.parse().ok()),
339360
manga_specifics: Some(MangaSpecifics {
340361
chapters: data.latest_chapter,
341-
volumes: None,
342362
url: data.url,
363+
volumes,
343364
}),
344365
suggestions,
345366
provider_rating: data.bayesian_rating,

0 commit comments

Comments
 (0)