本文整理汇总了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);
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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!!!");
}
}
示例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);
}
示例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;
}
示例9: YoutubeRetriever
import com.google.gdata.client.youtube.YouTubeService; //导入依赖的package包/类
public YoutubeRetriever(String clientId, String developerKey) {
this.service = new YouTubeService(clientId, developerKey);
}