refactor: removing metadata package, and commented code; renaming template to soundboard.jinja
This commit is contained in:
parent
69ec048bc9
commit
7277ca0cfa
@ -11,7 +11,6 @@ axum = "0.6.18"
|
|||||||
axum-template = { version = "0.19.0", features = ["minijinja"] }
|
axum-template = { version = "0.19.0", features = ["minijinja"] }
|
||||||
cpal = "0.15.2"
|
cpal = "0.15.2"
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
# metadata = "0.1.8"
|
|
||||||
minijinja = { version = "1.0.3", features = ["loader"] }
|
minijinja = { version = "1.0.3", features = ["loader"] }
|
||||||
minimp3 = "0.5.1"
|
minimp3 = "0.5.1"
|
||||||
mp3-duration = "0.1.10"
|
mp3-duration = "0.1.10"
|
||||||
|
@ -65,7 +65,7 @@ struct TemplateContext {
|
|||||||
async fn home(engine: TemplateEngine, state: State<AppState>) -> impl axum::response::IntoResponse {
|
async fn home(engine: TemplateEngine, state: State<AppState>) -> impl axum::response::IntoResponse {
|
||||||
let clips = state.0.clone().clips; // this is not ideal.
|
let clips = state.0.clone().clips; // this is not ideal.
|
||||||
let context = TemplateContext { clips: clips };
|
let context = TemplateContext { clips: clips };
|
||||||
RenderHtml(Key("index.jinja".to_owned()), engine, context)
|
RenderHtml(Key("soundboard.jinja".to_owned()), engine, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn play_handler(
|
async fn play_handler(
|
||||||
|
@ -54,16 +54,6 @@ fn encode_filename(file_name: &str) -> String {
|
|||||||
hash_hex
|
hash_hex
|
||||||
}
|
}
|
||||||
|
|
||||||
/* // needs metadata to install ffmpeg.
|
|
||||||
fn get_sound_clip_length(file_path: &str) -> Option<u64> {
|
|
||||||
if let Ok(meta) = metadata::media_file::MediaFileMetadata::new(&std::path::Path::new(file_path))
|
|
||||||
{
|
|
||||||
return Some(meta._duration);
|
|
||||||
}
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fn get_sound_clip_length(file_path: &str) -> Option<u64> {
|
fn get_sound_clip_length(file_path: &str) -> Option<u64> {
|
||||||
let path = std::path::Path::new(file_path);
|
let path = std::path::Path::new(file_path);
|
||||||
if let Ok(duration) = mp3_duration::from_path(&path) {
|
if let Ok(duration) = mp3_duration::from_path(&path) {
|
||||||
@ -77,6 +67,7 @@ fn get_sound_clip_length(file_path: &str) -> Option<u64> {
|
|||||||
|
|
||||||
fn normalize_filename(input: &str) -> String {
|
fn normalize_filename(input: &str) -> String {
|
||||||
// List of extensions to be removed
|
// List of extensions to be removed
|
||||||
|
// TODO: this is hardcoded currently, add support to the provided list of extensions.
|
||||||
let extensions = [".mp3", ".wav", ".flac", ".ogg"];
|
let extensions = [".mp3", ".wav", ".flac", ".ogg"];
|
||||||
|
|
||||||
// Remove the extension if it matches any in the list
|
// Remove the extension if it matches any in the list
|
||||||
@ -88,7 +79,6 @@ fn normalize_filename(input: &str) -> String {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Replace all underscores with spaces
|
|
||||||
without_extension.replace("_", " ")
|
without_extension.replace("_", " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user