Skip to content

janyksteenbeek/Tubecode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TUBECODE - YouTube API Client

A simple abstraction for the youtube api - providing a fluent api that is powerful and easy to use.

Build Status Code Coverage Total Downloads Latest Stable Version Latest Unstable Version License

Contributing

To encourage active collaboration, TubeCode strongly encourages pull requests, not just bug reports. "Bug reports" may also be sent in the form of a pull request containing a failing unit test.

However, if you file a bug report, your issue should contain a title and a clear description of the issue. You should also include as much relevant information as possible and a code sample that demonstrates the issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix.

Remember, bug reports are created in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the bug report will automatically see any activity or that others will jump to fix it. Creating a bug report serves to help yourself and others start on the path of fixing the problem.

Which Branch?

All bug fixes should be sent to the latest stable branch. Bug fixes should never be sent to the master branch unless they fix features that exist only in the upcoming release.

Minor features that are fully backwards compatible with the current release may be sent to the latest stable branch.

Major new features should always be sent to the master branch, which contains the upcoming api client release.

Coding Style

TubeCode follows the PSR-4 and PSR-1 coding standards. In addition to these standards, the following coding standards should be followed:

  • The class namespace declaration must be on the same line as <?php.
  • A class' opening { must be on the same line as the class name.
  • Functions and control structures must use Allman style braces.
  • Indent with tabs, align with spaces.

Security Vulnerabilities

If you discover a security vulnerability within this API Client, please send an e-mail to Pascal Schwientek at pascal@plsk.de. All security vulnerabilities will be promptly addressed.

Docs

Installation

require the php package in the desired version via composer

php composer.phar require pascal/tubecode

Initialize

To initialize the API client call the create method on the factory.

use Tubecode\YouTube\Factory;

$api = new Factory::create($content_owner, $service_account_name, $key_file);

Upload a Video

To Upload a video you call the uploadVideo($file) method on the Api class. The file must be an instace of Tubecode\Resources\UploadableFile.

$file = new UploadableFile($pathToFile);

$upload = $api->uploadVideo($file);

You can add a configuration for the uploader.

$file = new UploadableFile($pathToFile);
$config = new Tubecode\Resources\Config\VideoUploadConfig(['chunkSizeBytes' => 1 * 1028 * 1028])

$upload = $api->uploadVideo($file, $config);

Available options:

chunkSizeBytes: (int) ## size of the chunks to upload the video

Now you have to configure the video.

$upload->setTitle("My awesome video")
       ->addTag(['thecakeisalie', 'php', 'is', 'awesome'])
       ->public()
       ->category(22)
       ->...

Available methods

public function addTag($tag) //string or array

public function setTags($tag) //string or array

public function setTitle($title) //string

public function setDescription($description) //string

public function category($category)  //int

public function publicVideo()

public function privateVideo()

public function unlistedVideo()

Before you can upload the video you need to specefie the channels the videos should be uploaded to.

NOTE: The channel must be part of the Content Owner you initialized the API client with.

$channel =  new Tubecode\Resources\Channel('CHANNEL_ID');

$upload->to($channel);

or to many channels

$channels = [
    new Tubecode\Resources\Channel('CHANNEL_ID_1');
    new Tubecode\Resources\Channel('CHANNEL_ID_2');
    new Tubecode\Resources\Channel('CHANNEL_ID_3');
    new Tubecode\Resources\Channel('CHANNEL_ID_4');
    new Tubecode\Resources\Channel('CHANNEL_ID_5');
];

$upload->to($channels);

As soon the Video is configured you can start uploading it. This will return an array with all videoIds from youtube.

$videoIds = $upload->start();

TODO for v2 stable release

  • Unit Tests
  • validate video
  • validate video configuration input
  • init client with custom config
  • API for
    • assets
      • reference file upload
    • claims
    • channels
    • videos
    • content owners
  • upload video with watermark or other overlays
  • set thumbnail of video

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages