2017 © Pedro Peláez
 

library youstraw

PHP Youtube Audio and Video Extractor

image

flatbits/youstraw

PHP Youtube Audio and Video Extractor

  • Friday, November 11, 2016
  • by Titoeuf
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

YouStraw

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, (*1)

Installation

Install the latest version via Composer, (*2)

composer require flatbits/youstraw

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

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., (*4)

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

The Versions

11/11 2016

dev-master

9999999-dev https://github.com/FlatBits/YouStraw

PHP Youtube Audio and Video Extractor

  Sources   Download

MIT

The Requires

 

05/10 2015
04/10 2015

dev-async-download

dev-async-download https://github.com/FlatBits/YouStraw

PHP Youtube Audio and Video Extractor

  Sources   Download

MIT

The Requires

 

23/09 2015