From fc2f200ee553779bfc9bd9c0ef319dcea86f80be Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 23 May 2022 22:19:13 +0200 Subject: [PATCH] Also pass the backend to the download handler --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9ee9892..0460864 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,8 @@ async fn feed(username: &str, config: &State) -> Option { let slug = cloudcast.slug; let mut url = Url::parse(&config.url).unwrap(); url.set_path(&format!("{}/download", &url.path()[1..])); - url.query_pairs_mut().append_pair("url", &cloudcast.url); + url.query_pairs_mut().append_pair("backend", "mixcloud"); + url.query_pairs_mut().append_pair("id", &cloudcast.key); let description = format!("Taken from Mixcloud: <{}>", cloudcast.url); let keywords = cloudcast .tags @@ -126,8 +127,8 @@ async fn feed(username: &str, config: &State) -> Option { } /// Retrieves a download using youtube-dl. -#[get("/?")] -pub(crate) async fn download(url: &str) -> Option { +#[get("/?&")] +pub(crate) async fn download(backend: &str, url: &str) -> Option { let parsed_url = Url::parse(url).ok()?; let mut cmd = Command::new("youtube-dl"); cmd.args(&["--output", "-"]) @@ -148,6 +149,7 @@ pub(crate) async fn download(url: &str) -> Option { Some(ReaderStream::one(stdout)) } + /// Sets up Rocket. pub fn setup() -> Rocket { rocket::build()