YouTube
The youtube module lets editors search and import videos from YouTube through Brightspot's federated search, optionally scoped to a single channel.
Dependencies
Depends on db-http and the YouTube Data API v3, through Google's official Java client.
Installation
- Maven
- Gradle
- Gradle (Kotlin DSL)
<!-- Requires Brightspot 5.0 or later. -->
<dependency>
<groupId>com.brightspot.dbhttp</groupId>
<artifactId>youtube</artifactId>
<version>1.0.0</version>
</dependency>
// Requires Brightspot 5.0 or later.
implementation 'com.brightspot.dbhttp:youtube:1.0.0'
// Requires Brightspot 5.0 or later.
implementation("com.brightspot.dbhttp:youtube:1.0.0")
API reference
com.psddev.google.youtube.YouTubeDatabase
Extends HttpDatabase. Searches YouTube videos, optionally scoped to a configured channel Id, and returns up to 50 results per page — the maximum YouTube's API allows in a single request.
com.psddev.google.youtube.YouTubeVideo
Extends ExternalItem.
| Field | Type | Description |
|---|---|---|
youTubeId | String | The YouTube video Id. |
publishedAt | Date | When the video was published on YouTube. |
title | String | The video title. |
description | String | The video description. |
channelName | String | The publishing channel's name. |
channelId | String | The publishing channel's Id. |
thumbnailUrl | String | A thumbnail image URL. |
tags | List<String> | Tags applied to the video on YouTube. |
duration | String | The video duration. |
dimension | String | Whether the video is 2D or 3D. |
Sort order is set through the YouTubeVideoSort enum: RELEVANCE, TITLE, DATE, RATING, or VIEW_COUNT.
Configuration
Credentials are stored on com.psddev.google.youtube.YouTubeApiClient (name, apiKey, channelId), referenced from YouTubeSettings, a Modification<SiteSettings> shown under Site Settings > Integrations > YouTube. Leaving channelId blank searches all of YouTube; setting it restricts every search on that site to the specified channel.
Extending the plugin
The module doesn't ship a content type for imported videos. To let editors create one from search results, define a content type and extend ExternalItemConverter<YouTubeVideo, T> to convert the external item into it on import. (The web module's demo application includes an example, YoutubeUrlVideoConverter, that converts to a lightweight YouTubeUrlVideo type storing only the video's URL—it isn't part of the published youtube artifact.)