mirror of
https://github.com/neosubhamoy/pytubepp-helper.git
synced 2026-02-04 03:12:22 +05:30
(feat): added caption support with backwards compatibility
This commit is contained in:
@@ -255,10 +255,11 @@ fn install_program(icommand: String) {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn download_stream(url: String, stream: String) {
|
||||
fn download_stream(url: String, stream: String, caption: Option<String>) {
|
||||
let caption = caption.unwrap_or("none".to_string());
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
||||
let command = format!("pytubepp \"{}\" -s {} -c {}", &url, &stream, &caption);
|
||||
Command::new("cmd")
|
||||
.args(["/k", command.as_str()])
|
||||
.spawn()
|
||||
@@ -267,7 +268,7 @@ fn download_stream(url: String, stream: String) {
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
||||
let command = format!("pytubepp \"{}\" -s {} -c {}", &url, &stream, &caption);
|
||||
Command::new("gnome-terminal")
|
||||
.args(["--", "bash", "-c", command.as_str()])
|
||||
.spawn()
|
||||
@@ -276,7 +277,7 @@ fn download_stream(url: String, stream: String) {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
||||
let command = format!("pytubepp \"{}\" -s {} -c {}", &url, &stream, &caption);
|
||||
let escaped_command = command.replace("\"", "\\\"");
|
||||
|
||||
let applescript = format!(
|
||||
|
||||
@@ -26,7 +26,7 @@ function App({ children }: { children: React.ReactNode }) {
|
||||
} else if(event.payload.command === 'download-stream') {
|
||||
const startDownload = async () => {
|
||||
try {
|
||||
await invoke('download_stream', { url: event.payload.url, stream: event.payload.argument });
|
||||
await invoke('download_stream', { url: event.payload.url, stream: event.payload.argument.split(' ')[0], caption: event.payload.argument.split(' ')[1] });
|
||||
await invoke('receive_frontend_response', { response: 'Download started' });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user