norkunas / youtube-dl-php

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

Is it possible changing options on the fly ? #128

Closed promotion closed 4 years ago

promotion commented 4 years ago

Hi @norkunas ! Once again - thanks for your lib - works just fine for me !

Do you think it is possible changing options on the fly? In my case , i need changing filename ('output' => 'Newfilename_with_getDisplayId_string') AFTER i grab file info with $infovid=$dl->getInfo($url);

however trying to access $options would generate error: Cannot access protected property YoutubeDl\YoutubeDl::$options

To make it even more clearer code example :

 $dl = new YoutubeDl([
            'continue' => true, 
            'output' => 'TemporaryFilename.%(ext)s',
            'restrict-filenames' => true,
        ]);

//get information on video:
$infovid=$dl->getInfo($url);

//this would generate new filename based on video ID
$newFileName= $this->generateNewFilename($infovid->getDisplayId());

//THIS LINE WONT WORK, BUT THATS WHAT I ACTUALLY NEED:
 $dl->options['output']=$newFileName

//this would download to a NEW genarated filename.
$finalvideo = $dl->download($url);

Hope it makes snce, and easy doable :) Thanks in advance !

norkunas commented 4 years ago

Hey, just instantiate a new instance, its not that heavy :)

promotion commented 4 years ago

OK, just thought maybe its somehow implemented in a faster way :)

norkunas commented 4 years ago

Note: from v2 this will be possible.