Credential credential = getCredentials();
youTube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName("Playlist Web App").build();
YouTube.Playlists.List searchList = youTube.playlists().list("id,snippet,contentDetails");
searchList.setFields("etag,eventId,items(contentDetails,etag,id,kind,player,snippet,status),kind,nextPageToken,pageInfo,prevPageToken,tokenPagination");
searchList.setMine(true);
searchList.setMaxResults((long) 10);
PlaylistListResponse playListResponse = searchList.execute();
List<Playlist> playlists = playListResponse.getItems();
if (playlists != null) {
Iterator<Playlist> iteratorPlaylistResults = playlists.iterator();
if (!iteratorPlaylistResults.hasNext()) {
System.out.println(" There aren't any results for your query.");
}
while (iteratorPlaylistResults.hasNext()) {
Playlist playlist = iteratorPlaylistResults.next();
System.out.println(" Playlist Id : " + playlist.getId());
System.out.println(" Title: " + playlist.getSnippet().getTitle());
}
}