initial commit
This commit is contained in:
commit
f211e9b520
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
1022
Cargo.lock
generated
Normal file
1022
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
Cargo.toml
Normal file
15
Cargo.toml
Normal file
@ -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"]
|
7
Rocket.toml
Normal file
7
Rocket.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[development]
|
||||
address = "192.168.0.96"
|
||||
port = 8000
|
||||
workers = 4
|
||||
keep_alive = 5
|
||||
log = "normal"
|
||||
limits = { forms = 32768 }
|
32
src/main.rs
Normal file
32
src/main.rs
Normal file
@ -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();
|
||||
}
|
||||
|
10
static/index.html
Normal file
10
static/index.html
Normal file
@ -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
Block a user