本文整理汇总了Java中com.google.api.services.youtube.model.Thumbnail类的典型用法代码示例。如果您正苦于以下问题:Java Thumbnail类的具体用法?Java Thumbnail怎么用?Java Thumbnail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Thumbnail类属于com.google.api.services.youtube.model包,在下文中一共展示了Thumbnail类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: prettyPrint
import com.google.api.services.youtube.model.Thumbnail; //导入依赖的package包/类
private static void prettyPrint(Iterator<SearchResult> iteratorSearchResults, String query) {
//
// " First " + NUMBER_OF_VIDEOS_RETURNED + " videos for search on \"" + query + "\".");
//
// if (!iteratorSearchResults.hasNext()) {
// System.out.println(" There aren't any results for your query.");
// }
while (iteratorSearchResults.hasNext()) {
SearchResult singleVideo = iteratorSearchResults.next();
ResourceId rId = singleVideo.getId();
// Confirm that the result represents a video. Otherwise, the
// item will not contain a video ID.
if (rId.getKind().equals("youtube#video")) {
Thumbnail thumbnail = singleVideo.getSnippet().getThumbnails().getDefault();
System.out.println(" Video Id" + rId.getVideoId());
System.out.println(" Title: " + singleVideo.getSnippet().getTitle());
System.out.println(" Thumbnail: " + thumbnail.getUrl());
System.out.println("\n-------------------------------------------------------------\n");
}
}
}
开发者ID:EUMSSI,项目名称:EUMSSI-platform,代码行数:26,代码来源:Search.java
示例2: thumbnailURL
import com.google.api.services.youtube.model.Thumbnail; //导入依赖的package包/类
private String thumbnailURL(ThumbnailDetails details) {
String result = null;
if (details != null) {
Thumbnail thumbnail = details.getMaxres();
// is this necessary? not sure
if (thumbnail == null) {
thumbnail = details.getHigh();
}
if (thumbnail == null) {
thumbnail = details.getDefault();
}
if (thumbnail != null) {
result = thumbnail.getUrl();
}
}
return result;
}
开发者ID:sgehrman,项目名称:UTubeTV,代码行数:23,代码来源:YouTubeAPI.java
示例3: createAttachments
import com.google.api.services.youtube.model.Thumbnail; //导入依赖的package包/类
@Override
protected List<Attachment> createAttachments(SectionInfo info)
{
List<Attachment> attachments = Lists.newArrayList();
List<String> videoIds = Lists.newArrayList(results.getSelectedValuesAsStrings(info));
List<Video> videos = google.getVideos(videoIds);
for( Video v : videos )
{
CustomAttachment a = new CustomAttachment();
Channel channel = google.getChannel(v.getSnippet().getChannelId());
a.setType(YoutubeUtils.ATTACHMENT_TYPE);
Thumbnail defaultThumb = v.getSnippet().getThumbnails().getDefault();
a.setData(YoutubeUtils.PROPERTY_THUMB_URL, defaultThumb.getUrl());
a.setThumbnail(defaultThumb.getUrl());
a.setData(YoutubeUtils.PROPERTY_PLAY_URL, "//www.youtube.com/v/" + v.getId());
a.setData(YoutubeUtils.PROPERTY_ID, v.getId());
a.setData(YoutubeUtils.PROPERTY_DURATION, v.getContentDetails().getDuration());
a.setData(YoutubeUtils.PROPERTY_AUTHOR, channel.getSnippet().getTitle());
DateTime uploaded = v.getSnippet().getPublishedAt();
if( uploaded != null )
{
a.setData(YoutubeUtils.PROPERTY_DATE, uploaded.getValue());
}
String title = v.getSnippet().getTitle();
a.setData(YoutubeUtils.PROPERTY_TITLE, title);
a.setDescription(title);
attachments.add(a);
}
return attachments;
}
开发者ID:equella,项目名称:Equella,代码行数:37,代码来源:YoutubeHandler.java
示例4: YoutubeVideo
import com.google.api.services.youtube.model.Thumbnail; //导入依赖的package包/类
public YoutubeVideo(com.google.api.services.youtube.model.Video v) {
setId(Sources.YOUTUBE + '#' + v.getId());
setSource(Sources.YOUTUBE);
title = v.getSnippet().getTitle();
description = v.getSnippet().getDescription();
creationDate = new Date(v.getSnippet().getPublishedAt().getValue());
crawlDate = new Date();
VideoStatistics statistics = v.getStatistics();
if (statistics != null) {
if(statistics.getFavoriteCount() != null) {
numLikes = statistics.getFavoriteCount().intValue();
}
if(statistics.getViewCount() != null) {
numViews = statistics.getViewCount().intValue();
}
if(statistics.getCommentCount() != null) {
numComments = statistics.getCommentCount().intValue();
}
}
VideoContentDetails details = v.getContentDetails();
if (details != null) {
quality = details.getDefinition();
}
VideoSnippet snippet = v.getSnippet();
Thumbnail t = snippet.getThumbnails().getHigh();
setThumbnail(t.getUrl());
setWidth(t.getWidth().intValue());
setHeight(t.getHeight().intValue());
url = "https://www.youtube.com/watch?v=" + v.getId();
webPageUrl = url;
UserAccount channel = new YoutubeChannel();
channel.setId(Sources.YOUTUBE + '#' + snippet.getChannelId());
channel.setSource(Sources.YOUTUBE);
channel.setUserId(snippet.getChannelId());
channel.setName(snippet.getChannelTitle());
channel.setPageUrl("https://www.youtube.com/channel/" + snippet.getChannelId());
channel.setDescription(snippet.getDescription());
setContributor(channel);
}
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:56,代码来源:YoutubeVideo.java
示例5: fetch
import com.google.api.services.youtube.model.Thumbnail; //导入依赖的package包/类
@Override
public Favicon fetch(Feed feed) {
String url = feed.getUrl();
if (!url.toLowerCase().contains("youtube.com/feeds/videos.xml")) {
return null;
}
String googleAuthKey = config.getApplicationSettings().getGoogleAuthKey();
if (googleAuthKey == null) {
log.debug("no google auth key configured");
return null;
}
byte[] bytes = null;
String contentType = null;
try {
List<NameValuePair> params = URLEncodedUtils.parse(url.substring(url.indexOf("?") + 1), StandardCharsets.UTF_8);
Optional<NameValuePair> userId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("user")).findFirst();
Optional<NameValuePair> channelId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("channel_id")).findFirst();
if (!userId.isPresent() && !channelId.isPresent()) {
return null;
}
YouTube youtube = new YouTube.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(),
new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("CommaFeed").build();
YouTube.Channels.List list = youtube.channels().list("snippet");
list.setKey(googleAuthKey);
if (userId.isPresent()) {
list.setForUsername(userId.get().getValue());
} else {
list.setId(channelId.get().getValue());
}
log.debug("contacting youtube api");
ChannelListResponse response = list.execute();
if (response.getItems().isEmpty()) {
log.debug("youtube api returned no items");
return null;
}
Channel channel = response.getItems().get(0);
Thumbnail thumbnail = channel.getSnippet().getThumbnails().getDefault();
log.debug("fetching favicon");
HttpResult iconResult = getter.getBinary(thumbnail.getUrl(), TIMEOUT);
bytes = iconResult.getContent();
contentType = iconResult.getContentType();
} catch (Exception e) {
log.debug("Failed to retrieve YouTube icon", e);
}
if (!isValidIconResponse(bytes, contentType)) {
return null;
}
return new Favicon(bytes, contentType);
}
开发者ID:Athou,项目名称:commafeed,代码行数:63,代码来源:YoutubeFaviconFetcher.java
示例6: getChannelIcon
import com.google.api.services.youtube.model.Thumbnail; //导入依赖的package包/类
public static String getChannelIcon(String channelId) throws IOException {
YouTube.Channels.List channels = youtube.channels().list("snippet, statistics");
channels.setId(channelId);
ChannelListResponse channelResponse = channels.execute();
Thumbnail thumbnail = (Thumbnail) channelResponse.getItems().get(0).getSnippet().getThumbnails().get("default");
return thumbnail.getUrl();
}
开发者ID:lukas2005,项目名称:Device-Mod-Apps,代码行数:11,代码来源:YoutubeUtils.java
注:本文中的com.google.api.services.youtube.model.Thumbnail类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论