Hi all,
YouTubeFeed requests videos from an authenticated YouTube 'My Uploads' feed and converts them into YouTubeVideo DataObjects.
https://github.com/Little-Giant/silverstripe-youtubefeed
Features:
- Configurable auto-update interval (disabled by default)
- CLI task YouTubeFeedTask: "framework/sake YouTubeFeedTask flush=all"
- Stores video information into YouTubeVideo DataObject.
Installation requires creating an application in the Google Developers Console then copying and pasting the api key & secret into the Settings/YouTube tab in your CMS.
Example of using the onAfterCreate hook:
<?php
/**
* Class YouTubeFeedExtension
*
* Decorates YouTubeFeed from silverstripe-youtubefeed to create a blog post for every YouTube video.
*/
class YouTubeFeedExtension extends DataExtension
{
/**
* Create a new BlogPost when a new YouTube video is found in the connected accounts YouTube playlists/"My Uploads" feed
* Sets the PublishDate of the BlogPost to the date the video was published on YouTube
*
* @param YouTubeVideo $videoObject
*/
public function onAfterCreate(YouTubeVideo $videoObject)
{
$blogPost = new BlogPost();
$blogPost->Title = $videoObject->Title;
$blogPost->YouTubeVideoID = $videoObject->ID;
$blogPost->ParentID = Blog::get()->first()->ID;
$blogPost->PublishDate = $videoObject->Published;
$blogPost->write();
$blogPost->publish("Live", "Stage");
}
}