microlinkhq / youtube-dl-exec

A simple Node.js wrapper for youtube-dl/yt-dlp.
MIT License
423 stars 75 forks source link

Not working when a binary is on a path with space #180

Closed clpacheco90 closed 10 months ago

clpacheco90 commented 10 months ago

Hi,

I'm having a issue when run the package on folder with space, like "Program Files". This issue occurs on Linux and Windows.

Here is a path that is not working: "C:\Program Files\my-app\global\win32\yt-dlp.exe" But here is working: "C:\my-app\global\win32\yt-dlp.exe"

Here is a path that is not working: "/home/my app/global/linux/yt-dlp" But here is working: "/home/my-app/global/linux/yt-dlp"

I tried to use some methods like "\" on linux but nothing works for me.

Here is a sample of my code.

const { create: createYoutubeDl } = require('youtube-dl-exec')

  let download = async function($scope, value, eachCallback) {
    /**
   * Youtube-dl has been deprecated use yt-dlp instead
   */
    var linux = path.join(path.dirname(remote.getGlobal('globalPath')), 'global', 'linux', 'yt-dlp');
    var win32 = path.join(path.dirname(remote.getGlobal('globalPath')), 'global', 'win32', 'yt-dlp.exe');
    var youtubedlPath = (process.platform === 'win32') ? win32 : linux;

    let youtubedl = createYoutubeDl(youtubedlPath);
    ...        
    let update = await youtubedl('', { update: true });
    ...

can you help?

clpacheco90 commented 10 months ago

Solved. I need to put cwd on youtubedl

Here is:

const { create: createYoutubeDl } = require('youtube-dl-exec')

  let download = async function($scope, value, eachCallback) {
    /**
   * Youtube-dl has been deprecated use yt-dlp instead
   */
    let currentDirname = path.dirname(remote.getGlobal('globalPath'));
    var linux = path.join('global', 'linux', 'yt-dlp');
    var win32 = path.join('global', 'win32', 'yt-dlp.exe');
    var youtubedlPath = (process.platform === 'win32') ? win32 : linux;

    let youtubedl = createYoutubeDl(youtubedlPath);

    ...        
    let update = await youtubedl('', { update: true }, { cwd: currentDirname });
    ...