Alltube\VideoDownload::getFilename PHP Method

getFilename() public method

Get filename of video file from URL of page.
public getFilename ( string $url, string $format = null ) : string
$url string URL of page
$format string Format to use for the video
return string Filename of extracted video
    public function getFilename($url, $format = null)
    {
        return trim($this->getProp($url, $format, 'get-filename'));
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Dislay information about the video
  * @return void
  */
 static function video()
 {
     global $app;
     $config = Config::getInstance();
     if (isset($_GET["url"])) {
         if (isset($_GET['audio'])) {
             try {
                 $video = VideoDownload::getJSON($_GET["url"]);
                 //Vimeo needs a correct user-agent
                 $UA = VideoDownload::getUA();
                 ini_set('user_agent', $UA);
                 $url_info = parse_url($video->url);
                 if ($url_info['scheme'] == 'rtmp') {
                     ob_end_flush();
                     header('Content-Disposition: attachment; filename="' . html_entity_decode(pathinfo(VideoDownload::getFilename($video->webpage_url), PATHINFO_FILENAME) . '.mp3', ENT_COMPAT, 'ISO-8859-1') . '"');
                     header("Content-Type: audio/mpeg");
                     passthru('/usr/bin/rtmpdump -q -r ' . escapeshellarg($video->url) . '   |  ' . $config->avconv . ' -v quiet -i - -f mp3 -vn pipe:1');
                     exit;
                 } else {
                     ob_end_flush();
                     header('Content-Disposition: attachment; filename="' . html_entity_decode(pathinfo(VideoDownload::getFilename($video->webpage_url), PATHINFO_FILENAME) . '.mp3', ENT_COMPAT, 'ISO-8859-1') . '"');
                     header("Content-Type: audio/mpeg");
                     passthru('curl  --user-agent ' . escapeshellarg($UA) . ' ' . escapeshellarg($video->url) . '   |  ' . $config->avconv . ' -v quiet -i - -f mp3 -vn pipe:1');
                     exit;
                 }
             } catch (\Exception $e) {
                 $error = $e->getMessage();
             }
         } else {
             try {
                 $video = VideoDownload::getJSON($_GET["url"]);
                 $app->render('head.tpl', array('class' => 'video'));
                 $app->render('video.tpl', array('video' => $video));
                 $app->render('footer.tpl');
             } catch (\Exception $e) {
                 $error = $e->getMessage();
             }
         }
     }
     if (isset($error)) {
         $app->render('head.tpl', array('class' => 'video'));
         $app->render('error.tpl', array('errors' => $error));
         $app->render('footer.tpl');
     }
 }
All Usage Examples Of Alltube\VideoDownload::getFilename