commit
f211e9b520
@ -0,0 +1 @@ |
||||
/target |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@ |
||||
[package] |
||||
name = "mpv_send" |
||||
version = "0.1.0" |
||||
authors = ["CptCaptain <nilskoch@posteo.de>"] |
||||
edition = "2018" |
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||
|
||||
[dependencies] |
||||
rocket = "0.4.5" |
||||
|
||||
[dependencies.rocket_contrib] |
||||
version = "0.4.5" |
||||
default-features = false |
||||
features = ["serve"] |
@ -0,0 +1,7 @@ |
||||
[development] |
||||
address = "192.168.0.96" |
||||
port = 8000 |
||||
workers = 4 |
||||
keep_alive = 5 |
||||
log = "normal" |
||||
limits = { forms = 32768 } |
@ -0,0 +1,32 @@ |
||||
#![feature(proc_macro_hygiene, decl_macro)] |
||||
|
||||
#[macro_use] extern crate rocket; |
||||
|
||||
use std::process::Command; |
||||
use rocket::request::Form; |
||||
use rocket_contrib::serve::StaticFiles; |
||||
use rocket::response::Redirect; |
||||
|
||||
#[derive(FromForm)] |
||||
struct Video { |
||||
link: String, |
||||
} |
||||
|
||||
#[post("/new", data = "<video>")] |
||||
fn new(video: Form<Video>) -> Redirect { |
||||
// let mpv_script_path = "/home/hans/mpv_send.sh";
|
||||
if video.link.starts_with("https://"){ |
||||
// Command::new(mpv_script_path).arg(&video.link).output().expect("Failed to execute command");
|
||||
// Command::new(mpv_script_path).arg(&video.link).output().expect("Failed to execute command");
|
||||
Command::new("/bin/env").args(&["bash", "-c", &format!("mpv {link}", link=&video.link).to_string()]).output().expect("Failed to execute command"); |
||||
} |
||||
Redirect::to("/") |
||||
} |
||||
|
||||
fn main() { |
||||
rocket::ignite() |
||||
.mount("/", routes![new]) |
||||
.mount("/", StaticFiles::from("static")) |
||||
.launch(); |
||||
} |
||||
|
@ -0,0 +1,10 @@ |
||||
<html> |
||||
<head> |
||||
</head> |
||||
<body> |
||||
<form action="/new" method="POST"> |
||||
<input type="text" id="link" name="link" value=""/> |
||||
<input type="submit"/> |
||||
</form> |
||||
</body> |
||||
<html> |
Loading…
Reference in new issue