tsk-202: Make CoverArt filename random during creation #232
Generated
+1
-1
@@ -964,7 +964,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.14"
|
version = "0.3.15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.14"
|
version = "0.3.15"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
|
|
||||||
|
|||||||
+25
-6
@@ -69,18 +69,37 @@ pub mod endpoint {
|
|||||||
match crate::repo::song::get_song(&pool, &song_id).await {
|
match crate::repo::song::get_song(&pool, &song_id).await {
|
||||||
Ok(song) => {
|
Ok(song) => {
|
||||||
let directory = icarus_envy::environment::get_root_directory().await.value;
|
let directory = icarus_envy::environment::get_root_directory().await.value;
|
||||||
// TODO: Make this random and the file extension should not be hard coded
|
let file_type =
|
||||||
let filename = format!("{}-coverart.jpeg", &song.filename[..8]);
|
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||||
|
let coverart_type = if file_type.file_type
|
||||||
|
== icarus_meta::detection::coverart::constants::JPEG_TYPE
|
||||||
|
{
|
||||||
|
icarus_models::types::CoverArtType::JpegExtension
|
||||||
|
} else if file_type.file_type
|
||||||
|
== icarus_meta::detection::coverart::constants::JPG_TYPE
|
||||||
|
{
|
||||||
|
icarus_models::types::CoverArtType::JpgExtension
|
||||||
|
} else if file_type.file_type
|
||||||
|
== icarus_meta::detection::coverart::constants::PNG_TYPE
|
||||||
|
{
|
||||||
|
icarus_models::types::CoverArtType::PngExtension
|
||||||
|
} else {
|
||||||
|
response.message = String::from("Invalid CoverArt type");
|
||||||
|
return (
|
||||||
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
axum::Json(response),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
let filename =
|
||||||
|
icarus_models::coverart::generate_filename(coverart_type, true)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut coverart =
|
let mut coverart =
|
||||||
icarus_models::coverart::init::init_coverart_dir_and_filename(
|
icarus_models::coverart::init::init_coverart_dir_and_filename(
|
||||||
&directory, &filename,
|
&directory, &filename,
|
||||||
);
|
);
|
||||||
coverart.title = song.album.clone();
|
coverart.title = song.album.clone();
|
||||||
coverart.file_type =
|
coverart.file_type = file_type.file_type;
|
||||||
icarus_meta::detection::coverart::file_type_from_data(&data)
|
|
||||||
.unwrap()
|
|
||||||
.file_type;
|
|
||||||
coverart.data = data;
|
coverart.data = data;
|
||||||
|
|
||||||
match coverart.save_to_filesystem() {
|
match coverart.save_to_filesystem() {
|
||||||
|
|||||||
Reference in New Issue
Block a user