Alltube\VideoDownload::getAudioFilename PHP Méthode

getAudioFilename() public méthode

Get filename of audio from URL of page.
public getAudioFilename ( string $url, string $format = null ) : string
$url string URL of page
$format string Format to use for the video
Résultat string Filename of converted audio file
    public function getAudioFilename($url, $format = null)
    {
        return html_entity_decode(pathinfo($this->getFilename($url, $format), PATHINFO_FILENAME) . '.mp3', ENT_COMPAT, 'ISO-8859-1');
    }

Usage Example

Exemple #1
0
 /**
  * Dislay information about the video.
  *
  * @param Request  $request  PSR-7 request
  * @param Response $response PSR-7 response
  *
  * @return Response HTTP response
  */
 public function video(Request $request, Response $response)
 {
     $params = $request->getQueryParams();
     $this->config = Config::getInstance();
     if (isset($params['url'])) {
         if (isset($params['audio'])) {
             try {
                 $url = $this->download->getURL($params['url'], 'mp3[protocol^=http]');
                 return $response->withRedirect($url);
             } catch (\Exception $e) {
                 $response = $response->withHeader('Content-Disposition', 'attachment; filename="' . $this->download->getAudioFilename($params['url'], 'bestaudio/best') . '"');
                 $response = $response->withHeader('Content-Type', 'audio/mpeg');
                 if ($request->isGet()) {
                     $process = $this->download->getAudioStream($params['url'], 'bestaudio/best');
                     $response = $response->withBody(new Stream($process));
                 }
                 return $response;
             }
         } else {
             $video = $this->download->getJSON($params['url']);
             if ($this->container instanceof Container) {
                 $this->container->view->render($response, 'video.tpl', ['video' => $video, 'class' => 'video', 'title' => $video->title, 'description' => 'Download "' . $video->title . '" from ' . $video->extractor_key]);
             }
         }
     } else {
         return $response->withRedirect($this->container->get('router')->pathFor('index'));
     }
 }
All Usage Examples Of Alltube\VideoDownload::getAudioFilename