analysis with screenshots is k WOO
parent
01887f061a
commit
5033c4016f
File diff suppressed because it is too large
Load Diff
|
|
@ -7,7 +7,6 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
dioxus = "0.4.3"
|
||||
rfd = "0.12.1"
|
||||
lib = { path = "../src-lib" }
|
||||
base64 = "0.21.5"
|
||||
#dioxus-web = "0.4.3"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
#![allow(non_snake_case)]
|
||||
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
|
||||
use dioxus::prelude::*;
|
||||
use rfd::AsyncFileDialog;
|
||||
use lib;
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
|
||||
fn main() {
|
||||
// launch the dioxus app in a webview
|
||||
// dioxus_desktop::launch(App);
|
||||
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!"
|
||||
|
|
@ -23,33 +22,32 @@ fn App(cx: Scope) -> Element {
|
|||
rsx! {
|
||||
div {
|
||||
input {
|
||||
r#type: "button",
|
||||
value: "pick file", onclick: move |evt| {
|
||||
r#type: "file",
|
||||
onchange: |evt| {
|
||||
to_owned![file];
|
||||
async move {
|
||||
match AsyncFileDialog::new()
|
||||
.pick_file()
|
||||
.await {
|
||||
Some(f) => {
|
||||
//file.set(f.file_name().clone()); // TODO swap to .path() on desktop
|
||||
file.set(f.path().clone()); // TODO swap to .path() on desktop
|
||||
},
|
||||
None => { file.set(format!("<<failed to pick a file>>")); },
|
||||
};
|
||||
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.path().clone()); // TODO swap to .path() on desktop
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
p { file.get().clone() }
|
||||
}
|
||||
div {
|
||||
input { r#type: "button", value: "analyze", onclick: move |evt| {
|
||||
input { r#type: "button", value: "analyze", disabled: file.get().len() == 0, onclick: move |evt| {
|
||||
to_owned![file];
|
||||
to_owned![analysis];
|
||||
async move {
|
||||
analysis.set(analyze(file.get().clone()));
|
||||
}
|
||||
}}
|
||||
input { r#type: "button", value: "clipify", onclick: move |evt| { clipify(file.get().clone()); } }
|
||||
input { r#type: "button", value: "clipify", disabled: file.get().len() == 0, onclick: move |evt| {
|
||||
clipify(file.get().clone());
|
||||
}}
|
||||
}
|
||||
div {
|
||||
analysis.get().iter().map(|a| {
|
||||
|
|
@ -86,7 +84,6 @@ fn analyze(file: String) -> Vec<Analyzed> {
|
|||
let content_spans = content_spans.unwrap();
|
||||
head.iter().chain(content_spans.iter())
|
||||
.map(|content_span| {
|
||||
eprintln!("analyze");
|
||||
let mut result = Analyzed{
|
||||
start: content_span.start.to_string(),
|
||||
stop: content_span.stop.to_string(),
|
||||
|
|
@ -94,7 +91,7 @@ fn analyze(file: String) -> Vec<Analyzed> {
|
|||
};
|
||||
match lib::video::screenshot_png(
|
||||
&file,
|
||||
content_span.start,
|
||||
(content_span.start + content_span.stop) / 2.0,
|
||||
) {
|
||||
Ok(png) => { result.screenshot = general_purpose::STANDARD.encode(&png); },
|
||||
Err(msg) => { result.stop = format!("{} <<failed to screenshot {}: {}>>", result.stop, file, msg); },
|
||||
|
|
|
|||
Loading…
Reference in New Issue