Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| dc01b36771 | 
							
								
								
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| 
						 | 
					@ -3272,6 +3272,7 @@ dependencies = [
 | 
				
			||||||
 "base64",
 | 
					 "base64",
 | 
				
			||||||
 "bytes",
 | 
					 "bytes",
 | 
				
			||||||
 "encoding_rs",
 | 
					 "encoding_rs",
 | 
				
			||||||
 | 
					 "futures-channel",
 | 
				
			||||||
 "futures-core",
 | 
					 "futures-core",
 | 
				
			||||||
 "futures-util",
 | 
					 "futures-util",
 | 
				
			||||||
 "h2",
 | 
					 "h2",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@ libc = "0.2.153"
 | 
				
			||||||
log = "0.4.21"
 | 
					log = "0.4.21"
 | 
				
			||||||
notify-rust = "4.11.3"
 | 
					notify-rust = "4.11.3"
 | 
				
			||||||
open = "5.3.0"
 | 
					open = "5.3.0"
 | 
				
			||||||
reqwest = "0.12.3"
 | 
					reqwest = { version = "0.12.3", features = ["blocking"] }
 | 
				
			||||||
serde = { version = "1.0.197", features = ["derive"] }
 | 
					serde = { version = "1.0.197", features = ["derive"] }
 | 
				
			||||||
serde_json = "1.0.115"
 | 
					serde_json = "1.0.115"
 | 
				
			||||||
# serde_traitobject = "0.2.8"
 | 
					# serde_traitobject = "0.2.8"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										37
									
								
								src/config/downloader/links.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/config/downloader/links.rs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,37 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="windows", target_arch="x86_64"))]
 | 
				
			||||||
 | 
					pub const YTDLP: &str = "https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp_min.exe";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="linux", target_arch="x86_64"))]
 | 
				
			||||||
 | 
					pub const YTDLP: &str = "https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp_linux";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="linux", target_arch="aarch64"))]
 | 
				
			||||||
 | 
					pub const YTDLP: &str = "https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp_linux_aarch64";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="windows", target_arch="x86_64"))]
 | 
				
			||||||
 | 
					pub const SPOTDL: &str = "https://github.com/spotDL/spotify-downloader/releases/download/v4.2.8/spotdl-4.2.8-win32.exe";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="linux", target_arch="x86_64"))]
 | 
				
			||||||
 | 
					pub const SPOTDL: &str = "https://github.com/spotDL/spotify-downloader/releases/download/v4.2.8/spotdl-4.2.8-linux";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="linux", target_arch="aarch64"))]
 | 
				
			||||||
 | 
					pub const SPOTDL: &str = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="windows", target_arch="x86_64"))]
 | 
				
			||||||
 | 
					pub const FFMPEG: &str = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="linux", target_arch="x86_64"))]
 | 
				
			||||||
 | 
					pub const FFMPEG: &str = "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(all(target_os="linux", target_arch="aarch64"))]
 | 
				
			||||||
 | 
					pub const FFMPEG: &str = "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(not(any(
 | 
				
			||||||
 | 
					    all(target_os="windows", target_arch="x86_64"),
 | 
				
			||||||
 | 
					    all(target_os="linux", target_arch="x86_64"),
 | 
				
			||||||
 | 
					    all(target_os="linux", target_arch="aarch64"),
 | 
				
			||||||
 | 
					)))]
 | 
				
			||||||
 | 
					compile_error!("Target and or Architecture is not supported");
 | 
				
			||||||
							
								
								
									
										111
									
								
								src/config/downloader/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								src/config/downloader/mod.rs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,111 @@
 | 
				
			||||||
 | 
					use std::path::{Path, PathBuf};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use crate::constants::EXEC_EXT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mod links;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub struct DepDownloader {
 | 
				
			||||||
 | 
					    ytdlp: PathBuf,
 | 
				
			||||||
 | 
					    spotdl: PathBuf,
 | 
				
			||||||
 | 
					    ffmpeg: PathBuf,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl DepDownloader {
 | 
				
			||||||
 | 
					    pub fn new() -> anyhow::Result<Self> {
 | 
				
			||||||
 | 
					        if !Path::new(".dep").exists() {
 | 
				
			||||||
 | 
					            std::fs::create_dir(".dep")?; 
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        let ytdlp = Self::download_ytdlp()?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        todo!()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn download_ytdlp() -> anyhow::Result<PathBuf> {
 | 
				
			||||||
 | 
					        if let Some(p) = crate::util::is_program_in_path("yt-dlp") {
 | 
				
			||||||
 | 
					            return Ok(p); // Already exists on pc
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        let mut fp = PathBuf::new();
 | 
				
			||||||
 | 
					        fp.push(".dep");
 | 
				
			||||||
 | 
					        fp.push("yt-dlp");
 | 
				
			||||||
 | 
					        fp.set_extension(EXEC_EXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if fp.exists() {
 | 
				
			||||||
 | 
					            return Ok(fp);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        let mut f = std::fs::OpenOptions::new()
 | 
				
			||||||
 | 
					            .create_new(true)
 | 
				
			||||||
 | 
					            .write(true)
 | 
				
			||||||
 | 
					            .open(&fp)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut req = reqwest::blocking::get(links::YTDLP)?;
 | 
				
			||||||
 | 
					        req.copy_to(&mut f)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Ok(fp)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn download_spotdl() -> anyhow::Result<PathBuf> {
 | 
				
			||||||
 | 
					        if let Some(p) = crate::util::is_program_in_path("spotdl") {
 | 
				
			||||||
 | 
					            return Ok(p); // already exists on pc
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        let mut fp = PathBuf::new();
 | 
				
			||||||
 | 
					        fp.push(".dep");
 | 
				
			||||||
 | 
					        fp.push("spotdl");
 | 
				
			||||||
 | 
					        fp.set_extension(EXEC_EXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if fp.exists() {
 | 
				
			||||||
 | 
					            return Ok(fp);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if links::SPOTDL.is_empty() {
 | 
				
			||||||
 | 
					            log::error!("spotdl doesnt support this architecture (probably aarch64)");
 | 
				
			||||||
 | 
					            log::error!("please install it manually, if you have installed it, make sure its accessible in path");
 | 
				
			||||||
 | 
					            anyhow::bail!("");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut f = std::fs::OpenOptions::new()
 | 
				
			||||||
 | 
					            .create_new(true)
 | 
				
			||||||
 | 
					            .write(true)
 | 
				
			||||||
 | 
					            .open(&fp)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut req = reqwest::blocking::get(links::SPOTDL)?;
 | 
				
			||||||
 | 
					        req.copy_to(&mut f)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Ok(fp)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn download_ffmpeg() -> anyhow::Result<PathBuf> {
 | 
				
			||||||
 | 
					        if let Some(p) = crate::util::is_program_in_path("ffmpeg") {
 | 
				
			||||||
 | 
					            return Ok(p); // already exists on pc
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        let mut fp = PathBuf::new();
 | 
				
			||||||
 | 
					        fp.push(".dep");
 | 
				
			||||||
 | 
					        fp.push("ffmpeg");
 | 
				
			||||||
 | 
					        fp.set_extension(EXEC_EXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if fp.exists() {
 | 
				
			||||||
 | 
					            return Ok(fp);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if links::FFMPEG.is_empty() {
 | 
				
			||||||
 | 
					            log::error!("spotdl doesnt support this architecture (probably aarch64)");
 | 
				
			||||||
 | 
					            log::error!("please install it manually, if you have installed it, make sure its accessible in path");
 | 
				
			||||||
 | 
					            anyhow::bail!("");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut f = std::fs::OpenOptions::new()
 | 
				
			||||||
 | 
					            .create_new(true)
 | 
				
			||||||
 | 
					            .write(true)
 | 
				
			||||||
 | 
					            .open(&fp)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut req = reqwest::blocking::get(links::FFMPEG)?;
 | 
				
			||||||
 | 
					        req.copy_to(&mut f)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Ok(fp)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,10 @@
 | 
				
			||||||
pub mod cli;
 | 
					pub mod cli;
 | 
				
			||||||
 | 
					pub mod downloader;
 | 
				
			||||||
use std::path::PathBuf;
 | 
					use std::path::PathBuf;
 | 
				
			||||||
 | 
					 | 
				
			||||||
use clap::Parser;
 | 
					use clap::Parser;
 | 
				
			||||||
use serde::{Deserialize, Serialize};
 | 
					use serde::{Deserialize, Serialize};
 | 
				
			||||||
use anyhow::Result;
 | 
					use anyhow::Result;
 | 
				
			||||||
use crate::util::{self, isatty};
 | 
					use crate::util::{self, isatty};
 | 
				
			||||||
 | 
					 | 
				
			||||||
use self::cli::CliArgs;
 | 
					use self::cli::CliArgs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// const YTDLP_DL_URL: &'static str = "https://github.com/yt-dlp/yt-dlp/archive/refs/heads/master.zip";
 | 
					// const YTDLP_DL_URL: &'static str = "https://github.com/yt-dlp/yt-dlp/archive/refs/heads/master.zip";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user