norkunas / youtube-dl-php

A PHP wrapper for youtube-dl or yt-dlp.
MIT License
458 stars 158 forks source link

INTERNAL ERROR: cannot create temporary directory! #202

Open KlaimGames opened 1 year ago

KlaimGames commented 1 year ago

Running into some issues using this. Fairly basic setup, but on windows :

`$yt = new YoutubeDl();

$yt->setBinPath(__DIR__.'/yt-dl/yt-dlp');

$collection = $yt->download(
    Options::create()
        ->downloadPath('/path/to/my/downloadfolder')
        ->url('https://www.youtube.com/watch?v=oDAw7vW7H0c')
);`

(downloadfolder being set to a specific folder onto my computer, redacted in here)

Within the download() function, I do a dump of the $buffer to get the info, since it otherwise silently fails. All i get is

INTERNAL ERROR: cannot create temporary directory!

Not sure as to why. If I dump the $process->getCommandLine() to get the command line and run that in my own command line, works no problem, so I am unsure as to what is happening here

Any idea ?

norkunas commented 1 year ago

Hey,

Maybe you are running your script with not the same permissions as directly through terminal?

KlaimGames commented 1 year ago

Hi,

So, as far as I know, it shouldnt be a problem, as its been implemented within a system that already writes files and others ( like uploaded images ). Now, if what is presumably a wrapper for a shell command can, is a different matter, but im not sure as to how to verify that. I guess that the php builds the command line that is going to be executed, but i dont know how to verify if its that execution process that isnt permitted.

Thank you

On Wed, Mar 15, 2023 at 12:09 AM Tomas Norkūnas @.***> wrote:

Hey,

Maybe you are running your script with not the same permissions as directly through terminal?

— Reply to this email directly, view it on GitHub https://github.com/norkunas/youtube-dl-php/issues/202#issuecomment-1469298853, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG5D64JSD5TDWGFRHD63BRLW4E6JPANCNFSM6AAAAAAV3GYLRU . You are receiving this because you authored the thread.Message ID: @.***>

norkunas commented 1 year ago

You could try to run shell_exec with same cmd that works in terminal without this library to check if it works

KlaimGames commented 1 year ago

So, I did just that, getting the command from $process->getCommandLine(), and pasting the result to a shell_exec, it works directly without any issue.

Given that it can generate a functional command line that blindly works in a shell_exec, i could bypass this issue and work with just this at the moment, but obviously, id rather it be fixed properly and correctly. However, from this, I do not know what more I could provide to assist in troubleshooting this.

thank you

On Wed, Mar 15, 2023 at 2:55 PM Tomas Norkūnas @.***> wrote:

You could try to run shell_exec with same cmd that works in terminal without this library to check if it works

— Reply to this email directly, view it on GitHub https://github.com/norkunas/youtube-dl-php/issues/202#issuecomment-1470605718, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG5D64PFVTPVQ3XYQMRCQWLW4IGCHANCNFSM6AAAAAAV3GYLRU . You are receiving this because you authored the thread.Message ID: @.***>

norkunas commented 1 year ago

Could you try that also with proc_open? also on which OS are you running your app?

KlaimGames commented 1 year ago

Used as follow :

$cmd = $process->getCommandLine(); $proc=proc_open($cmd, array( 0=>array('pipe', 'r'), //stdin 1=>array('pipe', 'w'), //stdout 2=>array('pipe', 'w') //stderr ), $pipes, DIR, null, array('bypass_shell'=>true) ); echo stream_get_contents($pipes[1]); proc_close($proc);

Works fine, with no issue, generating both the video file and json

Im on a local dev environment, on windows.

Thank you

On Thu, Mar 16, 2023 at 2:21 AM Tomas Norkūnas @.***> wrote:

Could you try that also with proc_open? also on which OS are you running your app?

— Reply to this email directly, view it on GitHub https://github.com/norkunas/youtube-dl-php/issues/202#issuecomment-1471387118, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG5D64O5CZTFHDDOBBRKSGDW4KWPTANCNFSM6AAAAAAV3GYLRU . You are receiving this because you authored the thread.Message ID: @.***>

norkunas commented 1 year ago

Then I'm not sure and probably can't help anymore because I don't use windows and I suggest to use xdebug then :disappointed:

KlaimGames commented 1 year ago

Ok no worries, I'll work around the issue then, since the generated command does work.

Thank you for your help

On Fri, Mar 17, 2023, 12:52 a.m. Tomas Norkūnas @.***> wrote:

Then I'm not sure and probably can't help anymore because I don't use windows and I suggest to use xdebug then 😞

— Reply to this email directly, view it on GitHub https://github.com/norkunas/youtube-dl-php/issues/202#issuecomment-1473126898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG5D64OHY2OIN7FO7A2WQTLW4PUX5ANCNFSM6AAAAAAV3GYLRU . You are receiving this because you authored the thread.Message ID: @.***>

tree1891 commented 1 week ago

On windows, it occurs when debug [PYI-14352:ERROR] Could not create temporary directory!

norkunas commented 1 week ago

@tree1891 so the error is directly coming from yt-dlp, no?

tree1891 commented 1 week ago

only when run yt-dlp command in php, it occurs, but not in command prompt.

norkunas commented 1 week ago

ok, but still, this doesn't indicate that it's library's fault. without a way to reproduce this error i won't be able to help