norkunas / youtube-dl-php

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

Error with yt-dlp #197

Open vksputnik opened 1 year ago

vksputnik commented 1 year ago

I am using yt-dlp: $dl->setBinpath('/usr/local/bin/yt-dlp');

But I am getting an error: ERR > ERROR: [youtube] 4A67iTiOD_g: Unable to extract uploader id; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U

At the same time, if I call the command on the command line, then the video is downloaded without problems: yt-dlp -vU https://youtu.be/4A67iTiOD_g

The problem arose after updating yt-dlp to the latest version on 02/17/2023.

norkunas commented 1 year ago

Not sure what's going on then, I've tested with this snippet and it works for me:

<?php

require __DIR__.'/vendor/autoload.php';

$yt = new \YoutubeDl\YoutubeDl();
$yt->setBinPath('/usr/local/bin/yt-dlp');
$yt->debug(function ($type, $buffer) {
    if (\Symfony\Component\Process\Process::ERR === $type) {
        echo $buffer;
    } else {
        echo $buffer;
    }
});

$options = \YoutubeDl\Options::create()
    ->downloadPath(__DIR__.'/dd')
    ->url('https://youtu.be/4A67iTiOD_g');

$collection = $yt->download($options);

echo "Download completed\n";
debug output norkunas@norkunas-A5-K1:~/Projects/www/youtube-dl-php$ php issue197.php [youtube] Extracting URL: https://youtu.be/4A67iTiOD_g [youtube] 4A67iTiOD_g: Downloading webpage [youtube] 4A67iTiOD_g: Downloading android player API JSON [info] 4A67iTiOD_g: Downloading 1 format(s): 313+251 [info] Writing video metadata as JSON to: /home/norkunas/Projects/www/youtube-dl-php/dd/Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой.-4A67iTiOD_g.info.json [download] Destination: /home/norkunas/Projects/www/youtube-dl-php/dd/Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой.-4A67iTiOD_g.f313.webm [download] 100% of 300.89MiB in 00:00:10 at 27.53MiB/s [download] Destination: /home/norkunas/Projects/www/youtube-dl-php/dd/Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой.-4A67iTiOD_g.f251.webm [download] 100% of 4.42MiB in 00:00:00 at 23.28MiB/s [Merger] Merging formats into "/home/norkunas/Projects/www/youtube-dl-php/dd/Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой.-4A67iTiOD_g.webm" Deleting original file /home/norkunas/Projects/www/youtube-dl-php/dd/Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой.-4A67iTiOD_g.f313.webm (pass -k to keep) Deleting original file /home/norkunas/Projects/www/youtube-dl-php/dd/Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой.-4A67iTiOD_g.f251.webm (pass -k to keep) Download completed
vksputnik commented 1 year ago
root@s40b6707c:~# '/usr/local/bin/yt-dlp' -vU 'https://youtu.be/4A67iTiOD_g'
[debug] Command-line config: ['-vU', 'https://youtu.be/4A67iTiOD_g']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out UTF-8, error UTF-8, screen UTF-8
[debug] yt-dlp version 2023.02.17 [a0a7c0154]
[debug] Lazy loading extractors is disabled
[debug] Python 3.7.3 (CPython x86_64 64bit) - Linux-4.19.0-14-amd64-x86_64-with-debian-10.12 (OpenSSL 1.1.1n  15 Mar 2022, glibc 2.28)
[debug] exe versions: ffmpeg 4.1.9-0, ffprobe 4.1.9-0
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, secretstorage-2.3.1, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1782 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2023.02.17, Current version: 2023.02.17
yt-dlp is up to date (2023.02.17)
[youtube] Extracting URL: https://youtu.be/4A67iTiOD_g
[youtube] 4A67iTiOD_g: Downloading webpage
[youtube] 4A67iTiOD_g: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 4A67iTiOD_g: Downloading 1 format(s): 313+251
[download] Юрий Шевчук, Дмитрий Емельянов — Родина, вернись домой. [4A67iTiOD_g].webm has already been downloaded
<?php

require __DIR__.'/vendor/autoload.php';

$yt = new \YoutubeDl\YoutubeDl();
$yt->setBinPath('/usr/local/bin/yt-dlp');
$yt->debug(function ($type, $buffer) {
    if (\Symfony\Component\Process\Process::ERR === $type) {
        echo $buffer;
    } else {
        echo $buffer;
    }
});

/*$options = \YoutubeDl\Options::create()
    ->downloadPath(__DIR__.'/dd')
    ->url('https://youtu.be/4A67iTiOD_g');*/

$collection = $yt->download('https://youtu.be/4A67iTiOD_g');

echo "Download completed\n";
<html>
<body>
<!--StartFragment-->

  | [youtube] 4A67iTiOD_g: Downloading webpage
-- | --
  | [youtube] 4A67iTiOD_g: Downloading android player API JSON
  | ERROR: [youtube] 4A67iTiOD_g: Unable to extract uploader id; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  | <br />
  | <b>Fatal error</b>:  Uncaught exception 'Symfony\Component\Process\Exception\ProcessFailedException' with message 'The command &quot;'/usr/local/bin/yt-dlp' 'https://youtu.be/4A67iTiOD_g'&quot; failed.
  |  
  | Exit Code: 1(General error)
  |  
  | Working directory: /tmp
  |  
  | Output:
  | ================
  | [youtube] 4A67iTiOD_g: Downloading webpage
  | [youtube] 4A67iTiOD_g: Downloading android player API JSON
  |  
  |  
  | Error Output:
  | ================
  | ERROR: [youtube] 4A67iTiOD_g: Unable to extract uploader id; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  | ' in /var/www/awebcom/data/www/autoava.com/retrans/vendor/symfony/process/Process.php:235
  | Stack trace:
  | #0 /var/www/awebcom/data/www/autoava.com/retrans/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(241): Symfony\Component\Process\Process-&gt;mustRun(Object(Closure))
  | #1 /var/www/awebcom/data/www/autoava.com/retrans/videovk_test.php(19): YoutubeDl\YoutubeDl-&gt;download('https://youtu.b...')
  | #2 {main}
  | th in <b>/var/www/awebcom/data/www/autoava.com/retrans/vendor/symfony/process/Process.php</b> on line <b>235</b><br />

<!--EndFragment-->
</body>
</html>
norkunas commented 1 year ago

Did you try with latest version of this library? But that maybe not related, because I've tested with 0.x, 1.x and it works for me. Could you also try to debug the end command line that the library runs for you?

vksputnik commented 1 year ago

Final command line: '/usr/local/bin/yt-dlp' 'https://youtu.be/4A67iTiOD_g' (specially commented out all options)

norkunas commented 1 year ago

Maybe it has something related with options, dunno then..

vksputnik commented 1 year ago

The server and IP address are of course the same as in the first, in the second case.

norkunas commented 1 year ago

Does it fail only on your server?

vksputnik commented 1 year ago

I only use one server. Until 02/17/2023 everything worked

norkunas commented 1 year ago

I mean does it work locally for you? Or you don't even test your app locally? :)

vksputnik commented 1 year ago

I don't test locally.

norkunas commented 1 year ago

So will you give the final cmd with full options?

sadakura commented 1 year ago

Hello Norkunas, it is related to new youtube users usernames, yt-dlp team have made patch and soon will make it available in master branch. I have same issues with your wrapper.

Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/yt-dlp' 'https://www.youtube.com/watch?v=sTeoEFzVNSc' '--no-playlist' '--ignore-config' '--write-info-json' '--continue' '--output=320e56596cb150ba6ceecd6627e108a0.%(ext)s' '--restrict-filenames' '--proxy=p.proxyservice.la:9999' '--no-check-certificate' '--no-mtime' '--skip-download'" failed. Exit Code: 1(General error) Working directory: /var/www/vhosts/yt2online.com/httpdocs/assets/downloads/youtube Output: ================ [youtube] sTeoEFzVNSc: Downloading webpage [youtube] sTeoEFzVNSc: Downloading android player API JSON [youtube] sTeoEFzVNSc: Executing signature code Error Output: ================ WARNING: [youtube] sTeoEFzVNSc: Native nsig extraction failed: Trying with PhantomJS n = kk6doOgbwRvsJaiJ ; player = https://www.youtube.com/s/player/11e3a4ec/player_ias.vflset/en_US/base.js ERROR: [youtube] sTeoEFzVNSc: Unable to extract uploader id; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U in /var/www/vhosts/yt2online.com/httpdocs/vendor/symfony/process/Process.php:252 Stack trace: #0 /var/www/vhosts/yt2online.com/httpdocs/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(158): Symfony\Component\Process\Process->mustRun(Object(Closure)) #1 /var/www/vhosts/yt2online.com/httpdocs/mysite/code/Grabbers/classes/youtube_new.class.php(73): YoutubeDl\YoutubeDl->download('https://www.you...') #2 /var/www/vhosts/yt2online.com/httpdocs/mysite/code/Grabbers/GrabberPage.php(642): youtube_new->media_info('https://www.you...') #3 /var/www/vhosts/yt2online.com/httpdocs/framework/control/RequestHandler.php(296): GrabberPage_Controller->finddownloadlinks(Object(SS_HTTPRequest)) #4 /var/www/vhosts/yt2online.com/httpdocs/framework/control/Controller.php(192): RequestHandler->handleAction(Object(SS_HTTPRequest), 'finddownloadlin...') #5 /var/www/vhosts/yt2online.com/httpdocs/framework/control/RequestHandler.php(208): Controller->handleAction(Object(SS_HTTPRequest), 'finddownloadlin...') #6 /var/www/vhosts/yt2online.com/httpdocs/framework/control/Controller.php(151): RequestHandler->handleRequest(Object(SS_HTTPRequest), Object(DataModel)) #7 /var/www/vhosts/yt2online.com/httpdocs/cms/code/controllers/ContentController.php(200): Controller->handleRequest(Object(SS_HTTPRequest), Object(DataModel)) #8 /var/www/vhosts/yt2online.com/httpdocs/cms/code/controllers/ModelAsController.php(75): ContentController->handleRequest(Object(SS_HTTPRequest), Object(DataModel)) #9 /var/www/vhosts/yt2online.com/httpdocs/framework/control/Director.php(387): ModelAsController->handleRequest(Object(SS_HTTPRequest), Object(DataModel)) #10 /var/www/vhosts/yt2online.com/httpdocs/framework/control/Director.php(149): Director::handleRequest(Object(SS_HTTPRequest), Object(Session), Object(DataModel)) #11 /var/www/vhosts/yt2online.com/httpdocs/framework/main.php(211): Director::direct('/besplatno/find...', Object(DataModel)) #12 {main}

You can read on original issue at yt-dlp Norkunas here : https://github.com/yt-dlp/yt-dlp/issues/6247

sadakura commented 1 year ago

Hello Norkunas, are you going to fix it soon ? Regards, Tomas.

norkunas commented 1 year ago

Hi, i'm not sure what I should fix, if the issue was in yt-dlp?

jhonix22 commented 1 year ago

I had this issue before when I was using the youtube-dl and then we switched to yt-dlp, it worked on my local in this case, but it doesn't work on our staging server. And it doesn't even give us any error and it works when running in the terminal 😅

norkunas commented 1 year ago

I need a reproducer otherwise it's impossible to guess what's the issue :)

jhonix22 commented 1 year ago

Ah I got mine solved, my re-installing yt-dlp via curl. Previously I installed it via pip install yt-dlp. Hope this information might help.

sadakura commented 1 year ago

Hi, i'm not sure what I should fix, if the issue was in yt-dlp?

Hi Tomas, if your php wrapper somehow processing user id, error started to appear instantly after this change on youtube platform and later yt-dlp was patched for youtube :

sadakura commented 1 year ago

I'm not coder walked around code and found this entry, looks like this wrapper is involved in whole process, since i found this function :) I'm trying to get log error to work for this wrapper so I can give more details, my whole website is down since youtube have made changes :)

` /**

norkunas commented 1 year ago

This wrapper just returns what the python binary returns :)

sadakura commented 1 year ago

This wrapper just returns what the python binary returns :)

Oh ok, I thought that being as an intermediate it could cause error for me in the whole process, I have found that wrapper is modified on my end it took me 2 days to figure it out comparing all lines in whole project. Thank you for great php wrapper you have made freely available to everyone.

norkunas commented 1 year ago

You're welcome 😉

shibjeedanuwar commented 1 year ago

how to fix this output: The system cannot find the path specified.

norkunas commented 1 year ago

Maybe you set the unexisting download path?

liwa-dev commented 1 year ago

Can u just update your repo? cuz i'm confused to use it when i tried your code and nothing happen

<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use YoutubeDl\Options;
use YoutubeDl\YoutubeDl;

$yt = new YoutubeDl();
$yt->setBinPath('/usr/bin/youtube-dl');
$collection = $yt->download(
    Options::create()
        ->downloadPath('/path/to/downloads')
        ->extractAudio(true)
        ->audioFormat('mp3')
        ->audioQuality('0') // best
        ->output('%(title)s.%(ext)s')
        ->url('https://www.youtube.com/watch?v=oDAw7vW7H0c')
);

foreach ($collection->getVideos() as $video) {
    if ($video->getError() !== null) {
        echo "Error downloading video: {$video->getError()}.";
    } else {
        echo "work";
        $video->getFile(); // audio file
    }
}
norkunas commented 1 year ago

@liwa-dev If nothing happened then I suggest to use a debugger or at least enable error handling in your front script to see what's happening, because there is nothing to update currently.

and please do not comment on unrelated issues, because other people get useless notifications