]> git.ayabusa.dev Git - rusty-slicer.git/commitdiff
fixed multiple bugs, and made a few tweaks
authorayabusa <lebgpub@gmail.com>
Sun, 10 Mar 2024 09:47:57 +0000 (10:47 +0100)
committerayabusa <lebgpub@gmail.com>
Sun, 10 Mar 2024 09:47:57 +0000 (10:47 +0100)
src-tauri/src/main.rs
src-tauri/tauri.conf.json
src/event_handler.js
src/index.html

index 3dc6eebf0ee117eb606d1abd1516fc1903ca7d38..83090dee6b02b927731c5858ea38d0ee053583fb 100644 (file)
@@ -3,7 +3,10 @@
 
 use native_dialog::FileDialog;
 use tauri::{Manager, PhysicalSize, Size};
-use std::{env, io::{Error, ErrorKind}, path::PathBuf, sync::Mutex};
+use std::{env, fmt::Display, io::{Error, ErrorKind}, path::PathBuf, sync::Mutex};
+
+#[cfg(target_os = "windows")]
+use std::os::windows::process::CommandExt;
 
 #[macro_use]
 extern crate lazy_static;
@@ -53,9 +56,9 @@ async fn slice_button(app: tauri::AppHandle, chapter: String, fileformat: String
     // Try to format the chapters and panic if it was not able to
     let formated_chapters = match format_chapter(&chapter) {
         Ok(res) => res,
-        Err(_error) => {
+        Err(error) => {
             println!("error formating chapters, slicing aborted");
-            app.emit_all("backend_error", Payload { message: "formating_issue".to_owned() }).unwrap();
+            app.emit_all("formatting_error", Payload { message: error.to_string() }).unwrap();
             return;
         },
     };
@@ -149,6 +152,7 @@ fn format_chapter(chapter: &str) -> Result<(Vec<String>, Vec<String>), Error>{
 
     for l in lines.iter(){
         if l.is_empty() { break; }
+        if l.len() > 200 { return Err(Error::new(ErrorKind::Other, "Line is too big")); }
         let splited_line = l.split(" - ").collect::<Vec<&str>>();
         if splited_line.len()<2 || splited_line[1] == "" { // To avoid blank title
             return Err(Error::new(ErrorKind::Other, "No title associated with the time code")); 
@@ -208,6 +212,13 @@ fn launch_ffmpeg(app: tauri::AppHandle, args: Vec<String>) {
 
     println!("using ffmpeg binary : {}\nwith the following argument : {:?}", resource_path.display(), args);
     // launch the command
+    #[cfg(target_os = "windows")]
+    let output = std::process::Command::new(resource_path.as_os_str())
+                     .args(args)
+                     .creation_flags(0x08000000) // avoid the terminal from showing up
+                     .output()
+                     .expect("failed to execute process");
+    #[cfg(not (target_os = "windows"))]
     let output = std::process::Command::new(resource_path.as_os_str())
                      .args(args)
                      .output()
index 0d5074ef6b42949812839b10bf69cc973ace3135..aa6ab263b2889004b96ed603ac3cc6f9b47d7453 100644 (file)
@@ -24,8 +24,8 @@
         "fullscreen": false,
         "resizable": true,
         "title": "Rusty slicer",
-        "width": 400,
-        "height": 880
+        "width": 450,
+        "height": 950
       }
     ],
     "security": {
index f9555b2ba6f034a3267dce02aff8c5d97b48810c..4c0d25b5c7083789a2d361eaa54c366c599fadb6 100644 (file)
@@ -27,9 +27,11 @@ const unlistenerror = await listen('backend_error', (event) => {
       document.getElementById("folderLocation").innerHTML = "please select an output folder"
       console.log("please select an output folder");
       break;
-      case "formating_issue":
-        document.getElementById("errorLabel").innerHTML = "error: wrong chapter format. use 0:13 - my title"
-        console.log("error: wrong chapter format. use \n0:00 - first song title \n2:13 - second song title \n3:45 - third song title \n...");
-        break;
   }
-})
\ No newline at end of file
+})
+
+// listen for f0rmating issue from rust backend
+const unlistenformattinginssie = await listen('formatting_error', (event) => {
+  document.getElementById("errorLabel").innerHTML = "error: wrong chapter format. "+ event.payload.message;
+  console.log("error: wrong chapter format. \n"+event.payload.message+"\nuse \n0:00 - first song title \n2:13 - second song title \n3:45 - third song title \n...");z
+})
index 1d05135ae19a7c09f0bd226eefff437f5f156c9e..4b17d471a5015ed20762eb930f7a26387337e13b 100644 (file)
         <h3>Welcome to the Rusty slicer! <img src="assets/cat-vibe-vibe-cat.gif"></h1>
         <div class="select-file">
           <div>
-            <p><b> Input file </b></p>
+            <h4><b> Input file </b></h4>
             <p id="fileLocation"> no location choosen </p>
           </div>
           <button id="fileButton">choose file ðŸ“‚</button>
         </div>
 
         <div>
-          <textarea id="chapterList" rows="30">
-0:00 - my first song
+          <h4><b> Chapter list (timecode - song name) </b></h4>
+          <textarea id="chapterList" rows="30" cols="10000" placeholder="0:00 - my first song
 3:30 - another one
-13:37 - one more time - Daft punk</textarea>
+13:37 - one more time - Daft punk"></textarea>
           <p id="errorLabel" style="color: red;"></p>
         </div>