norkunas / youtube-dl-php

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

Argument #1 ($progressTarget) must be of type string, null given, called in vendor/norkunas/youtube-dl-php/src/YoutubeDl.php on line 139 #154

Closed schulzrinne closed 3 years ago

schulzrinne commented 3 years ago

I'm using the example on the home page, verbatim (with dev-master from today; no laravel).

norkunas commented 3 years ago

Please give your code sample how do you use it and a test link :)

schulzrinne commented 3 years ago

Copy-pasted from the README, verbatim:

$yt = new YoutubeDl();

$yt->onProgress(static function (string $progressTarget, string $percentage, string $size, string $speed, string $eta, ?string $totalTime): void {
    echo "Download file: $progressTarget; Percentage: $percentage; Size: $size";
    if ($speed) {
        echo "; Speed: $speed";
    }
    if ($eta) {
        echo "; ETA: $eta";
    }
    if ($totalTime !== null) {
        echo "; Downloaded in: $totalTime";
    }
});

$collection = $yt->download(
    Options::create()
        ->downloadPath('/tmp')
        ->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 $video->getTitle(); // Will return Phonebloks
    }
}
norkunas commented 3 years ago

Works for me. please enable process debugging to check what's going on.

schulzrinne commented 3 years ago

How do I enable process debugging? The documentation seems silent on this.

On Thu, Aug 26, 2021 at 8:28 AM Tomas Norkūnas @.***> wrote:

Works for me. please enable process debugging to check what's going on.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/norkunas/youtube-dl-php/issues/154#issuecomment-906363711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANHS5B6NYBNGFTNW6MULWDT6YXO7ANCNFSM5CTD4SCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

zoxidovuz commented 3 years ago

I have the same problem. What is the solution to this?

norkunas commented 3 years ago

How do I enable process debugging? The documentation seems silent on this. On Thu, Aug 26, 2021 at 8:28 AM Tomas Norkūnas @.***> wrote: Works for me. please enable process debugging to check what's going on. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#154 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANHS5B6NYBNGFTNW6MULWDT6YXO7ANCNFSM5CTD4SCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

$yt->debug(function ($type, $buffer) {
    if (\Symfony\Component\Process\Process::ERR === $type) {
        echo 'ERR > ' . $buffer;
    } else {
        echo 'OUT > ' . $buffer;
    }
});
schulzrinne commented 3 years ago

The problem seems to appear on the 2nd (and subsequent downloads). Stack trace below:

Edas{closure}(): Argument #1 ($progressTarget) must be of type string, null given, called in /mnt/edas/html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php on line 139 /mnt/edas/html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php:139 Edas{closure} (Null, "100%", "7.01MiB", Null, Null, Null) /mnt/edas/html/vendor/symfony/process/Process.php:1342 YoutubeDl\YoutubeDl->YoutubeDl{closure} ("out", " [download] 100% of 7.01MiB ") /mnt/edas/html/vendor/symfony/process/Process.php:1442 Symfony\Component\Process\Process->Symfony\Component\Process{closure} ("out", " [download] 100% of 7.01MiB ") /mnt/edas/html/vendor/symfony/process/Process.php:430 Symfony\Component\Process\Process->readPipes (True, True) /mnt/edas/html/vendor/symfony/process/Process.php:252 Symfony\Component\Process\Process->wait () /mnt/edas/html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php:146 Symfony\Component\Process\Process->run (Object(Closure=[])) /mnt/edas/html/testY.php:50 YoutubeDl\YoutubeDl->download (Object(YoutubeDl\Options=[]))

OUT > [youtube] oDAw7vW7H0c: Downloading webpage OUT > [youtube] oDAw7vW7H0c: Downloading player 9da24d97 OUT > [info] Writing video description metadata as JSON to: /tmp/Phonebloks-oDAw7vW7H0c.info.json OUT > [download] /tmp/Phonebloks-oDAw7vW7H0c.mp4 has already been downloaded

On Sun, Aug 29, 2021 at 11:33 PM Tomas Norkūnas @.***> wrote:

How do I enable process debugging? The documentation seems silent on this. … <#m-3419332739715970790> On Thu, Aug 26, 2021 at 8:28 AM Tomas Norkūnas @.***> wrote: Works for me. please enable process debugging to check what's going on. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#154 (comment) https://github.com/norkunas/youtube-dl-php/issues/154#issuecomment-906363711>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANHS5B6NYBNGFTNW6MULWDT6YXO7ANCNFSM5CTD4SCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

$yt->debug(function ($type, $buffer) {

if (\Symfony\Component\Process\Process::ERR === $type) {

    echo 'ERR > ' . $buffer;

} else {

    echo 'OUT > ' . $buffer;

}

});

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/norkunas/youtube-dl-php/issues/154#issuecomment-907987124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANHS5HLFTSYWKJI7PJ3AXLT7L3X7ANCNFSM5CTD4SCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

norkunas commented 3 years ago

Hm, for me it still works:

norkunas@norkunas-X571LI:~/Projects/www/youtube-dl-php$ php issue154.php
OUT > [youtube] oDAw7vW7H0c: Downloading webpage
OUT > [info] Writing video description metadata as JSON to: /home/norkunas/Projects/www/youtube-dl-php/dd/Phonebloks-oDAw7vW7H0c.info.json
OUT > [download] /home/norkunas/Projects/www/youtube-dl-php/dd/Phonebloks-oDAw7vW7H0c.webm has already been downloaded and merged
Phonebloks

Edit: reproduced with ->mergeOutputFormat('mp4')