1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-22 08:05:48 +05:30

refactor: use pip3 yt-dlp in flatpak

This commit is contained in:
2026-03-05 21:35:30 +05:30
Verified
parent 2e6dc6ab25
commit d7f2f7b867
5 changed files with 25 additions and 11 deletions

View File

@@ -66,9 +66,9 @@
"args": true "args": true
}, },
{ {
"name": "sh", "name": "sh",
"cmd": "sh", "cmd": "sh",
"args": true "args": true
} }
] ]
}, },
@@ -131,9 +131,9 @@
"args": true "args": true
}, },
{ {
"name": "sh", "name": "sh",
"cmd": "sh", "cmd": "sh",
"args": true "args": true
} }
] ]
} }

View File

@@ -37,7 +37,6 @@
"icons/icon.ico" "icons/icon.ico"
], ],
"externalBin": [ "externalBin": [
"binaries/yt-dlp",
"binaries/deno" "binaries/deno"
], ],
"resources": { "resources": {

View File

@@ -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('sh', ['-c', `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();

View File

@@ -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('sh', ['-c', `yt-dlp ${args.map(arg => arg.includes(' ') ? `"${arg}"` : arg).join(' ')}`])
: 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('sh', ['-c', `yt-dlp ${args.map(arg => arg.includes(' ') ? `"${arg}"` : arg).join(' ')}`])
: Command.sidecar('binaries/yt-dlp', args);
command.on('close', async (data) => { command.on('close', async (data) => {
if (data.code !== 0) { if (data.code !== 0) {

View File

@@ -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);