コード例 #1
0
ファイル: api.php プロジェクト: ridho1991/alltube
 *
 * @category Youtube-dl
 * @package  Youtubedl
 * @author   Pierre Rudloff <*****@*****.**>
 * @license  GNU General Public License http://www.gnu.org/licenses/gpl.html
 * @link     http://rudloff.pro
 * */
require_once 'common.php';
$smarty->assign('class', 'video');
require_once 'download.php';
if (isset($_GET["url"])) {
    if (isset($_GET['audio'])) {
        $video = VideoDownload::getJSON($_GET["url"]);
        if (isset($video->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') {
                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) . '   |  ' . AVCONV . ' -v quiet -i - -f mp3 -vn pipe:1');
                exit;
            } else {
                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) . '   |  ' . AVCONV . ' -v quiet -i - -f mp3 -vn pipe:1');
                exit;
            }
        } else {
            $error = true;
コード例 #2
0
 /**
  * Test getUA function
  * @return void
  */
 public function testGetUA()
 {
     $this->assertStringStartsWith('Mozilla/', VideoDownload::getUA());
 }