the ugliest mvp
parent
bf3c1af8e5
commit
a7581da4d1
|
|
@ -1,26 +1,26 @@
|
|||
pub mod video;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn analyze(file: &str) -> String {
|
||||
match _analyze(file) {
|
||||
pub fn must_analyze(file: &str) -> String {
|
||||
match analyze(file) {
|
||||
Ok(result) => result,
|
||||
Err(msg) => msg,
|
||||
}
|
||||
}
|
||||
|
||||
fn _analyze(file: &str) -> Result<String, String> {
|
||||
pub fn analyze(file: &str) -> Result<String, String> {
|
||||
eprintln!("analyzing {}", file);
|
||||
Err(format!("not impl"))
|
||||
}
|
||||
|
||||
pub fn clipify(file: &str) -> String {
|
||||
match _clipify(file) {
|
||||
pub fn must_clipify(file: &str) -> String {
|
||||
match clipify(file) {
|
||||
Ok(result) => result,
|
||||
Err(msg) => msg,
|
||||
}
|
||||
}
|
||||
|
||||
fn _clipify(file: &str) -> Result<String, String> {
|
||||
pub fn clipify(file: &str) -> Result<String, String> {
|
||||
eprintln!("clipifying {}", file);
|
||||
let files = video::clipify(&file.to_string())?;
|
||||
match files.iter().nth(0) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -9,5 +9,6 @@ edition = "2021"
|
|||
dioxus = "0.4.3"
|
||||
lib = { path = "../src-lib" }
|
||||
base64 = "0.21.5"
|
||||
dioxus-web = "0.4.3"
|
||||
#dioxus-desktop = "0.4.3"
|
||||
#dioxus-web = "0.4.3"
|
||||
opener = "0.6.1"
|
||||
dioxus-desktop = "0.4.3"
|
||||
|
|
|
|||
|
|
@ -6,14 +6,15 @@ use base64::{engine::general_purpose, Engine as _};
|
|||
|
||||
fn main() {
|
||||
// launch the dioxus app in a webview
|
||||
//dioxus_desktop::launch(App); // TODO desktop
|
||||
dioxus_web::launch(App);
|
||||
dioxus_desktop::launch(App); // TODO desktop
|
||||
//dioxus_web::launch(App);
|
||||
}
|
||||
|
||||
// define a component that renders a div with the text "Hello, world!"
|
||||
fn App(cx: Scope) -> Element {
|
||||
let file = use_state(cx, String::new);
|
||||
let analysis = use_state(cx, Vec::<Analyzed>::new);
|
||||
let status = use_state(cx, String::new);
|
||||
cx.render(rsx! {
|
||||
header {
|
||||
h1 { "home-video-blue-extractinator" }
|
||||
|
|
@ -28,7 +29,7 @@ fn App(cx: Scope) -> Element {
|
|||
async move {
|
||||
if let Some(file_engine) = &evt.files {
|
||||
for f in &file_engine.files() {
|
||||
file.set(f.clone()); // TODO swap to .path() on desktop
|
||||
file.set(f.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,9 +46,18 @@ fn App(cx: Scope) -> Element {
|
|||
}
|
||||
}}
|
||||
input { r#type: "button", value: "clipify", disabled: file.get().len() == 0, onclick: move |evt| {
|
||||
clipify(file.get().clone());
|
||||
to_owned![file];
|
||||
to_owned![status];
|
||||
async move {
|
||||
status.set(clipify(file.get().clone()));
|
||||
}
|
||||
}}
|
||||
}
|
||||
div {
|
||||
br {}
|
||||
status.get().clone()
|
||||
br {}
|
||||
}
|
||||
div {
|
||||
analysis.get().iter().map(|a| {
|
||||
rsx! {
|
||||
|
|
@ -71,8 +81,8 @@ struct Analyzed {
|
|||
}
|
||||
|
||||
fn analyze(file: String) -> Vec<Analyzed> {
|
||||
//let content_spans = lib::video::inspect(&file); // TODO desktop
|
||||
let content_spans: Result<Vec<lib::video::ContentSpan>, String> = Ok(vec![lib::video::ContentSpan{start: 0.5, stop: 20.2}]);
|
||||
let content_spans = lib::video::inspect(&file); // TODO desktop
|
||||
//let content_spans: Result<Vec<lib::video::ContentSpan>, String> = Ok(vec![lib::video::ContentSpan{start: 0.5, stop: 20.2}]);
|
||||
if content_spans.is_err() {
|
||||
return vec![Analyzed{
|
||||
start: format!("<<err analyzing {}", file),
|
||||
|
|
@ -99,8 +109,16 @@ fn analyze(file: String) -> Vec<Analyzed> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn clipify(file: String) {
|
||||
eprintln!("clipify");
|
||||
fn clipify(file: String) -> String {
|
||||
match lib::clipify(&file.to_string()) {
|
||||
Ok(path) => {
|
||||
match opener::open(path.clone()) {
|
||||
Ok(_) => path,
|
||||
Err(msg) => format!("failed to open clipify result: {}", msg),
|
||||
}
|
||||
},
|
||||
Err(msg) => msg,
|
||||
}
|
||||
}
|
||||
|
||||
const a_png: &str = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
||||
|
|
|
|||
Loading…
Reference in New Issue