mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-25 11:48:37 -06:00
Added support for multiple directors
This commit is contained in:
parent
1a83f88c0b
commit
5a4d7d0e1d
1 changed files with 9 additions and 2 deletions
|
@ -70,9 +70,16 @@ pub async fn process_file(
|
|||
let credits_reply = credits_search.execute(tmdb).await;
|
||||
if credits_reply.is_ok() {
|
||||
let mut crew = credits_reply.unwrap().crew;
|
||||
// Only keep the director(s)
|
||||
crew.retain(|x| x.job == *"Director");
|
||||
for person in crew {
|
||||
movie_details.director = person.person.name;
|
||||
if !crew.is_empty() {
|
||||
let directors: Vec<String> =
|
||||
crew.iter().map(|x| x.person.name.clone()).collect();
|
||||
let mut directors_text = directors.join(", ");
|
||||
if let Some(pos) = directors_text.rfind(',') {
|
||||
directors_text.replace_range(pos..pos + 2, " and ");
|
||||
}
|
||||
movie_details.director = directors_text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue