pub mod genius; pub mod lrclib; pub use genius::GeniusSource; pub use lrclib::LrcLibSource; use anyhow::{Result, anyhow}; use async_trait::async_trait; use lofty::{properties::FileProperties, tag::Tag}; use std::sync::Arc; #[async_trait] pub trait LyricsSource: Send + Sync { fn name(&self) -> &'static str; async fn fetch_lyrics( &self, tag: &Tag, properties: &FileProperties, allow_inaccurate: bool, ) -> Result; } pub async fn create_source(name: &str) -> Result> { match name { "lrclib" => Ok(Arc::new(LrcLibSource::new().await?) as Arc), "genius" => Ok(Arc::new(GeniusSource::new().await?) as Arc), _ => Err(anyhow!("Unknown source type: {}", name)), } }