! Finalizing video fetch endpoint

With this the backend is officially at an MVP stage and now requires polishing
Proper data streaming for larger clips is basically required
for a really good backend(especially async streaming)
and some better css for the video player
This commit is contained in:
shockrah 2021-10-16 18:14:04 -07:00
parent d6b076970f
commit c53d9a293e
5 changed files with 15 additions and 12 deletions

View File

@ -9,7 +9,6 @@ edition = "2018"
rocket = { version = "0.5.0-rc.1", features = [ "json" ] }
tokio = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
base64 = "0.13.0"
[dependencies.rocket_dyn_templates]

View File

@ -37,9 +37,6 @@ pub async fn category(cat: PathBuf) -> Template {
#[get("/clip/<cat>/<file_base>")]
pub async fn video(cat: PathBuf, file_base: PathBuf) -> Template {
// NOTE: the "file name" does not include the
println!("{:?}, {:?}", cat, file_base);
let mut h: HashMap<&'static str, &str> = HashMap::new();
let cat = cat.to_string_lossy();
@ -59,6 +56,8 @@ pub async fn video(cat: PathBuf, file_base: PathBuf) -> Template {
let thumbnail = format!("/thumbnail/{}/{}", cat, file);
h.insert("ogimg", &thumbnail);
let clip_url = format!("/video/{}/{}", &cat, &file);
h.insert("clip_url", &clip_url);
return Template::render("video", &h);
}

View File

@ -62,7 +62,7 @@ pub fn list(cat: PathBuf) -> Option<Json<Vec<VideoPreview>>> {
}
#[get("/clip/<cat>/<file>")]
#[get("/<cat>/<file>")]
pub async fn get_video(cat: PathBuf, file: PathBuf) -> Option<NamedFile> {
let clips_dir = get_clips_dir();
let path = Path::new(&clips_dir).join(cat).join(file);

View File

@ -38,6 +38,9 @@ a {
background: #191818;
border-radius: 1em;
}
video {
max-width: 100%;
}
.pure-form {
text-align: center;

View File

@ -19,12 +19,14 @@
{% endif %}
</head>
<body>
<div id="layout">
<div class="content">
<h1></h1>
<div class="video-gallery" id="main-container">
</div>
</div>
</div>
<div id="layout">
<div class="content">
<h1>{{title}}</h1>
<video width="1280" height="720" controls>
<source src="{{clip_url}}" type="">
wtf get a better browser 1d10t
</video>
</div>
</div>
</body>
</html>