Fix filename generator

This commit is contained in:
2022-12-16 23:57:29 +01:00
parent 7b7dc33070
commit 4a606c67dc

View File

@@ -34,18 +34,21 @@ pub fn get_filename_by_book(book: &BookWithRemote, file_type: &str, force_zip: b
file_type.to_string() file_type.to_string()
}; };
filename_parts.push( if book.authors.len() != 0 {
book.authors filename_parts.push(
.clone() book.authors
.into_iter() .clone()
.map(|author| get_author_short_name(author)) .into_iter()
.collect::<Vec<String>>() .map(|author| get_author_short_name(author))
.join("_-_"), .collect::<Vec<String>>()
); .join("_-_"),
);
}
filename_parts.push(book.title.trim().to_string()); filename_parts.push(book.title.trim().to_string());
let transliterator = Transliterator::new(gost779b_ru()); let transliterator = Transliterator::new(gost779b_ru());
let mut filename_without_type = transliterator.convert(&filename_parts.join(""), false); let mut filename_without_type = transliterator.convert(&filename_parts.join("_"), false);
for char in "(),….!\"?»«':".get(..) { for char in "(),….!\"?»«':".get(..) {
filename_without_type = filename_without_type.replace(char, ""); filename_without_type = filename_without_type.replace(char, "");