Compare commits

..

4 Commits

Author SHA1 Message Date
2411320522 temp redirect
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m27s
CI/CD Pipeline / deploy (push) Successful in 1m19s
2025-08-22 07:15:06 +02:00
34811c15af be lazy and just return mp3 of orf
All checks were successful
CI/CD Pipeline / test (push) Successful in 4m27s
CI/CD Pipeline / deploy (push) Successful in 5m55s
2025-08-21 22:29:53 +02:00
eebea71fca switch to morgenjournal again
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m40s
CI/CD Pipeline / deploy (push) Successful in 1m36s
2025-08-12 21:00:35 +02:00
9260d80458 use semver
All checks were successful
CI/CD Pipeline / test (push) Successful in 4m52s
CI/CD Pipeline / deploy (push) Successful in 6m0s
2025-08-12 20:41:21 +02:00
4 changed files with 47 additions and 39 deletions

View File

@@ -13,4 +13,4 @@ async-stream = "0.3"
serde_json = "1"
stream-download = "0.22"
chrono = "0.4"
tokio-cron-scheduler = "0.14.0"
tokio-cron-scheduler = "0.14"

View File

@@ -16,11 +16,11 @@ async fn get_newest_morning_journal() -> Result<String, Box<dyn std::error::Erro
for day in days.iter().rev() {
if let Some(broadcasts) = day["broadcasts"].as_array() {
for broadcast in broadcasts.iter().rev() {
//if broadcast["title"] == "Ö1 Morgenjournal" {
if broadcast["title"] == "Eröffnungskonzert Allegro Vivo"
&& let Some(href) = broadcast["href"].as_str() {
return Ok(href.into());
}
if broadcast["title"] == "Ö1 Morgenjournal"
&& let Some(href) = broadcast["href"].as_str()
{
return Ok(href.into());
}
}
}
}

View File

@@ -15,24 +15,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.route("/", get(streamer::stream_handler))
.with_state(state.clone());
let scheduler = JobScheduler::new().await.unwrap();
scheduler
.add(
Job::new_async(
"30 0 7 * * Mon,Tue,Wed,Thu,Fri,Sat",
move |_uuid, _locked| {
let state_for_task = state.clone();
Box::pin(async move {
state_for_task.check_update().await;
println!("Task executed at: {}", Utc::now());
})
},
)
.unwrap(),
)
.await
.unwrap();
scheduler.start().await.unwrap();
//let scheduler = JobScheduler::new().await.unwrap();
//scheduler
// .add(
// Job::new_async(
// "30 0 7 * * Mon,Tue,Wed,Thu,Fri,Sat",
// move |_uuid, _locked| {
// let state_for_task = state.clone();
// Box::pin(async move {
// state_for_task.check_update().await;
// println!("Task executed at: {}", Utc::now());
// })
// },
// )
// .unwrap(),
// )
// .await
// .unwrap();
//scheduler.start().await.unwrap();
println!("Streaming server running on http://localhost:3029");

View File

@@ -1,24 +1,32 @@
use crate::state::AppState;
use axum::{body::Body, extract::State, response::Response};
use axum::{
body::Body,
extract::State,
response::{Redirect, Response},
};
use player::newest_morning_journal_streaming_url;
use std::sync::Arc;
use tokio_stream::Stream;
pub async fn stream_handler(State(state): State<Arc<AppState>>) -> Response {
state.clone().check_update().await;
pub async fn stream_handler(State(state): State<Arc<AppState>>) -> Redirect {
let url = newest_morning_journal_streaming_url().await.unwrap();
Redirect::temporary(&url)
let stream = create_chunk_stream(state);
let body = Body::from_stream(stream);
//state.clone().check_update().await;
Response::builder()
.header("Content-Type", "audio/mpeg")
.header("Cache-Control", "no-cache, no-store, must-revalidate")
.header("Pragma", "no-cache")
.header("Expires", "0")
.header("Accept-Ranges", "none")
.header("Transfer-Encoding", "chunked")
.header("X-Content-Duration", "infinity")
.body(body)
.unwrap()
//let stream = create_chunk_stream(state);
//let body = Body::from_stream(stream);
//Response::builder()
// .header("Content-Type", "audio/mpeg")
// .header("Cache-Control", "no-cache, no-store, must-revalidate")
// .header("Pragma", "no-cache")
// .header("Expires", "0")
// .header("Accept-Ranges", "none")
// .header("Transfer-Encoding", "chunked")
// .header("X-Content-Duration", "infinity")
// .body(body)
// .unwrap()
}
fn create_chunk_stream(