Giter Site home page Giter Site logo

youtube-dl-php's Introduction

Youtube-dl PHP

A PHP wrapper for youtube-dl or yt-dlp.

Latest Stable Version Latest Unstable Version Total Downloads CI Status License

Install

First step is to download the youtube-dl or yt-dlp.

Second step is to install the wrapper using Composer:

composer require norkunas/youtube-dl-php:dev-master

Download video

<?php

declare(strict_types=1);

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

use YoutubeDl\Options;
use YoutubeDl\YoutubeDl;

$yt = new YoutubeDl();

$collection = $yt->download(
    Options::create()
        ->downloadPath('/path/to/downloads')
        ->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
        // $video->getFile(); // \SplFileInfo instance of downloaded file
    }
}

Download only audio (requires ffmpeg or avconv and ffprobe or avprobe)

<?php

declare(strict_types=1);

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

use YoutubeDl\Options;
use YoutubeDl\YoutubeDl;

$yt = new YoutubeDl();
$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 {
        $video->getFile(); // audio file
    }
}

Download progress

<?php

declare(strict_types=1);

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

use YoutubeDl\YoutubeDl;

$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";
    }
});

Custom Process Instantiation

<?php

declare(strict_types=1);

namespace App\YoutubeDl;

use Symfony\Component\Process\Process;
use YoutubeDl\Process\ProcessBuilderInterface;

class ProcessBuilder implements ProcessBuilderInterface
{
    public function build(?string $binPath, ?string $pythonPath, array $arguments = []): Process
    {
        $process = new Process([$binPath, $pythonPath, ...$arguments]);
        // Set custom timeout or customize other things..
        $process->setTimeout(60);

        return $process;
    }
}
<?php

declare(strict_types=1);

use App\YoutubeDl\ProcessBuilder;
use YoutubeDl\YoutubeDl;

$processBuilder = new ProcessBuilder();

// Provide your custom process builder as the first argument.
$yt = new YoutubeDl($processBuilder);

Questions?

If you have any questions please open a discussion.

License

This library is released under the MIT License. See the bundled LICENSE file for details.

youtube-dl-php's People

Contributors

9x3l6 avatar blackburn29 avatar dopesong avatar erensertkaya avatar florianlechat avatar jimbolino avatar khanhvu14 avatar miapuffia avatar michaelbelgium avatar mrlaminat avatar nks avatar norkunas avatar peter279k avatar sheriffmarley avatar stupidkitty avatar tone87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtube-dl-php's Issues

Downloading playlist?

Hi, when I try to download playlist, I'm getting
RuntimeException: Response can't be decoded error.
This wrapper can't handle the playlist links, only single tracks?
Thx,
Peter

Some options are missing

for example: http-chunk-size.

Why do you limit the options. Let the users decide the options.

Issue with Symfony - Unable to Launch New Process

Hello...

This issue cropped up a week ago. Not sure what causes it. When youtube-dl fires up through Norkunas/youtube-dl-php, I get:
["message":protected]=> string(31) "Unable to launch a new process." ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(60) "/home/ubuntu/php_composer/vendor/symfony/process/Process.php" ["line":protected]=> int(288) ["trace":"Exception":private]=> array(4) { [0]=> array(6) { ["file"]=> string(60) "/home/ubuntu/php_composer/vendor/symfony/process/Process.php" ["line"]=> int(196) ["function"]=> string(5) "start" ["class"]=> string(33) "Symfony\Component\Process\Process" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> NULL } } [1]=> array(6) { ["file"]=> string(60) "/home/ubuntu/php_composer/vendor/symfony/process/Process.php" ["line"]=> int(220) ["function"]=> string(3) "run" ["class"]=> string(33) "Symfony\Component\Process\Process" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> NULL } } [2]=> array(6) { ["file"]=> string(74) "/home/ubuntu/php_composer/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php" ["line"]=> int(241) ["function"]=> string(7) "mustRun" ["class"]=> string(33) "Symfony\Component\Process\Process" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> NULL } } [3]=> array(6) { ["file"]=> string(42) "/home/ubuntu/api/api-word-timing.php" ["line"]=> int(61) ["function"]=> string(8) "download" ["class"]=> string(19) "YoutubeDl\YoutubeDl" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(43) "https://www.youtube.com/watch?v=sfOM27C0MLU" } } } ["previous":"Exception":private]=> NULL }

At this point, I've tried:
-- Removing Symfony (but can't remove the dependencies in youtube-dl-php
-- Changing symfony versions from 2.8 to 3.3 and back (same error)

I'm running Ubuntu 16.04, youtube-dl version is 2017-11-06 (but also errors on earlier versions the same way, I checked). Installed youtube-dl-php via composer.

Any suggestions? I lean on this a lot, but not sure when Symfony went bonkers on me...

download-archive error

Hi. One question. I use 'download-archive' for non download the same video again.

the problem is when the video was download before, the "$video->getFilename();" break my foreach.

I need:
if (video was downloaded before) {
continue;
}
sorry for my english.
Thanks.....

Symfony 3.2 - ExecutableFinder can't locate binary / setBinPath doesn't include ENV path

Maybe I'm overlooking something. It works in some degree.

I'm using a Symfony 3.2 deployment. I required your code via composer.

This works
I can successfully test the mp3 example WITHOUT specifying the youtube-dl binary path in the root directory.

symfony-project-folder/
app/
vendor/
test.php
blabla/

test.php::

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

use YoutubeDl\YoutubeDl;

$dl = new YoutubeDl([
    'extract-audio' => true,
    'audio-format' => 'mp3',
    'audio-quality' => 0, // best
    'output' => '%(title)s.%(ext)s',
]);
$dl->setDownloadPath('/home/user/downloads');

$video = $dl->download('https://www.youtube.com/watch?v=oDAw7vW7H0c');

This doesn't work
When I try to use it within my bundle. I have to specify the binary path.
Strangely the ExecutableFinder doesn't seem to work. So I explicitly do it by setting: setBinPath('/usr/local/bin/youtube-dl')
But than this error pops up:

Error Output:

ERROR: ffprobe or avprobe not found. Please install one.

So it seems that the ExecutableFinder can't see my youtube-dl binary and its ENV settings. youtube-dl. ffmpeg, ffprobe, avprobe are all installed onto my system.

This is the executed command, when I copy/paste the command into my shell it works fine. '/usr/local/bin/youtube-dl' 'https://www.youtube.com/watch?v=oDAw7vW7H0c' '--no-playlist' '--print-json' '--ignore-config' '--extract-audio' '--audio-format=mp3' '--audio-quality=0' '--output=%(title)s.%(ext)s'

As a temporary solution I cloned your YoutubeDl to YoutubeDlFixed
and added:

        $process = $processBuilder->getProcess();
        $process->setEnv(['PATH' => '/Users/forrestgump/.composer/vendor/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/ruby/bin:/usr/local/bin:/Users/forrestgump/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin']);

        try {
            $process->mustRun(is_callable($this->debug) ? $this->debug : null);
        } catch (\Exception $e) {
            throw $this->handleException($e);
        }

So my question is: Is this is a bug? or a mistake from my side? Did I overlook something?

$dl->getFilename() returns ""

Can't get filename of downloaded file. This method only displayes correct string with 'restrict-filenames' => true option. My options array:

            'extract-audio' => true,
            'audio-format' => 'mp3',
            'audio-quality' => 0, // best
            'output' => '%(title)s.%(ext)s',
            'no-playlist'  => true,

How to disable playlist downloading?

Hi!
I wouldn't like enable playlist downloading, users can kill my server with a huge feed :) Is there any possibilities to enable only single downloads from all providers?

Thanks,
Peter

onProgress not available in 0.3.5

I installed this beautiful package as instructed in the readme

composer require norkunas/youtube-dl-php

This installs the 0.3.5 version of this package. Unfortunately the new onProgress function (also described in the readme) doesn't exists in this version.
Any change of deploying a new version containing this change?

POST & GET

Hi, Tomas

how do i POST the URL to $dl->download("https://www.youtube.com/watch?v=wM8ytYa5sHw");
$dl->download($_GET[link]);
example:

$reqUrl = $_GET[link];
require __DIR__ . '/vendor/autoload.php';
use YoutubeDl\YoutubeDl;
$dl = new YoutubeDl([
    'extract-audio' => true,
    'audio-format' => 'mp3',
    'audio-quality' => 0, // best
    'output' => '%(title)s.%(ext)s',
]);
$dl->setDownloadPath('./');
$video = $dl->download($reqUrl);

i works wonderful but get and post wont send the link to download?

Thanks form your help

Hi Tomas, Thanks for reply
i've tried both methods,
none of them worked.
i mean either method.

Add progress function

Can you do what this guy do?

Example #3: With progress function

require_once 'vendor/autoload.php';

use PHPYoutubeDl\PHPYoutubeDl;

function showProgress($downloaded_size, $download_size){
	echo $downloaded_size / $download_size;
	echo PHP_EOL;
	flush();
}

$php_youtube_dl = new PHPYoutubeDl("http://www.youtube.com/watch?v=xxxxxx");
$php_youtube_dl->setProgressCallback('showProgress');
$php_youtube_dl->startDownload();

source: https://github.com/aladdindev/php-youtube-dl
also maybe this will help: https://askubuntu.com/questions/635504/youtube-dl-file-download-progress-with-zenity-progress-bar
PS: No, i cannot do it by myself

ERROR: unable to open for writing: [Errno 13] Permission denied (UBUNTU)

I'm sorry my english, is not native language.

I to be with a problem after of finish all process of install.
When goes execute the code, this error occur:

Error Output: ================ ERROR: unable to open for writing: [Errno 13] Permission denied: "Video File...." in /home/.../vendor/symfony/process/Process.php:233 Stack trace: #0 /home/.../vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(102): Symfony\Component\Process\Process->mustRun(Object(Closure)) #1 /var/.../youtube-dl/index.php(25): YoutubeDl\YoutubeDl->download('https://www.you...') #2 {main}

Please, help. What going on? :/

How to get download links

Hi,

Is there a way to get a list of download links for a youtube video rather than downloading the file? youtube-dl has this option, so how can it be done with this PHP wrapper?

vendor/autoload.php error

Hi,
I did the setup : composer require norkunas/youtube-dl-php install and
File patch : /home/username/vendor/norkunas/youtube-dl-php

I'm getting this error
error code : require(/opt/lampp/htdocs/example/youtube/1../vendor/autoload.php): failed to open stream: Böyle bir dosya ya da dizin yok in /opt/lampp/htdocs/example/youtube/1/index2.php on line 2

Download path variable doesn't work

I've tried to trace why, but I figured I'd just ask before I break my back over it.
i've set my path as per instruction:
$dl->setDownloadPath('/home/user/downloads');
but every time the file ends up in my server directory and i can't seem to make it go where I want, without moving it in my own code which defeats the purpose of having it in yours and the option -o in youtube-dl.

Failed to detect metadata file

Hi there,

here is my sample code which works fine with 0.3 version:

$simulate = new \YoutubeDl\YoutubeDl(['simulate' => true]);
$simulate->setDownloadPath(__DIR__);
$video = $simulate->download('https://www.youtube.com/watch?v=nfWlot6h_JM');
dump($video);

however above code with 1.0 version gives following error:

Failed to detect metadata file. {"exception":"[object] (YoutubeDl\\Exception\\YoutubeDlException(code: 0): Failed to detect metadata file. at /app/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php:184)

i'm using quite recent youtube-dl version: 2017.11.15

let me know if you need any additional info :)

CreateProcess failed Symfony error

Hey,

im currently playing around with this script and i installed it as you instructed. when i try to download a video, i get the following error:

( ! ) Warning: proc_open(): CreateProcess failed, error code - 267 in C:\xampp\htdocs\test\core\lib\vendor\symfony\process\Process.php on line 293

My code to call the script is this one:

private function videoDownloader($url){
    $dl = new YoutubeDl([
        'extract-audio' => true,
        'audio-format' => 'mp3',
        'audio-quality' => 0, // best
        'output' => '%(title)s.%(ext)s',
    ]);
    $dl->setDownloadPath('/data/');

    $video = $dl->download($url);

    return $video;       
}

I can access youtube-dl over cmd so its path-settings should be fine.

Where should i keep youtube-dl.exe

Sorry for asking a dumb question, it's giving me a headache. I have installed everything via composer. Now I don't know what to do next, I have tried my best and now finally I am stopped at this error.

ERR > Fatal Python error: Failed to initialize Windows random API (CryptoGen)

The second thing I don't understand I will be moving this project from localhost to online so where I will keep youtube-dl.exe?

Mixcloud+mp3 - requested format not available

Hi!

It's me again.
First: thank for your work, it's very cool! :)

Sorry for bother,but i have an another issue:
It works like a charm with youtube and soundcloud (mp3 and mp4 too), but i get the error below, if i provide a mixcloud url and choose mp3 format.
With mp4 format it works.
Avconv installed

Failed to download:exception 'Symfony\Component\Process\Exception\ProcessFailedException' with message 'The command "youtube-dl --continue --format bestaudio --extract-audio --audio-format mp3 --audio-quality 0 --output "%(id)s.%(ext)s" --no-playlist --print-json --ignore-config 'https://www.mixcloud.com/MalibuRum/play-1-dj-mks-summer-throwdown-mix'" failed. Exit Code: 1(General error) Working directory: /var/www/converter/public/download Output: ================ Error Output: ================ ERROR: requested format not available ' in /var/www/converter/public/vendor/symfony/process/Process.php:232 Stack trace: #0 /var/www/converter/public/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(245): Symfony\Component\Process\Process->mustRun(NULL) #1 /var/www/converter/public/index.php(108): YoutubeDl\YoutubeDl->download('https://www.mix...') #2 {main}

Fatal Python error: Failed to initialize Windows random API (CryptoGen)

Windows youtube-dl.exe is definitely found and working - path set etc.

When I remove the parameters in the Process function as per this post

https://stackoverflow.com/questions/44735057/resolve-relative-urls-of-youtube-using-php

the error is no longer thrown however it simply times out.

The youtube-dl command does NOT work without setting the binPath - not found - and when it is set the above error occurs.

The youtube-dl is found and works by calling a straight shell_exec on the youtube-dl with video - AND it works from command line - it appears this is entirely something wrong with the package.

I have seen some earlier suggestions of putting the Python path in the set bin path - however this appears to be prior to the Python being embedded in the exe and failed when I tested it.

Any thoughts ?

Error

Fatal error: Uncaught exception 'Symfony\Component\Process\Exception\RuntimeException' with message 'The Process class relies on proc_open, which is not available on your PHP installation.' in /usr/share/nginx/html/m.vuclip.club/vendor/symfony/process/Process.php:147 Stack trace: #0 /usr/share/nginx/html/m.vuclip.club/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(516): Symfony\Component\Process\Process->__construct(Array) #1 /usr/share/nginx/html/m.vuclip.club/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(238): YoutubeDl\YoutubeDl->createProcess(Array) #2 /usr/share/nginx/html/m.vuclip.club/tes.php(15): YoutubeDl\YoutubeDl->download('https://www.you...') #3 {main}

getFilesize not work in other format

hi man !
thanks for your package
i use getFilesize() for get downloaded file size but this option worked in 'bestvideo' format and show file size and return
but when change format option in '18' and download file getFilesize() return null and not return really file size
other option like getTitle() good worked without problem But getFilesize() not
you can help me !
thanks

Download error

Error Output:

Usage: youtube-dl [options] url [url...]

youtube-dl: error: no such option: --print-json

["message":protected]=>
  string(385) "The command "'/usr/bin/youtube-dl' 'https://www.youtube.com/watch?v=oDAw7vW7H0c' '--no-playlist' '--print-json' '--ignore-config' '--continue' '--format=bestvideo'" failed.

How to get all formats?

Hi,

When I fetch the download links, it only gets the highest available format (22). It doesn't show the download links for the other formats.

So how can I get the link for all the video formats?

Edit: I enabled the 'all-formats' option, but apparently this option cannot be used.

High CPU Usage

I've been keeping track of the CPU usage (with htop) while the youtube-dl script is executed, and it spikes to 100% whenever the script runs. If multiple instances of the script are executed at the same time, then it freezes the server.

Why is that? Any way to fix this problem?

Process fails on windows

When trying to use the library on windows, it throws a "ProcessFailedException".
This is the entire error message:

The command "c:\inetpub\wwwroot\youtube-dl.exe --format 137+140/best --simulate --no-playlist --print-json --ignore-config "https://www.youtube.com/watch?v=iGk5fR-t5AU"" failed.

Exit Code: -1073741819(Unknown error)

Working directory: C:\inetpub\wwwroot\storage\assets\downloads

Output:
================


Error Output:
================
Fatal Python error: Failed to initialize Windows random API (CryptoGen)

The command it's trying to execute works fine if I run it manually in the terminal, which makes me think the error is somewhere between the library and the php engine.
I haven't been able to find any solution on google. I'm using the latest version of youtube-dl.exe.

Problem with Linux command

Everything worked until yesterday, now:

Fatal error: Uncaught YoutubeDl\Exception\NotFoundException in /var/www/html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php:173 Stack trace: #0 /var/www/html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(123): YoutubeDl\YoutubeDl->handleException(Object(Symfony\Component\Process\Exception\ProcessFailedException)) #1 /var/www/html/api.php(12): YoutubeDl\YoutubeDl->download('https://www.you...') #2 {main} thrown in /var/www/html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php on line 173

looks like it`s adding a text at the end of command sometime:

youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 --output "%(id)s.%(ext)s" --no-playlist --print-json --ignore-config 'https://www.youtube.com/watch?v=QQcQDbpDH_o'

i`m talking about the " " " thing.
tested on 2 different server both of them on ubuntu 16.04 and 17
both of them are on php 7.0

heroku deploy

please add composer lock

`-----> PHP app detected

! ERROR: Your 'composer.json' lists dependencies inside 'require',

   but no 'composer.lock' was found. Please run 'composer update' to

   re-generate 'composer.lock' if necessary, and commit it into your

   repository. For more information, please refer to the docs at

   https://devcenter.heroku.com/articles/php-support#activation

! Push rejected, failed to compile PHP app.

! Push failed

`

Why this code isn't working?

Why this code isn't working?
Variable $video are empty. All dependencies libraries was updated successfully.
I didn't any changes in my code and it worked few month ago.

                $identity = 'Tiye0BqxJS4';
                $yt = new YoutubeDl([
                    'skip-download' => true,
                    'format' => 'best[ext=mp4]',
                ]);

                $video = $yt->download('https://www.youtube.com/watch?v='.$identity);
                print_r($video);
                exit();

Cant get the audio with video download

HI

sorry to bother you again. when i try to download the video i cant get the audio. any idea why and what i an doing wrong. i am following your example

regards
wasiq

Localhost to Hosting

Hello again,

I really don't know this is issue of youtube-dl-php or not, you are an expert that's why I am asking from you :D

Well, I just copied everything to my hosting and changed bin path and downloads path to

$youtubedl->setBinPath('/home/onlinevi/public_html/bin/youtube-dl.exe'); $youtubedl->setDownloadPath('/home/onlinevi/public_html/downloads');

In error_log I'm getting these errors
Stack trace: #0 /home/onlinevi/public_html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(231): Symfony\Component\Process\Process->__construct(Array) #1 /home/onlinevi/public_html/vendor/norkunas/youtube-dl-php/src/YoutubeDl.php(131): YoutubeDl\YoutubeDl->createProcess(Array) #2 /home/onlinevi/public_html/file-download.php(34): YoutubeDl\YoutubeDl->download('https://www.you...') #3 {main} thrown in /home/onlinevi/public_html/vendor/symfony/process/Process.php on line 147

If you are free, can you help please, what should I do?

P.S: I have cPanel shared hosting...

how to list all the format ?

Hi ,
I have tried to list all format without downloading the video but I got an empty array for format part

$dl = new YoutubeDl\YoutubeDl(
 ['skip-download' => true]
 
 );
 $dl->setDownloadPath('/var/www/.../youtube-dl-test');

return $dl->download('https://www.youtube.com/watch?v=gCYcHz2k5x0');

formats: [
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ }
],
this is my format result

in general on command I use -J to get all the information about the video but here I couldn't do that

Error while trying to download

Hello, im getting HTTP ERROR 500 while using the code mentioned below. Any ideas why?
This is the /var/log/apache2/error.log output:

[Wed Apr 11 23:06:15.339320 2018] [:error] [pid 1491] [client xx.xx.xx.xx:xxxxx] PHP Fatal error: Uncaught Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/youtube-dl' 'https://www.youtube.com/watch?v=XOVI851gAJg' '--no-playlist' '--ignore-config' '--write-info-json' '--extract-audio' '--audio-format=mp3' '--audio-quality=0' '--output=%(title)s.%(ext)s'" failed.\n\nExit Code: 1(General error)\n\nWorking directory: /home/mapmanager\n\nOutput:\n================\n[youtube] XOVI851gAJg: Downloading webpage\n[youtube] XOVI851gAJg: Downloading video info webpage\n[youtube] XOVI851gAJg: Extracting video information\n[youtube] XOVI851gAJg: Downloading js player vflSawkIt\n[info] Writing video description metadata as JSON to: DJ_Khaled_-_I_m_the_One_ft._Justin_Bieber_Quavo_Chance_the_Rapper_Lil_Wayne_Lyrics_Lyric_Video.info.json\n\n\nError Output:\n================\nWARNING: Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.\nWARNING: Writing cache to u'/var/www/.cache/youtube-dl/youtube-sigfuncs/js_vflSawkIt in /var/www/html/ytconverter/vendor/symfony/process/Process.php on line 239

PHP:

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

use YoutubeDl\YoutubeDl;

$dl = new YoutubeDl([
    'extract-audio' => true,
    'audio-format' => 'mp3',
    'audio-quality' => 0, // best
    'output' => '%(title)s.%(ext)s',
]);
$dl->setDownloadPath('/home/mapmanager');

$video = $dl->download('https://www.youtube.com/watch?v=XOVI851gAJg');

Bad \SplFileInfo instance when extracting audio

$yt = new \YoutubeDl\YoutubeDl([
    'extract-audio' => true,
    'audio-format' => 'mp3',
    'audio-quality' => 0,
    'output' => '%(id)s.%(ext)s',
]);

$a = $yt->download('https://www.youtube.com/watch?v=IwYm1m1rKd8');
$basename = $a->getBasename(); // IwYm1m1rKd8.webm while it should be IwYm1m1rKd8.mp3

Define get-* options

Why can't I use the youtube-dl options "--get-duration", "--get-title". .... with this? Or is there another way? I'm like checking if the video is already downloaded, if it is then i want the duration, title and path from it.

added quotes to output file

Since version v0.3.4 extra quotes are being added to files.

$youtubeDl = new YoutubeDl([
            'format' => $config['format'],
            'output' => '%(id)s.%(ext)s',
            'force-ipv4' => true,
        ]);
        $youtubeDl->setDownloadPath($this->path->getPath(false));
        $youtubeDl->setTimeout(60);

        $result = $youtubeDl->download($video);

The file is being saved as "3tmd-ClpJxA.mp4" (including quotes)

Syntax error: ")" unexpected

hi

I am stuck with this error .What this is ? Any thing that i am missing ?

Message: The command "'/var/www/html/apps/coredev/usr/local/bin/youtube-dl.exe' 'https://www.viki.com/videos/1119776v-trailer-3' '--skip-download' '--no-playlist' '--ignore-config' '--write-info-json' '--write-sub' '--write-auto-sub' '--abort-on-error' '--skip-download' '--all-subs'" failed. Exit Code: 2(Misuse of shell builtins) Working directory: /var/www/html/apps/coredev/downloads Output: ================ Error Output: ================ /var/www/html/apps/coredev/usr/local/bin/youtube-dl.exe: 1: /var/www/html/apps/coredev/usr/l ocal/bin/youtube-dl.exe: MZ������@������: not found /var/www/html/apps/coredev/usr/local/bin/youtube-dl.exe: 2: /var/www/html/apps/coredev/usr/local/bin/youtube-dl.exe: $��}�Ŷ�HŶ�HŶ�H�+�HǶ�H�+�HĶ�H�+�HǶ�H�΀H¶�HŶ�H���H�+�H߶�H�+�HĶ�H�+�HĶ�H�+�HĶ�HRichŶ�HPEL��OzFT�����: not found /var/www/html/apps/coredev/usr/local/bin/youtube-dl.exe: 3: /var/www/html/apps/coredev/usr/local/bin/youtube-dl.exe: Syntax error: ")" unexpected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.