mirror of
				https://github.com/ayabusa/Rusty-slicer.git
				synced 2025-11-04 01:57:16 +00:00 
			
		
		
		
	added file format support
This commit is contained in:
		@@ -35,7 +35,7 @@ async fn select_folder_button(app: tauri::AppHandle) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[tauri::command]
 | 
					#[tauri::command]
 | 
				
			||||||
async fn slice_button(app: tauri::AppHandle, chapter: String){
 | 
					async fn slice_button(app: tauri::AppHandle, chapter: String, fileformat: String){
 | 
				
			||||||
    // Try to format the chapters and panic if it was not able to
 | 
					    // Try to format the chapters and panic if it was not able to
 | 
				
			||||||
    let formated_chapters = match format_chapter(&chapter) {
 | 
					    let formated_chapters = match format_chapter(&chapter) {
 | 
				
			||||||
        Ok(res) => res,
 | 
					        Ok(res) => res,
 | 
				
			||||||
@@ -63,9 +63,10 @@ async fn slice_button(app: tauri::AppHandle, chapter: String){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for i in 0..time_codes.len(){
 | 
					    for i in 0..time_codes.len(){
 | 
				
			||||||
        let args: Vec<String>;
 | 
					        let args: Vec<String>;
 | 
				
			||||||
 | 
					        // create the path to the output file
 | 
				
			||||||
        let mut output_file: PathBuf = PathBuf::from(&FOLDER_PATH.lock().unwrap().to_owned());
 | 
					        let mut output_file: PathBuf = PathBuf::from(&FOLDER_PATH.lock().unwrap().to_owned());
 | 
				
			||||||
        output_file.push(format!("{:02} - {}", i+1, title_names[i]));
 | 
					        output_file.push(format!("{:02} - {}", i+1, title_names[i]));
 | 
				
			||||||
        output_file.set_extension("mp3");
 | 
					        output_file.set_extension(&fileformat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if i+1<time_codes.len() {
 | 
					        if i+1<time_codes.len() {
 | 
				
			||||||
            args = vec!["-i".to_owned(), 
 | 
					            args = vec!["-i".to_owned(), 
 | 
				
			||||||
@@ -74,6 +75,7 @@ async fn slice_button(app: tauri::AppHandle, chapter: String){
 | 
				
			|||||||
                time_codes[i].to_owned(),
 | 
					                time_codes[i].to_owned(),
 | 
				
			||||||
                "-to".to_owned(),
 | 
					                "-to".to_owned(),
 | 
				
			||||||
                time_codes[i+1].to_owned(),
 | 
					                time_codes[i+1].to_owned(),
 | 
				
			||||||
 | 
					                "-vn".to_owned(), // no video
 | 
				
			||||||
                //format!("{:?}", output_file),
 | 
					                //format!("{:?}", output_file),
 | 
				
			||||||
                output_file.display().to_string()];
 | 
					                output_file.display().to_string()];
 | 
				
			||||||
        }else { // case for the last song
 | 
					        }else { // case for the last song
 | 
				
			||||||
@@ -81,6 +83,7 @@ async fn slice_button(app: tauri::AppHandle, chapter: String){
 | 
				
			|||||||
                FILE_PATH.lock().unwrap().to_owned(),
 | 
					                FILE_PATH.lock().unwrap().to_owned(),
 | 
				
			||||||
                "-ss".to_owned(),
 | 
					                "-ss".to_owned(),
 | 
				
			||||||
                time_codes[i].to_owned(),
 | 
					                time_codes[i].to_owned(),
 | 
				
			||||||
 | 
					                "-vn".to_owned(), // no video
 | 
				
			||||||
                //format!("{:?}", output_file),
 | 
					                //format!("{:?}", output_file),
 | 
				
			||||||
                output_file.display().to_string()];
 | 
					                output_file.display().to_string()];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,10 +41,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        <div class="select-file">
 | 
					        <div class="select-file">
 | 
				
			||||||
          <p><b> output type </b></p>
 | 
					          <p><b> output type </b></p>
 | 
				
			||||||
          <select>
 | 
					          <select id="fileFormatSelect">
 | 
				
			||||||
            <option value="mp3">mp3</option>
 | 
					            <option value="mp3">mp3 (recommended)</option>
 | 
				
			||||||
            <option value="ogg">ogg</option>
 | 
					            <option value="ogg">ogg</option>
 | 
				
			||||||
            <option value="flac">flac</option>
 | 
					            <option value="flac">flac (really long)</option>
 | 
				
			||||||
            <option value="m4a">m4a</option>
 | 
					            <option value="m4a">m4a</option>
 | 
				
			||||||
          </select>
 | 
					          </select>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ function select_folder_button_pressed(){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function slice_button_pressed(){
 | 
					function slice_button_pressed(){
 | 
				
			||||||
    invoke("slice_button", {chapter: document.getElementById("chapterList").value})
 | 
					    invoke("slice_button", {chapter: document.getElementById("chapterList").value, fileformat: document.getElementById("fileFormatSelect").value})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function about_button_pressed(){
 | 
					function about_button_pressed(){
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										147
									
								
								src/stars.scss
									
									
									
									
									
								
							
							
						
						
									
										147
									
								
								src/stars.scss
									
									
									
									
									
								
							@@ -1,147 +0,0 @@
 | 
				
			|||||||
@mixin translate50
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  -webkit-transform: translate(-50, -50%);
 | 
					 | 
				
			||||||
  -ms-transform: translate(-50, -50%);
 | 
					 | 
				
			||||||
  -o-transform: translate(-50, -50%);
 | 
					 | 
				
			||||||
  transform: translate(-50, -50%);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@mixin roundedCorners
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  -webkit-border-radius: 50%; 
 | 
					 | 
				
			||||||
  -moz-border-radius: 50%; 
 | 
					 | 
				
			||||||
  border-radius: 50%;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@mixin rotateBase
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  -webkit-transform: rotate3d(-1, 1, 0, 0deg);
 | 
					 | 
				
			||||||
  -ms-transform: rotate3d(-1, 1, 0, 0deg);
 | 
					 | 
				
			||||||
  -o-transform: rotate3d(-1, 1, 0, 0deg);
 | 
					 | 
				
			||||||
  transform: rotate3d(-1, 1, 0, 0deg);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@mixin rotateRight
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  -webkit-transform: rotate3d(-1, 1, 0, 30deg);
 | 
					 | 
				
			||||||
  -ms-transform: rotate3d(-1, 1, 0, 30deg);
 | 
					 | 
				
			||||||
  -o-transform: rotate3d(-1, 1, 0, 30deg);
 | 
					 | 
				
			||||||
  transform: rotate3d(-1, 1, 0, 30deg);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@mixin rotateLeft
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  -webkit-transform: rotate3d(-1, 1, 0, -30deg);
 | 
					 | 
				
			||||||
  -ms-transform: rotate3d(-1, 1, 0, -30deg);
 | 
					 | 
				
			||||||
  -o-transform: rotate3d(-1, 1, 0, -30deg);
 | 
					 | 
				
			||||||
  transform: rotate3d(-1, 1, 0, -30deg);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// n is number of stars generated
 | 
					 | 
				
			||||||
@function generateStars ($n)
 | 
					 | 
				
			||||||
{ 
 | 
					 | 
				
			||||||
  $value: '#{0} #{random(2000)}px #{random(2000)}px #FFF';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  @for $i from 2 through $n
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    $value: '#{$value} , #{random(2000)}px #{random(2000)}px #FFF';
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  @return unquote($value);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
$stars-small:  generateStars(700);
 | 
					 | 
				
			||||||
$stars-medium: generateStars(200);
 | 
					 | 
				
			||||||
$stars-big:    generateStars(100);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
body
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  overflow: hidden;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#stars-container
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  height: 200vh;
 | 
					 | 
				
			||||||
  width: 200%;
 | 
					 | 
				
			||||||
  background: radial-gradient(ellipse at bottom, #1B2735 0%, #191F24 100%);
 | 
					 | 
				
			||||||
  overflow: hidden;
 | 
					 | 
				
			||||||
  @include translate50;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
#stars
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  width: 1px;
 | 
					 | 
				
			||||||
  height: 1px;
 | 
					 | 
				
			||||||
  background: transparent;
 | 
					 | 
				
			||||||
  box-shadow: $stars-small;
 | 
					 | 
				
			||||||
  animation : animateStars 28.5s ease-in-out infinite;
 | 
					 | 
				
			||||||
  @include roundedCorners;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  &::after
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    content: " ";
 | 
					 | 
				
			||||||
    position: absolute;
 | 
					 | 
				
			||||||
    margin: auto;
 | 
					 | 
				
			||||||
    top: 0; left: 0; right: 0; bottom: 0;
 | 
					 | 
				
			||||||
    width: 1px;
 | 
					 | 
				
			||||||
    height: 1px;
 | 
					 | 
				
			||||||
    background: transparent;
 | 
					 | 
				
			||||||
    box-shadow: $stars-small;
 | 
					 | 
				
			||||||
    @include roundedCorners;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
#stars2
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  width: 2px;
 | 
					 | 
				
			||||||
  height: 2px;
 | 
					 | 
				
			||||||
  background: transparent;
 | 
					 | 
				
			||||||
  box-shadow: $stars-medium;
 | 
					 | 
				
			||||||
  animation : animateStars 30s ease-in-out infinite;
 | 
					 | 
				
			||||||
  @include roundedCorners;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  &::after
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    content: " ";
 | 
					 | 
				
			||||||
    position: absolute;
 | 
					 | 
				
			||||||
    margin: auto;
 | 
					 | 
				
			||||||
    top: 0; left: 0; right: 0; bottom: 0;
 | 
					 | 
				
			||||||
    width: 2px;
 | 
					 | 
				
			||||||
    height: 2px;
 | 
					 | 
				
			||||||
    background: transparent;
 | 
					 | 
				
			||||||
    box-shadow: $stars-medium;
 | 
					 | 
				
			||||||
    @include roundedCorners;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
#stars3
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  width: 3px;
 | 
					 | 
				
			||||||
  height: 3px;
 | 
					 | 
				
			||||||
  background: transparent;
 | 
					 | 
				
			||||||
  box-shadow: $stars-big;
 | 
					 | 
				
			||||||
  animation : animateStars 31.5s ease-in-out infinite;
 | 
					 | 
				
			||||||
  @include roundedCorners;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  &:after
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    content: " ";
 | 
					 | 
				
			||||||
    position: absolute;
 | 
					 | 
				
			||||||
    margin: auto;
 | 
					 | 
				
			||||||
    top: 0; left: 0; right: 0; bottom: 0;
 | 
					 | 
				
			||||||
    width: 3px;
 | 
					 | 
				
			||||||
    height: 3px;
 | 
					 | 
				
			||||||
    background: transparent;
 | 
					 | 
				
			||||||
    box-shadow: $stars-big;
 | 
					 | 
				
			||||||
    @include roundedCorners;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@keyframes animateStars
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  0%{@include rotateBase;}
 | 
					 | 
				
			||||||
  25%{@include rotateRight;}
 | 
					 | 
				
			||||||
  50%{@include rotateBase;}
 | 
					 | 
				
			||||||
  75%{@include rotateLeft;}
 | 
					 | 
				
			||||||
  100%{@include rotateBase;}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user