mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2026-03-23 03:05:49 +05:30
Compare commits
2 Commits
2e6dc6ab25
...
52dad3acb1
@@ -40,6 +40,11 @@
|
|||||||
"args": true,
|
"args": true,
|
||||||
"sidecar": true
|
"sidecar": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "yt-dlp",
|
||||||
|
"cmd": "yt-dlp",
|
||||||
|
"args": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ffmpeg",
|
"name": "ffmpeg",
|
||||||
"cmd": "ffmpeg",
|
"cmd": "ffmpeg",
|
||||||
@@ -105,6 +110,11 @@
|
|||||||
"args": true,
|
"args": true,
|
||||||
"sidecar": true
|
"sidecar": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "yt-dlp",
|
||||||
|
"cmd": "yt-dlp",
|
||||||
|
"args": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ffmpeg",
|
"name": "ffmpeg",
|
||||||
"cmd": "ffmpeg",
|
"cmd": "ffmpeg",
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
],
|
||||||
"externalBin": [
|
"externalBin": [
|
||||||
"binaries/yt-dlp",
|
|
||||||
"binaries/deno"
|
"binaries/deno"
|
||||||
],
|
],
|
||||||
"resources": {
|
"resources": {
|
||||||
|
|||||||
@@ -257,7 +257,10 @@ export default function App({ children }: { children: React.ReactNode }) {
|
|||||||
const fetchYtDlpVersion = async () => {
|
const fetchYtDlpVersion = async () => {
|
||||||
setIsFetchingYtDlpVersion(true);
|
setIsFetchingYtDlpVersion(true);
|
||||||
try {
|
try {
|
||||||
const command = Command.sidecar('binaries/yt-dlp', ['--version']);
|
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||||
|
const command = isFlatpak
|
||||||
|
? Command.create('yt-dlp', [' --version'])
|
||||||
|
: Command.sidecar('binaries/yt-dlp', ['--version']);
|
||||||
const output = await command.execute();
|
const output = await command.execute();
|
||||||
if (output.code === 0) {
|
if (output.code === 0) {
|
||||||
const version = output.stdout.trim();
|
const version = output.stdout.trim();
|
||||||
|
|||||||
@@ -196,7 +196,10 @@ export default function useDownloader() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const command = Command.sidecar('binaries/yt-dlp', args);
|
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||||
|
const command = isFlatpak
|
||||||
|
? Command.create('yt-dlp', args)
|
||||||
|
: Command.sidecar('binaries/yt-dlp', args);
|
||||||
|
|
||||||
let jsonOutput = '';
|
let jsonOutput = '';
|
||||||
|
|
||||||
@@ -557,7 +560,10 @@ export default function useDownloader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Starting download with args:', args);
|
console.log('Starting download with args:', args);
|
||||||
const command = Command.sidecar('binaries/yt-dlp', args);
|
const isFlatpak = await invoke<boolean>('is_flatpak');
|
||||||
|
const command = isFlatpak
|
||||||
|
? Command.create('yt-dlp', args)
|
||||||
|
: Command.sidecar('binaries/yt-dlp', args);
|
||||||
|
|
||||||
command.on('close', async (data) => {
|
command.on('close', async (data) => {
|
||||||
if (data.code !== 0) {
|
if (data.code !== 0) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { join, resourceDir, homeDir } from "@tauri-apps/api/path";
|
|||||||
import * as fs from "@tauri-apps/plugin-fs";
|
import * as fs from "@tauri-apps/plugin-fs";
|
||||||
import { useKvPairs } from "@/helpers/use-kvpairs";
|
import { useKvPairs } from "@/helpers/use-kvpairs";
|
||||||
import { useSettingsPageStatesStore } from "@/services/store";
|
import { useSettingsPageStatesStore } from "@/services/store";
|
||||||
// import { Command } from "@tauri-apps/plugin-shell";
|
import { Command } from "@tauri-apps/plugin-shell";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
interface FileMap {
|
interface FileMap {
|
||||||
@@ -42,42 +42,43 @@ export function useLinuxRegisterer() {
|
|||||||
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', destination: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', dir: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
|
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', destination: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', dir: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// const filesToCopyFlatpak: FileMap[] = [
|
const filesToCopyFlatpak: FileMap[] = [
|
||||||
// { source: 'chrome.json', destination: '.config/google-chrome/NativeMessagingHosts/com.neosubhamoy.neodlp.json', dir: '.config/google-chrome/NativeMessagingHosts/', content: JSON.stringify(flatpakChromeManifestContent) },
|
// { source: 'chrome.json', destination: '.config/google-chrome/NativeMessagingHosts/com.neosubhamoy.neodlp.json', dir: '.config/google-chrome/NativeMessagingHosts/', content: JSON.stringify(flatpakChromeManifestContent) },
|
||||||
// { source: 'chrome.json', destination: '.config/chromium/NativeMessagingHosts/com.neosubhamoy.neodlp.json', dir: '.config/chromium/NativeMessagingHosts/', content: JSON.stringify(flatpakChromeManifestContent) },
|
// { source: 'chrome.json', destination: '.config/chromium/NativeMessagingHosts/com.neosubhamoy.neodlp.json', dir: '.config/chromium/NativeMessagingHosts/', content: JSON.stringify(flatpakChromeManifestContent) },
|
||||||
// { source: 'firefox.json', destination: '.mozilla/native-messaging-hosts/com.neosubhamoy.neodlp.json', dir: '.mozilla/native-messaging-hosts/', content: JSON.stringify(flatpakFirefoxManifestContent) },
|
// { source: 'firefox.json', destination: '.mozilla/native-messaging-hosts/com.neosubhamoy.neodlp.json', dir: '.mozilla/native-messaging-hosts/', content: JSON.stringify(flatpakFirefoxManifestContent) },
|
||||||
// { source: 'neodlp-msghost', destination: '.local/bin/neodlp-msghost', dir: '.local/bin/' },
|
// { source: 'neodlp-msghost', destination: '.local/bin/neodlp-msghost', dir: '.local/bin/' },
|
||||||
// ];
|
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
|
||||||
|
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_cli.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_cli.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
|
||||||
|
{ source: 'yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', destination: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/getpot_bgutil_http.py', dir: '.var/app/com.neosubhamoy.neodlp/config/yt-dlp-plugins/bgutil-ytdlp-pot-provider/yt_dlp_plugins/extractor/' },
|
||||||
|
];
|
||||||
|
|
||||||
if (isFlatpak) {
|
if (isFlatpak) {
|
||||||
// Skip registration and just return success in flatpak
|
for (const file of filesToCopyFlatpak) {
|
||||||
console.log('Running in Flatpak, Skipping registration...');
|
const sourcePath = await join(resourceDirPath, file.source);
|
||||||
|
const destinationDir = await join(homeDirPath, file.dir);
|
||||||
|
const destinationPath = await join(homeDirPath, file.destination);
|
||||||
|
const escapedContent = file.content?.replace(/'/g, `'\\''`) || '';
|
||||||
|
const copyCommand = Command.create('sh', ['-c', `mkdir -p "${destinationDir}" && cp "${sourcePath}" "${destinationPath}"`]);
|
||||||
|
const writeCommand = Command.create('sh', ['-c', `printf '%s' '${escapedContent}' > "${destinationPath}"`]);
|
||||||
|
|
||||||
// for (const file of filesToCopyFlatpak) {
|
if (file.content) {
|
||||||
// const sourcePath = await join(resourceDirPath, file.source);
|
const writeOutput = await writeCommand.execute();
|
||||||
// const destinationPath = await join(homeDirPath, file.destination);
|
if (writeOutput.code === 0) {
|
||||||
// const escapedContent = file.content?.replace(/'/g, `'\\''`) || '';
|
console.log(`File ${file.destination} created successfully at ${destinationPath}`);
|
||||||
// const copyCommand = Command.create('sh', ['-c', `cp "${sourcePath}" "${destinationPath}"`]);
|
} else {
|
||||||
// const writeCommand = Command.create('sh', ['-c', `printf '%s' '${escapedContent}' > "${destinationPath}"`]);
|
console.error(`Failed to create file ${file.destination} at ${destinationPath}:`, writeOutput.stderr);
|
||||||
|
return { success: false, message: 'Failed to register' };
|
||||||
// if (file.content) {
|
}
|
||||||
// const writeOutput = await writeCommand.execute();
|
} else {
|
||||||
// if (writeOutput.code === 0) {
|
const copyOutput = await copyCommand.execute();
|
||||||
// console.log(`File ${file.destination} created successfully at ${destinationPath}`);
|
if (copyOutput.code === 0) {
|
||||||
// } else {
|
console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
||||||
// console.error(`Failed to create file ${file.destination} at ${destinationPath}:`, writeOutput.stderr);
|
} else {
|
||||||
// return { success: false, message: 'Failed to register' };
|
console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, copyOutput.stderr);
|
||||||
// }
|
return { success: false, message: 'Failed to register' };
|
||||||
// } else {
|
}
|
||||||
// const copyOutput = await copyCommand.execute();
|
}
|
||||||
// if (copyOutput.code === 0) {
|
}
|
||||||
// console.log(`File ${file.source} copied successfully to ${destinationPath}`);
|
|
||||||
// } else {
|
|
||||||
// console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, copyOutput.stderr);
|
|
||||||
// return { success: false, message: 'Failed to register' };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
for (const file of filesToCopy) {
|
for (const file of filesToCopy) {
|
||||||
const sourcePath = await join(resourceDirPath, file.source);
|
const sourcePath = await join(resourceDirPath, file.source);
|
||||||
|
|||||||
@@ -21,7 +21,13 @@ export function useYtDlpUpdater() {
|
|||||||
setIsUpdatingYtDlp(true);
|
setIsUpdatingYtDlp(true);
|
||||||
LOG.info('NEODLP', 'Updating yt-dlp to latest version');
|
LOG.info('NEODLP', 'Updating yt-dlp to latest version');
|
||||||
try {
|
try {
|
||||||
const command = currentPlatform === 'linux' && !isFlatpak ? Command.create('pkexec', ['yt-dlp', '--update-to', ytDlpUpdateChannel]) : Command.sidecar('binaries/yt-dlp', ['--update-to', ytDlpUpdateChannel]);
|
const command = currentPlatform === 'linux' && isFlatpak
|
||||||
|
? ytDlpUpdateChannel === 'nightly'
|
||||||
|
? Command.create('sh', ['-c', 'pip3 install -U --pre "yt-dlp[default,curl-cffi]"'])
|
||||||
|
: Command.create('sh', ['-c', 'pip3 install -U "yt-dlp[default,curl-cffi]"'])
|
||||||
|
: currentPlatform === 'linux'
|
||||||
|
? Command.create('pkexec', ['yt-dlp', '--update-to', ytDlpUpdateChannel])
|
||||||
|
: Command.sidecar('binaries/yt-dlp', ['--update-to', ytDlpUpdateChannel]);
|
||||||
const output = await command.execute();
|
const output = await command.execute();
|
||||||
if (output.code === 0) {
|
if (output.code === 0) {
|
||||||
console.log("yt-dlp updated successfully:", output.stdout);
|
console.log("yt-dlp updated successfully:", output.stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user