mirror of
https://github.com/neosubhamoy/pytubepp-helper.git
synced 2026-02-04 11:22: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]
|
#[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")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
let command = format!("pytubepp \"{}\" -s {} -c {}", &url, &stream, &caption);
|
||||||
Command::new("cmd")
|
Command::new("cmd")
|
||||||
.args(["/k", command.as_str()])
|
.args(["/k", command.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
@@ -267,7 +268,7 @@ fn download_stream(url: String, stream: String) {
|
|||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let command = format!("pytubepp \"{}\" -s {}", &url, &stream);
|
let command = format!("pytubepp \"{}\" -s {} -c {}", &url, &stream, &caption);
|
||||||
Command::new("gnome-terminal")
|
Command::new("gnome-terminal")
|
||||||
.args(["--", "bash", "-c", command.as_str()])
|
.args(["--", "bash", "-c", command.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
@@ -276,7 +277,7 @@ fn download_stream(url: String, stream: String) {
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[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 escaped_command = command.replace("\"", "\\\"");
|
||||||
|
|
||||||
let applescript = format!(
|
let applescript = format!(
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function App({ children }: { children: React.ReactNode }) {
|
|||||||
} else if(event.payload.command === 'download-stream') {
|
} else if(event.payload.command === 'download-stream') {
|
||||||
const startDownload = async () => {
|
const startDownload = async () => {
|
||||||
try {
|
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' });
|
await invoke('receive_frontend_response', { response: 'Download started' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user