Compare commits
1 Commits
v0.8.0-mai
...
v0.8.1-mai
| Author | SHA1 | Date | |
|---|---|---|---|
| 02b6157e0d |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -149,7 +149,7 @@ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_models"
|
name = "icarus_models"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"josekit",
|
"josekit",
|
||||||
"rand",
|
"rand",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_models"
|
name = "icarus_models"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
description = "models used for the icarus project"
|
description = "models used for the icarus project"
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
use rand::Rng;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
const FILENAME_LENGTH: i32 = 16;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct CoverArt {
|
pub struct CoverArt {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
@@ -89,6 +92,40 @@ impl CoverArt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates filename for a CoverArt
|
||||||
|
pub fn generate_filename(typ: crate::types::CoverArtTypes, randomize: bool) -> String {
|
||||||
|
let file_extension = match typ {
|
||||||
|
crate::types::CoverArtTypes::PngExtension => {
|
||||||
|
String::from(crate::constants::file_extensions::image::PNGEXTENSION)
|
||||||
|
}
|
||||||
|
crate::types::CoverArtTypes::JpegExtension => {
|
||||||
|
String::from(crate::constants::file_extensions::image::JPEGEXTENSION)
|
||||||
|
}
|
||||||
|
crate::types::CoverArtTypes::JpgExtension => {
|
||||||
|
String::from(crate::constants::file_extensions::image::JPGEXTENSION)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if randomize {
|
||||||
|
let mut filename: String = String::new();
|
||||||
|
let some_chars: String = String::from("abcdefghij0123456789");
|
||||||
|
let some_chars_length = some_chars.len();
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
|
for _ in 0..FILENAME_LENGTH {
|
||||||
|
let index = rng.random_range(0..=some_chars_length);
|
||||||
|
let rando_char = some_chars.chars().nth(index);
|
||||||
|
|
||||||
|
if let Some(c) = rando_char {
|
||||||
|
filename.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filename + &file_extension
|
||||||
|
} else {
|
||||||
|
"track-output".to_string() + &file_extension
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod io {
|
pub mod io {
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
|
|||||||
@@ -129,14 +129,12 @@ impl Song {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a filename. In order to save a song to the filesystem, the song must have
|
/// Generates a filename. In order to save a song to the filesystem
|
||||||
/// a directory and filename
|
|
||||||
pub fn generate_filename(typ: types::MusicTypes, randomize: bool) -> String {
|
pub fn generate_filename(typ: types::MusicTypes, randomize: bool) -> String {
|
||||||
let file_extension = match typ {
|
let file_extension = match typ {
|
||||||
types::MusicTypes::DefaultMusicExtension => {
|
types::MusicTypes::DefaultMusicExtension => {
|
||||||
String::from(constants::file_extensions::audio::DEFAULTMUSICEXTENSION)
|
String::from(constants::file_extensions::audio::DEFAULTMUSICEXTENSION)
|
||||||
}
|
}
|
||||||
|
|
||||||
types::MusicTypes::WavExtension => {
|
types::MusicTypes::WavExtension => {
|
||||||
String::from(constants::file_extensions::audio::WAVEXTENSION)
|
String::from(constants::file_extensions::audio::WAVEXTENSION)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
|
#[derive(Debug)]
|
||||||
pub enum MusicTypes {
|
pub enum MusicTypes {
|
||||||
DefaultMusicExtension,
|
DefaultMusicExtension,
|
||||||
WavExtension,
|
WavExtension,
|
||||||
FlacExtension,
|
FlacExtension,
|
||||||
MPThreeExtension,
|
MPThreeExtension,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum CoverArtTypes {
|
||||||
|
PngExtension,
|
||||||
|
JpegExtension,
|
||||||
|
JpgExtension,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user