ahaschool/video-dl

ahaschool 为 PHP 下载视频

v1.2 2018-12-16 03:46 UTC

This package is auto-updated.

Last update: 2024-09-16 19:54:05 UTC


README

使用 Composer 安装包装器

composer require ahaschool/video-dl

在您的根目录的 composer.josn 中添加 composer 脚本

"scripts": {
    ...
    "post-install-cmd": "chmod +x vendor/ahaschool/video-dl/bin/youtube-dl"
 }

获取 YouTube 视频URL列表

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

use Ahaschool\Videodl\Youtube\Channel;

$chl = new Channel('user/byjusclasses/videos');
$items = $chl->initVideoItems()->getItems();

通过视频密钥下载 YouTube 视频

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

use Ahaschool\Videodl\Youtube\Download;

$dl = new Download('./');
try {
    $video = $dl->dl('WPOoNZbT-1w');
} catch (\Exception $e) {
    echo $e->getMessage();
}