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

Java YouTubeService类代码示例

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

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



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

示例1: youTubeSearch

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
/** returns an Item object given a keyword */
private Item youTubeSearch(String kw) throws Exception {
    // init service
    YouTubeService service = new YouTubeService(APP_NAME);
    YouTubeQuery query = new YouTubeQuery(new URL(FEED_URL));
    
    // order results by the relevance
    query.setOrderBy(ORDER_BY_PARAM);

    // search for keyword
    query.setFullTextQuery(kw);
    query.setMaxResults(MAX_SEARCH_RESULTS);
    query.setSafeSearch(SAFE_SEARCH_PARAM);

    // retrieve results
    VideoFeed videoFeed = service.query(query, VideoFeed.class);
    String content = localizeVideoFeed(videoFeed);
    return new Item(kw, content);
}
 
开发者ID:wzhishen,项目名称:youtube-cache,代码行数:20,代码来源:YouTubeClient.java


示例2: publish

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
@Override
public void publish(NodeRef nodeToPublish, Map<QName, Serializable> properties)
{
    YouTubeService service = youTubeHelper.getYouTubeServiceFromChannelProperties(properties);
    if (service != null)
    {
        try
        {
            uploadVideo(service, nodeToPublish);
        }
        catch (Exception ex)
        {
            log.error("Failed to send asset to YouTube", ex);
            throw new AlfrescoRuntimeException("exception.publishing.youtube.publishFailed", ex);
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:18,代码来源:YouTubeChannelType.java


示例3: unpublish

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
@Override
public void unpublish(NodeRef nodeToUnpublish, Map<QName, Serializable> properties)
{
    YouTubeService service = youTubeHelper.getYouTubeServiceFromChannelProperties(properties);
    if (service != null)
    {
        try
        {
            removeVideo(service, nodeToUnpublish);
        }
        catch (Exception ex)
        {
            log.error("Failed to remove asset from YouTube", ex);
            throw new AlfrescoRuntimeException("exception.publishing.youtube.unpublishFailed", ex);
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:18,代码来源:YouTubeChannelType.java


示例4: removeVideo

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
private void removeVideo(YouTubeService service, NodeRef nodeRef) throws MalformedURLException, IOException,
        ServiceException
{
    NodeService nodeService = getNodeService();
    if (nodeService.hasAspect(nodeRef, YouTubePublishingModel.ASPECT_ASSET))
    {
        String youtubeId = (String) nodeService.getProperty(nodeRef, PublishingModel.PROP_ASSET_ID);
        if (youtubeId != null)
        {
            String videoEntryUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads/" + youtubeId;
            VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class);
            videoEntry.delete();
            nodeService.removeAspect(nodeRef, YouTubePublishingModel.ASPECT_ASSET);
            nodeService.removeAspect(nodeRef, PublishingModel.ASPECT_ASSET);
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:18,代码来源:YouTubeChannelType.java


示例5: retrieveVideos

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
public List<YouTubeVideo> retrieveVideos(String textQuery, int maxResults, boolean filter, int timeout, int startIndex) throws Exception {

      YouTubeService service = new YouTubeService(clientID);
      service.setConnectTimeout(timeout); // millis
      YouTubeQuery query = new YouTubeQuery(new URL(YOUTUBE_URL));

      query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);
      query.setFullTextQuery(textQuery);
      query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
      query.setMaxResults(maxResults);
      query.setStartIndex(startIndex);
      query.addCustomParameter(new Query.CustomParameter("hd", "true"));

      VideoFeed videoFeed = service.query(query, VideoFeed.class);  
      List<VideoEntry> videos = videoFeed.getEntries();

      return convertVideos(videos);

  }
 
开发者ID:hamdikavak,项目名称:youtube-search-tool,代码行数:20,代码来源:YouTubeManager.java


示例6: YouTubeAgent

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
/**
 * Konštruktor triedyy YouTubeAgent.
 * @param userName - prihlasovacie meno do webovej služby YouTube
 * @param Password - heslo do webovej služby YouTube
 */
public YouTubeAgent(String userName, String Password){
    try {
        service = new YouTubeService("YouTubeAgent for GPSWebApp", "AI39si4T3ipzbmmskeC0gh9sl094LAw1aJZFf3OtA82N2tyfpnAyUxBxkHoQYu1WgCyuqFSPlrWokd8I7-B4wtTimBU2dIHLHA");
        service.setUserCredentials(userName, Password);
    } catch (AuthenticationException ex) {
        System.out.println("ERROR: Cannot connect to YouTube Service!!! Bad Login or Pass!!!");
    }
}
 
开发者ID:lp190zn,项目名称:gTraxxx,代码行数:14,代码来源:YouTubeAgent.java


示例7: execute

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse response)
		throws Exception {

	Facade facade = Facade.getInstance();
	int idActivity = Integer.valueOf(request.getParameter("idActivity"));

	VideoIriz video = facade.getVideoByID(idActivity);
	String status = "activities.video.status.ok";
	String okStatus = "activities.video.status.ok";
	String watchLink = "";

	if (video.isUploaded()) {

		YouTubeService service = new YouTubeService(
				"ytapi-Amadeus-Amadeus-31t3bfbl-0",
				"AI39si4lPYVDXG8xROx-bAoe-vIODvTOcucDwRb-"
						+ "_2Ty6pesAsS3R2ybTp6D44a4FZy3Wi0dqls44Cur0-qiuDLCNdihPYBRmw");

		service.setAuthSubToken("CIyFvq-NDRCrmPDjBQ", null);

		String feedUrl = "http://gdata.youtube.com/feeds/api/users/amadeuslms/uploads";

		VideoFeed videoFeed;
		VideoEntry entry = null;
		try {
			videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class);

			for (VideoEntry videoInstance : videoFeed.getEntries()) { //search for the video entry
				if (UtilActivities.getVideoId(videoInstance.getId())
						.equals(video.getYoutubeId())) {
					entry = videoInstance;
				}
			}
			
			if(entry == null){
				status = "activities.video.status.invalidURL";
			}
			if (entry.isDraft()) {
				YtPublicationState pubState = entry.getPublicationState();
			if (pubState.getState() == YtPublicationState.State.PROCESSING) {
				status = "activities.video.status.processing";
			} else if (pubState.getState() == YtPublicationState.State.REJECTED) {
				status = "activities.video.status.rejected";
				//System.out.println(pubState.getDescription()); // why it was rejected
				//System.out.print("For help visit: ");
				//System.out.println(pubState.getHelpUrl());
			} else if (pubState.getState() == YtPublicationState.State.FAILED) {
				status = "activities.video.status.failed";
				//System.out.println(pubState.getDescription()); //why it failed
				//System.out.print("For help visit: ");
				//System.out.println(pubState.getHelpUrl());
			}
		}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	if(status.equals("activities.video.status.ok")){
		watchLink = "<a onclick='watchVideo" +
		"('"+ request.getContextPath() +"/jsp/course/content_management" +
		"/activities/video/iriz.jsp?idVideo="+ video.getYoutubeId() +"');' href='javascript" +
		":void(0);' ><bean:message key='activities.video.watch' /></a>";
	}else{
		watchLink = "<bean:message key='activities.video.watch' />";
	}

	request.setAttribute("watchLink", watchLink);
	request.setAttribute("video", video);
	request.setAttribute("status", status);
	request.setAttribute("okStatus", okStatus);
	
	return mapping.findForward(FORWARD_VIDEO_STATUS);
}
 
开发者ID:ProjetoAmadeus,项目名称:AmadeusLMS,代码行数:78,代码来源:ShowVideoIrizStatusAction.java


示例8: lookupVideo

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
public List<String> lookupVideo(String searchTerm) throws IOException, ServiceException {
    List<String> results = new ArrayList<String>();
    YouTubeService service = new YouTubeService("savetheenvironment");

    YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
    query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT);


    query.setFullTextQuery(searchTerm);

    query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);

    VideoFeed videoFeed = service.query(query, VideoFeed.class);

    for (VideoEntry videoEntry : videoFeed.getEntries()) {
        results.add(videoEntry.getTitle().getPlainText());
    }

    return results;
}
 
开发者ID:joshlong,项目名称:adaptive-spring,代码行数:21,代码来源:VideoSearchYouTube.java


示例9: YoutubeRetriever

import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
public YoutubeRetriever(String clientId, String developerKey) {	
	this.service = new YouTubeService(clientId, developerKey);
}
 
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:4,代码来源:YoutubeRetriever.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MEMM类代码示例发布时间:2022-05-22
下一篇:
Java Header类代码示例发布时间: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