Something went wrong. Try again.
custom music scrobbler
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738use std::{collections::BTreeMap, error::Error, path::Path};
use claxon::{FlacReader, FlacReaderOptions};use rustler::SerdeTerm;use serde::Serialize;use smol_str::SmolStr;
trait ErrorCompat<T> { fn compat(self) -> Result<T, String>;}
impl<T, E: Error> ErrorCompat<T> for Result<T, E> { fn compat(self) -> Result<T, String> { self.map_err(|err| err.to_string()) }}
#[derive(Debug, Serialize)]struct Metadata { tags: BTreeMap<SmolStr, SmolStr>,}
fn flac_metadata(path: &Path) -> Result<Metadata, String> { let reader = FlacReader::open_ext( path, FlacReaderOptions { metadata_only: true, ..Default::default() }, ) .compat()?;
let tags = reader.tags().map(|(k, v)| (k.into(), v.into())).collect(); Ok(Metadata { tags })}
rustler::init!("doodle_core");