use of com.google.api.services.youtube.model.VideoListResponse in project opencast by opencast.
the class YouTubeAPIVersion3ServiceImpl method getVideoById.
@Override
public Video getVideoById(final String videoId) throws IOException {
final YouTube.Videos.List search = youTube.videos().list("id,snippet");
search.setId(videoId);
search.setFields("items(id,kind,snippet),nextPageToken,pageInfo,prevPageToken,tokenPagination");
final VideoListResponse response = execute(search);
return response.getItems().isEmpty() ? null : response.getItems().get(0);
}
use of com.google.api.services.youtube.model.VideoListResponse in project api-samples by youtube.
the class VideoLocalizations method getVideoLocalization.
/**
* Returns localized metadata for a video in a selected language.
* If the localized text is not available in the requested language,
* this method will return text in the default language.
*
* @param videoId The id parameter specifies the video ID for the resource
* that is being updated.
* @param language The language of the localized metadata
* @throws IOException
*/
private static void getVideoLocalization(String videoId, String language) throws IOException {
// Call the YouTube Data API's videos.list method to retrieve videos.
VideoListResponse videoListResponse = youtube.videos().list("snippet").setId(videoId).set("hl", language).execute();
// Since the API request specified a unique video ID, the API
// response should return exactly one video. If the response does
// not contain a video, then the specified video ID was not found.
List<Video> videoList = videoListResponse.getItems();
if (videoList.isEmpty()) {
System.out.println("Can't find a video with ID: " + videoId);
return;
}
Video video = videoList.get(0);
// Print information from the API response.
System.out.println("\n================== Video ==================\n");
System.out.println(" - ID: " + video.getId());
System.out.println(" - Title(" + language + "): " + video.getLocalizations().get(language).getTitle());
System.out.println(" - Description(" + language + "): " + video.getLocalizations().get(language).getDescription());
System.out.println("\n-------------------------------------------------------------\n");
}
Aggregations