icarus_meta -> simeta

This commit is contained in:
2026-07-18 13:42:09 -04:00
parent 884753b996
commit f341ee94e5
6 changed files with 45 additions and 51 deletions
+8 -8
View File
@@ -70,17 +70,17 @@ pub mod endpoint {
Ok(song) => {
let directory = sienvy::environment::get_root_directory().value;
let file_type =
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
simeta::detection::coverart::file_type_from_data(&data).unwrap();
let coverart_type = if file_type.file_type
== icarus_meta::detection::coverart::constants::JPEG_TYPE
== simeta::detection::coverart::constants::JPEG_TYPE
{
simodels::types::CoverArtType::JpegExtension
} else if file_type.file_type
== icarus_meta::detection::coverart::constants::JPG_TYPE
== simeta::detection::coverart::constants::JPG_TYPE
{
simodels::types::CoverArtType::JpgExtension
} else if file_type.file_type
== icarus_meta::detection::coverart::constants::PNG_TYPE
== simeta::detection::coverart::constants::PNG_TYPE
{
simodels::types::CoverArtType::PngExtension
} else {
@@ -201,18 +201,18 @@ pub mod endpoint {
Ok(coverart) => match simodels::coverart::io::to_data(&coverart) {
Ok(data) => {
let (file_type, img_type) =
match icarus_meta::detection::coverart::file_type_from_data(&data) {
match simeta::detection::coverart::file_type_from_data(&data) {
Ok(file_type) => {
if file_type.file_type
== icarus_meta::detection::coverart::constants::JPEG_TYPE
== simeta::detection::coverart::constants::JPEG_TYPE
{
(file_type, simodels::types::CoverArtType::JpegExtension)
} else if file_type.file_type
== icarus_meta::detection::coverart::constants::JPG_TYPE
== simeta::detection::coverart::constants::JPG_TYPE
{
(file_type, simodels::types::CoverArtType::JpgExtension)
} else if file_type.file_type
== icarus_meta::detection::coverart::constants::PNG_TYPE
== simeta::detection::coverart::constants::PNG_TYPE
{
(file_type, simodels::types::CoverArtType::PngExtension)
} else {
+18 -24
View File
@@ -102,9 +102,9 @@ pub mod response {
mod helper {
pub fn is_coverart_file_type_valid(file_type: &String) -> bool {
let valid_file_types = vec![
String::from(icarus_meta::detection::coverart::constants::JPEG_TYPE),
String::from(icarus_meta::detection::coverart::constants::JPG_TYPE),
String::from(icarus_meta::detection::coverart::constants::PNG_TYPE),
String::from(simeta::detection::coverart::constants::JPEG_TYPE),
String::from(simeta::detection::coverart::constants::JPG_TYPE),
String::from(simeta::detection::coverart::constants::PNG_TYPE),
];
for valid_file_type in valid_file_types {
@@ -150,18 +150,17 @@ pub mod endpoint {
let content_type = field.content_type().unwrap().to_string();
let data = field.bytes().await.unwrap();
let raw_data = data.to_vec();
let file_type =
match icarus_meta::detection::coverart::file_type_from_data(&raw_data) {
Ok(file_type) => file_type,
Err(err) => {
eprintln!("Error: {err:?}");
response.message = err.to_string();
return (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
);
}
};
let file_type = match simeta::detection::coverart::file_type_from_data(&raw_data) {
Ok(file_type) => file_type,
Err(err) => {
eprintln!("Error: {err:?}");
response.message = err.to_string();
return (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
);
}
};
if !super::helper::is_coverart_file_type_valid(&file_type.file_type) {
response.message = format!("CoverArt file type not supported: {file_type:?}");
@@ -318,8 +317,7 @@ pub mod endpoint {
) -> (axum::http::StatusCode, axum::response::Response) {
match repo::coverart::get_coverart_queue_data_with_id(&pool, &id).await {
Ok(data) => {
let file_type =
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
let file_type = simeta::detection::coverart::file_type_from_data(&data).unwrap();
let bytes = axum::body::Bytes::from(data);
let mut response = bytes.into_response();
let headers = response.headers_mut();
@@ -329,16 +327,12 @@ pub mod endpoint {
);
let coverart_type = if file_type.file_type
== icarus_meta::detection::coverart::constants::JPEG_TYPE
== simeta::detection::coverart::constants::JPEG_TYPE
{
simodels::types::CoverArtType::JpegExtension
} else if file_type.file_type
== icarus_meta::detection::coverart::constants::JPG_TYPE
{
} else if file_type.file_type == simeta::detection::coverart::constants::JPG_TYPE {
simodels::types::CoverArtType::JpgExtension
} else if file_type.file_type
== icarus_meta::detection::coverart::constants::PNG_TYPE
{
} else if file_type.file_type == simeta::detection::coverart::constants::PNG_TYPE {
simodels::types::CoverArtType::PngExtension
} else {
return (
+2 -2
View File
@@ -97,9 +97,9 @@ pub mod response {
}
pub async fn is_song_valid(data: &[u8]) -> Result<bool, std::io::Error> {
match icarus_meta::detection::song::file_type_from_data(data) {
match simeta::detection::song::file_type_from_data(data) {
Ok(file_type) => {
if file_type.file_type == icarus_meta::detection::song::constants::FLAC_TYPE {
if file_type.file_type == simeta::detection::song::constants::FLAC_TYPE {
Ok(true)
} else {
Ok(false)
+4 -4
View File
@@ -149,8 +149,8 @@ mod tests {
pub fn token_fields() -> (String, String, String) {
(
String::from("What a twist!"),
String::from("icarus_test"),
String::from("icarus"),
String::from("soaricarus_test"),
String::from("soaricarus"),
)
}
@@ -289,7 +289,7 @@ mod tests {
.uri(uri)
.header(
axum::http::header::CONTENT_TYPE,
icarus_meta::detection::song::constants::mime::FLAC,
simeta::detection::song::constants::mime::FLAC,
)
.header(
axum::http::header::AUTHORIZATION,
@@ -306,7 +306,7 @@ mod tests {
) -> Result<axum::response::Response, std::convert::Infallible> {
let mut form = MultipartForm::default();
let _ = form.add_file(
icarus_meta::detection::coverart::constants::JPEG_TYPE,
simeta::detection::coverart::constants::JPEG_TYPE,
"tests/I/Coverart-1.jpg",
);