diff --git a/Cargo.lock b/Cargo.lock index b82e20e..44c9300 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2423,6 +2423,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "quick-xml" +version = "0.37.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.45" @@ -3333,11 +3343,15 @@ dependencies = [ "chrono", "clap", "dirs", + "hex", + "md-5", + "quick-xml", "rand 0.9.2", "reqwest", "sea-orm", "serde", "serde_json", + "serde_urlencoded", "serde_yaml", "shanty-config", "shanty-data", @@ -3351,6 +3365,7 @@ dependencies = [ "shanty-watch", "thiserror", "tokio", + "tokio-util", "tracing", "tracing-actix-web", "tracing-subscriber", diff --git a/shanty-config/src/lib.rs b/shanty-config/src/lib.rs index 353f0fb..16a51b0 100644 --- a/shanty-config/src/lib.rs +++ b/shanty-config/src/lib.rs @@ -38,6 +38,9 @@ pub struct AppConfig { #[serde(default)] pub scheduling: SchedulingConfig, + + #[serde(default)] + pub subsonic: SubsonicConfig, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -152,6 +155,26 @@ pub struct SchedulingConfig { pub monitor_interval_hours: u32, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct SubsonicConfig { + /// Whether the Subsonic API is enabled. + #[serde(default = "default_true")] + pub enabled: bool, + + /// Whether transcoding via ffmpeg is enabled. + #[serde(default = "default_true")] + pub transcoding_enabled: bool, +} + +impl Default for SubsonicConfig { + fn default() -> Self { + Self { + enabled: true, + transcoding_enabled: true, + } + } +} + impl Default for SchedulingConfig { fn default() -> Self { Self { @@ -179,6 +202,7 @@ impl Default for AppConfig { indexing: IndexingConfig::default(), metadata: MetadataConfig::default(), scheduling: SchedulingConfig::default(), + subsonic: SubsonicConfig::default(), } } } diff --git a/shanty-db b/shanty-db index 4fda907..1f983bb 160000 --- a/shanty-db +++ b/shanty-db @@ -1 +1 @@ -Subproject commit 4fda9071c7d3c20d51cf082245ad7636fbdda0af +Subproject commit 1f983bbecfc6e86945f396f6cd86ea67f0709b6f diff --git a/shanty-web b/shanty-web index abe321a..621355e 160000 --- a/shanty-web +++ b/shanty-web @@ -1 +1 @@ -Subproject commit abe321a3176bb797b107981f59b884fddb9b4c9b +Subproject commit 621355e35295c0593fb68d6708040bba5909a2dc diff --git a/src/main.rs b/src/main.rs index 20c8b85..ecba8b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,13 +131,21 @@ async fn main() -> anyhow::Result<()> { .service( actix_files::Files::new("/", static_dir.clone()) .index_file("index.html") - .prefer_utf8(true), + .prefer_utf8(true) + .guard(actix_web::guard::fn_guard(|ctx| { + !ctx.head().uri.path().starts_with("/rest") + })), ) .default_service(web::to({ let index_path = static_dir.join("index.html"); move |req: actix_web::HttpRequest| { let index_path = index_path.clone(); async move { + if req.path().starts_with("/rest") { + return Ok(actix_web::HttpResponse::NotFound() + .content_type("application/json") + .body(r#"{"subsonic-response":{"status":"failed","version":"1.16.1","error":{"code":0,"message":"Unknown endpoint"}}}"#)); + } actix_files::NamedFile::open_async(index_path) .await .map(|f| f.into_response(&req))