定制 flatbits/youstraw 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flatbits/youstraw

最新稳定版本:0.1.0

Composer 安装命令:

composer require flatbits/youstraw

包简介

PHP Youtube Audio and Video Extractor

README 文档

README

Extract a Tube Straw from YouTube

This experiment is not supported anymore and will probably not received any update in the future

Important : Since the data we need is not provided by Google's official API, this library does not require you to provide an API key or any other credentials. However, the the library heavily relies on undocumented APIs and DOM parsing. For these reason, I do not recommend the use of this library in mission critical environment since it can break at any moment from a change in YouTube's code

Installation

Install the latest version via Composer

composer require flatbits/youstraw

Include Composer's autoload file, and don't forget to add the use statements

require_once('./vendor/autoload.php');
use FlatBits\YouStraw\Straw;

Optional Requirement

  • FFmpeg - Some formats are not directly delivered from YouTube, this library requires FFmpeg for those Converted formats

Usage

Download a single video
<?php
require_once('./vendor/autoload.php');
use FlatBits\YouStraw\Format;
use FlatBits\YouStraw\Format\Mp4;
use FlatBits\YouStraw\Straw;

$videoId = 'xEoMC7czIxA';

// Create a Straw, the handle to our video
$straw = new Straw($videoId);

// Download a high quality (720p) mp4 to the video dir.
$straw->download('../cache/video', new Mp4(Format::QUALITY_HIGH));
// Make sure the script has write access to the specified directory.
Download music from a playlist
<?php
require_once('../vendor/autoload.php');
use FlatBits\YouStraw\Format;
use FlatBits\YouStraw\Format\Mp3;
use FlatBits\YouStraw\StrawCollection;

$playlistId = 'PLDoXbhQs-J6TMo69UeDvlxmDf7nkR8OSm';

// Create the StrawCollection, a helper for batch downloads and playlist parsing
$strawCollection = StrawCollection::fromPlaylist($playlistId);

// Download the collection mp3 files to the music dir.
$strawCollection->downloadAll('../cache/music', new Mp3());

Please look in the examples folder or through the source code for further usage.

Formats

Natives

Those format are directly fetched from YouTube
Format Available qualities
Mp4 High, Medium
WebM Medium
Flv Low
ThreeGP (3gp) Low

Converted

Those format are converted from a video, you will need FFmpeg on your system to use these formats.

Audio

Format Available qualities
Mp3 High, Medium
Flac High, Medium

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-23