Package com.google.gdata.data.youtube

Examples of com.google.gdata.data.youtube.YouTubeMediaGroup


      if (title.length() > 60) {
        title = title.substring(0, 59);
      }

      VideoEntry newEntry = new VideoEntry();
      YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();

      mg.setTitle(new MediaTitle());
      mg.getTitle().setPlainTextContent(title);

      mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, assignment.getCategory()));

      mg.setKeywords(new MediaKeywords());

      List<String> tags = new ArrayList<String>();
      for (int i = 0; i < tagsArray.length(); i++) {
        String tag = tagsArray.getString(i).trim();
        mg.getKeywords().addKeyword(tag);
        tags.add(tag);
      }

      // Sort the list of tags and join with "," so that we can easily compare
      // what's in the
      // datastore with what we get back from the YouTube API.
      String sortedTags = util.sortedJoin(tags, ",");

      mg.setDescription(new MediaDescription());
      mg.getDescription().setPlainTextContent(description);

      String applicationNameTag = Util.CLIENT_ID_PREFIX + SystemProperty.applicationId.get();
      if (applicationNameTag.length() > 25) {
        applicationNameTag = applicationNameTag.substring(0, 24) + "!";
      }
      mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, applicationNameTag));

      // Maximum size of a developer tag is 25 characters, and we prepend 2
      // characters.
      if (assignmentId.length() <= 23) {
        // Minimum size of a developer tag is 3 characters, so always append 2
        // characters.
        String assignmentIdTag = String.format("A-%s", assignmentId);

        // Use a developer tag to make it easy for developers to query for all
        // videos uploaded for
        // a given assignment.
        mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, assignmentIdTag));
      } else {
        log.warning(String.format("Assignment id '%s' is longer than 25 characters, and can't be "
            + "used as a developer tag.", assignmentId));
      }
     
View Full Code Here


          tagsArrayList.add(newTag);
          String newTags = util.sortedJoin(tagsArrayList, ",");
          videoSubmission.setVideoTags(newTags);
        }

        YouTubeMediaGroup mg = videoEntry.getOrCreateMediaGroup();
        // This should work as expected even if the tag already exists; No
        // duplicates will be added.
        mg.getKeywords().addKeyword(newTag);
      }

      // Update the datastore entry's description.
      videoSubmission.setVideoDescription(newDescription);
View Full Code Here

      if (uploadsFeed.getEntries().size() > 0) {
        HashMap<String, Map<String, String>> videoIdToMetadata = new HashMap<String, Map<String, String>>();
        for (VideoEntry videoEntry : uploadsFeed.getEntries()) {
          if (!videoEntry.isDraft()) {
            HashMap<String, String> metadata = new HashMap<String, String>();
            YouTubeMediaGroup mediaGroup = videoEntry.getMediaGroup();

            metadata.put("title", mediaGroup.getTitle().getPlainTextContent());
            metadata.put("videoUrl", videoEntry.getHtmlLink().getHref());
            metadata.put("description", mediaGroup.getDescription().getPlainTextContent());
            metadata.put("duration", mediaGroup.getDuration().toString());
            metadata.put("published", videoEntry.getPublished().toUiString());

            List<MediaThumbnail> thumbnails = mediaGroup.getThumbnails();
            if (thumbnails.size() > 0) {
              metadata.put("thumbnailUrl", mediaGroup.getThumbnails().get(0).getUrl());
            }

            videoIdToMetadata.put(videoEntry.getMediaGroup().getVideoId(), metadata);
          }
        }
View Full Code Here

    if (title.length() > 100) {
      title = title.substring(0, 99);
    }

    VideoEntry newEntry = new VideoEntry();
    YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();

    mg.setTitle(new MediaTitle());
    mg.getTitle().setPlainTextContent(title);

    mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "News"));
   
    String keyword = System.getProperty("com.google.tchotchke.Keyword");
    if (keyword != null && keyword.length() > 0) {
      mg.setKeywords(new MediaKeywords());
      mg.getKeywords().addKeyword(keyword);
    }
   
    mg.setDescription(new MediaDescription());
    mg.getDescription().setPlainTextContent("Uploaded in response to " + page +
        "\n\n" + description);
   
    String defaultDeveloperTag = System.getProperty(
        "com.google.tchotchke.DefaultDeveloperTag");
    if (defaultDeveloperTag != null && defaultDeveloperTag.length() > 0) {
      mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME,
          defaultDeveloperTag));
    }
   
    mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME,
        articleId));

    YouTubeApiManager apiManager = new YouTubeApiManager();
    apiManager.setToken(sessionManager.getToken());
View Full Code Here

   */
  private static void printVideoEntry(VideoEntry entry) throws IOException,
      ServiceException {
    System.out.println("Title:" + entry.getTitle().getPlainText());

    YouTubeMediaGroup mediaGroup = entry.getMediaGroup();

    if (mediaGroup != null) {
      if (mediaGroup.isPrivate()) {
        System.out.println("Video is private");
      }
      MediaPlayer player = mediaGroup.getPlayer();
      if (player != null) {
        System.out.println("Video URL: " + player.getUrl());
      }
    }

View Full Code Here

    System.out.println("What should I call this video?");
    String videoTitle = readLine();

    VideoEntry newEntry = new VideoEntry();

    YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();

    mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Tech"));
    mg.setTitle(new MediaTitle());
    mg.getTitle().setPlainTextContent(videoTitle);
    mg.setKeywords(new MediaKeywords());
    mg.getKeywords().addKeyword("gdata-test");
    mg.setDescription(new MediaDescription());
    mg.getDescription().setPlainTextContent(videoTitle);
    MediaFileSource ms = new MediaFileSource(videoFile, mimeType);
    newEntry.setMediaSource(ms);

    try {
      service.insert(new URL(VIDEO_UPLOAD_FEED), newEntry);
View Full Code Here

    }
    if (videoEntry.getSummary() != null) {
      System.out.printf("Summary: %s\n",
          videoEntry.getSummary().getPlainText());
    }
    YouTubeMediaGroup mediaGroup = videoEntry.getMediaGroup();
    if(mediaGroup != null) {
      MediaPlayer mediaPlayer = mediaGroup.getPlayer();
      System.out.println("Web Player URL: " + mediaPlayer.getUrl());
      MediaKeywords keywords = mediaGroup.getKeywords();
      System.out.print("Keywords: ");
      for(String keyword : keywords.getKeywords()) {
        System.out.print(keyword + ",");
      }
      System.out.println();
      System.out.println("\tThumbnails:");
      for(MediaThumbnail mediaThumbnail : mediaGroup.getThumbnails()) {
        System.out.println("\t\tThumbnail URL: " + mediaThumbnail.getUrl());
        System.out.println("\t\tThumbnail Time Index: " +
            mediaThumbnail.getTime());
        System.out.println();
      }
      System.out.println("\tMedia:");
      for(YouTubeMediaContent mediaContent : mediaGroup.getYouTubeContents()) {
        System.out.println("\t\tMedia Location: "+mediaContent.getUrl());
        System.out.println("\t\tMedia Type: "+mediaContent.getType());
        System.out.println("\t\tDuration: " + mediaContent.getDuration());
        System.out.println();
      }
View Full Code Here

    output.println("What should I call this video?");
    String videoTitle = readLine();

    VideoEntry newEntry = new VideoEntry();
    YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
    mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Tech"));
    mg.setTitle(new MediaTitle());
    mg.getTitle().setPlainTextContent(videoTitle);
    mg.setKeywords(new MediaKeywords());
    mg.getKeywords().addKeyword("gdata-test");
    mg.setDescription(new MediaDescription());
    mg.getDescription().setPlainTextContent(videoTitle);

    FileUploadProgressListener listener = new FileUploadProgressListener();
    ResumableGDataFileUploader uploader =
        new ResumableGDataFileUploader.Builder(
            service, new URL(RESUMABLE_UPLOAD_URL), ms, newEntry)
View Full Code Here

        YouTubeVideo youtubevideo = new YouTubeVideo();

        if (video.size() == 0)
            youtubevideo = null;
        else {
            YouTubeMediaGroup mediaGroup = video.get(0).getMediaGroup();

            String webPlayerUrl = mediaGroup.getPlayer().getUrl();
            String query = "?v=";
            int start = webPlayerUrl.indexOf(query) + query.length();
            int end = webPlayerUrl.indexOf("&");
            String video_code = webPlayerUrl.substring(start, end);

            youtubevideo.setVideoCode(video_code);

            List<YouTubeMedia> medias = new LinkedList<YouTubeMedia>();
            for (YouTubeMediaContent mediaContent : mediaGroup
                    .getYouTubeContents()) {
                medias.add(new YouTubeMedia(mediaContent.getUrl(), mediaContent
                        .getType()));
            }
            youtubevideo.setMedias(medias);
View Full Code Here

TOP

Related Classes of com.google.gdata.data.youtube.YouTubeMediaGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.