remove need to call /new
All checks were successful
CI/CD Pipeline / test (push) Successful in 2m24s
CI/CD Pipeline / deploy (push) Successful in 2m8s

This commit is contained in:
2025-08-01 19:04:25 +02:00
parent 12d02b286d
commit 67fb02894f
6 changed files with 227 additions and 102 deletions

View File

@@ -1,28 +1,16 @@
mod downloader;
mod state;
mod streamer;
use axum::{Router, extract::State, routing::get};
use axum::{routing::get, Router};
use state::AppState;
use std::sync::Arc;
async fn new(State(state): State<Arc<AppState>>) -> &'static str {
let Ok(url) = player::newest_morning_journal_streaming_url().await else {
return "Failed getting latest url";
};
downloader::spawn_download_task(&url, state.clone()).await;
"Download started. Access / to stream the new content."
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let state = Arc::new(AppState::new());
let app = Router::new()
.route("/", get(streamer::stream_handler))
.route("/new", get(new))
.with_state(state);
println!("Streaming server running on http://localhost:3029");