• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Channel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.api.services.youtube.model.Channel的典型用法代码示例。如果您正苦于以下问题:Java Channel类的具体用法?Java Channel怎么用?Java Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Channel类属于com.google.api.services.youtube.model包,在下文中一共展示了Channel类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getChannelForUser

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
@Override
public Channel getChannelForUser(String userId)
{
	try
	{
		YouTube.Channels.List channels = getTubeService().channels().list("snippet");
		channels.setKey(getApiKey());
		channels.setForUsername(userId);
		ChannelListResponse channelListResponse = channels.execute();

		List<Channel> items = channelListResponse.getItems();

		return Check.isEmpty(items) ? null : items.get(0);
	}
	catch( Exception ex )
	{
		throw Throwables.propagate(ex);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:GoogleServiceImpl.java


示例2: getChannels

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
@Override
public List<Channel> getChannels(List<String> channelIds)
{
	try
	{
		YouTube.Channels.List channels = getTubeService().channels().list("snippet");
		channels.setKey(getApiKey());
		channels.setId(Joiner.on(",").join(channelIds));
		ChannelListResponse channelListResponse = channels.execute();

		return channelListResponse.getItems();
	}
	catch( Exception ex )
	{
		throw Throwables.propagate(ex);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:GoogleServiceImpl.java


示例3: createAttachments

import com.google.api.services.youtube.model.Channel; //导入依赖的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: getMyChannel

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
/**
 * Gets the {@link Channel} reference for the own channel.
 * @param connection {@link YouTubeConnection} instance which stands for the
 * authorized youtube connection
 * @return {@list Channel} instance which can be used for creating requests
 * to the own channel
 * @throws IOException Can't connect to youtub or can't executing request.
 * @since 1.0
 */
public static Channel getMyChannel(final YouTubeConnection connection) throws
        IOException {
    final YouTube.Channels.List channelRequest = connection.getYouTube()
            .channels().list("contentDetails");
    channelRequest.setMine(Boolean.TRUE);
    channelRequest.setFields("items/contentDetails, items/id");
    channelRequest.setMaxResults(1L);
    final ChannelListResponse response = channelRequest.execute();

    return response.getItems().get(0);
}
 
开发者ID:LehmRob,项目名称:FeedMeYoutube,代码行数:21,代码来源:CrawlerUtils.java


示例5: YoutubeChannel

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
public YoutubeChannel(Channel c) {
    setId(Sources.YOUTUBE + '#' + c.getId());
    source = Sources.YOUTUBE;
    name = c.getSnippet().getTitle();
    description = c.getSnippet().getDescription();
    com.google.api.services.youtube.model.Thumbnail t = c.getSnippet().getThumbnails().getDefault();
    setAvatarBig(t.getUrl());
    ChannelStatistics s = c.getStatistics();
    if (s != null) {
        setNumFollowers(s.getSubscriberCount().intValue());
    }
    pageUrl = "https://www.youtube.com/channel/" + c.getId();
    numItems = s.getVideoCount().intValue();
    creationDate = new Date(c.getSnippet().getPublishedAt().getValue());
}
 
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:16,代码来源:YoutubeChannel.java


示例6: getChannel

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
@Override
public Channel getChannel(String channelId)
{
	List<Channel> channels = getChannels(Lists.newArrayList(channelId));
	return Check.isEmpty(channels) ? null : channels.get(0);
}
 
开发者ID:equella,项目名称:Equella,代码行数:7,代码来源:GoogleServiceImpl.java


示例7: YoutubeVideo

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
public YoutubeVideo(com.google.api.services.youtube.model.Video v, Channel c) {
    this(v);
    setContributor(new YoutubeChannel(c));
}
 
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:5,代码来源:YoutubeVideo.java


示例8: fetch

import com.google.api.services.youtube.model.Channel; //导入依赖的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


示例9: getChannel

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
Channel getChannel(String channelId); 
开发者ID:equella,项目名称:Equella,代码行数:2,代码来源:GoogleService.java


示例10: getChannelForUser

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
Channel getChannelForUser(String userId); 
开发者ID:equella,项目名称:Equella,代码行数:2,代码来源:GoogleService.java


示例11: getChannels

import com.google.api.services.youtube.model.Channel; //导入依赖的package包/类
List<Channel> getChannels(List<String> channelIds); 
开发者ID:equella,项目名称:Equella,代码行数:2,代码来源:GoogleService.java



注:本文中的com.google.api.services.youtube.model.Channel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClearTextPasswordEncryptor类代码示例发布时间:2022-05-22
下一篇:
Java VerbatimNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap