the ugliest mvp

This commit is contained in:
Bel LaPointe
2023-12-27 23:04:54 -05:00
parent bf3c1af8e5
commit a7581da4d1
4 changed files with 2530 additions and 122 deletions

View File

@@ -1,26 +1,26 @@
pub mod video; pub mod video;
use std::path::Path; use std::path::Path;
pub fn analyze(file: &str) -> String { pub fn must_analyze(file: &str) -> String {
match _analyze(file) { match analyze(file) {
Ok(result) => result, Ok(result) => result,
Err(msg) => msg, Err(msg) => msg,
} }
} }
fn _analyze(file: &str) -> Result<String, String> { pub fn analyze(file: &str) -> Result<String, String> {
eprintln!("analyzing {}", file); eprintln!("analyzing {}", file);
Err(format!("not impl")) Err(format!("not impl"))
} }
pub fn clipify(file: &str) -> String { pub fn must_clipify(file: &str) -> String {
match _clipify(file) { match clipify(file) {
Ok(result) => result, Ok(result) => result,
Err(msg) => msg, Err(msg) => msg,
} }
} }
fn _clipify(file: &str) -> Result<String, String> { pub fn clipify(file: &str) -> Result<String, String> {
eprintln!("clipifying {}", file); eprintln!("clipifying {}", file);
let files = video::clipify(&file.to_string())?; let files = video::clipify(&file.to_string())?;
match files.iter().nth(0) { match files.iter().nth(0) {

2601
src/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,5 +9,6 @@ edition = "2021"
dioxus = "0.4.3" dioxus = "0.4.3"
lib = { path = "../src-lib" } lib = { path = "../src-lib" }
base64 = "0.21.5" base64 = "0.21.5"
dioxus-web = "0.4.3" #dioxus-web = "0.4.3"
#dioxus-desktop = "0.4.3" opener = "0.6.1"
dioxus-desktop = "0.4.3"

View File

@@ -6,14 +6,15 @@ use base64::{engine::general_purpose, Engine as _};
fn main() { fn main() {
// launch the dioxus app in a webview // launch the dioxus app in a webview
//dioxus_desktop::launch(App); // TODO desktop dioxus_desktop::launch(App); // TODO desktop
dioxus_web::launch(App); //dioxus_web::launch(App);
} }
// define a component that renders a div with the text "Hello, world!" // define a component that renders a div with the text "Hello, world!"
fn App(cx: Scope) -> Element { fn App(cx: Scope) -> Element {
let file = use_state(cx, String::new); let file = use_state(cx, String::new);
let analysis = use_state(cx, Vec::<Analyzed>::new); let analysis = use_state(cx, Vec::<Analyzed>::new);
let status = use_state(cx, String::new);
cx.render(rsx! { cx.render(rsx! {
header { header {
h1 { "home-video-blue-extractinator" } h1 { "home-video-blue-extractinator" }
@@ -28,7 +29,7 @@ fn App(cx: Scope) -> Element {
async move { async move {
if let Some(file_engine) = &evt.files { if let Some(file_engine) = &evt.files {
for f in &file_engine.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| { 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 { div {
analysis.get().iter().map(|a| { analysis.get().iter().map(|a| {
rsx! { rsx! {
@@ -71,8 +81,8 @@ struct Analyzed {
} }
fn analyze(file: String) -> Vec<Analyzed> { fn analyze(file: String) -> Vec<Analyzed> {
//let content_spans = lib::video::inspect(&file); // TODO desktop 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: Result<Vec<lib::video::ContentSpan>, String> = Ok(vec![lib::video::ContentSpan{start: 0.5, stop: 20.2}]);
if content_spans.is_err() { if content_spans.is_err() {
return vec![Analyzed{ return vec![Analyzed{
start: format!("<<err analyzing {}", file), start: format!("<<err analyzing {}", file),
@@ -99,8 +109,16 @@ fn analyze(file: String) -> Vec<Analyzed> {
.collect() .collect()
} }
fn clipify(file: String) { fn clipify(file: String) -> String {
eprintln!("clipify"); 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=="; const a_png: &str = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";