Examples of YouTubeService


Examples of com.google.gdata.client.youtube.YouTubeService

    if (help || username == null || password == null || developerKey == null) {
      printUsage();
      System.exit(1);
    }

    YouTubeService service = new YouTubeService("gdata-YTPartialDemo-1",
        developerKey);

    try {
      service.setUserCredentials(username, password);
    } catch (AuthenticationException e) {
      System.out.println("Invalid login credentials.");
      System.exit(1);
    }
View Full Code Here

Examples of com.google.gdata.client.youtube.YouTubeService

    if (help || username == null || password == null || developerKey == null) {
      printUsage();
      System.exit(1);
    }

    YouTubeService service = new YouTubeService("gdataSample-YouTubeAuth-1",
        developerKey);

    try {
      service.setUserCredentials(username, password);
    } catch (AuthenticationException e) {
      System.out.println("Invalid login credentials.");
      System.exit(1);
    }
View Full Code Here

Examples of com.google.gdata.client.youtube.YouTubeService

   * the Java Client library.
   *
   * @param args not used
   */
  public static void main(String[] args) {
    YouTubeService myService = new YouTubeService("gdataSample-YouTube-1");

    while (true) {
      try {
        printUsage();
        int choice = readInt();
View Full Code Here

Examples of com.google.gdata.client.youtube.YouTubeService

    if (help || username == null || password == null || developerKey == null) {
      printUsage();
      System.exit(1);
    }

    YouTubeService service = new YouTubeService("gdataSample-YouTubeAuth-1",
        developerKey);

    try {
      service.setUserCredentials(username, password);
    } catch (AuthenticationException e) {
      System.out.println("Invalid login credentials.");
      System.exit(1);
    }
View Full Code Here

Examples of com.google.gdata.client.youtube.YouTubeService

    }

    private static YouTubeVideo retrieveVideo(String clientID, String keywords,
            int timeout, String ip) throws IOException, ServiceException {

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

        query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);
        query.setFullTextQuery(keywords);
        query.setMaxResults(1);
        query.setFormats(5);
        if (!ip.equals(""))
            query.setIpRestriction(ip);
        query.setSafeSearch(YouTubeQuery.SafeSearch.MODERATE);

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

        return convertVideos(videos);

    }
View Full Code Here

Examples of com.tubeonfire.service.YoutubeService

      Mission mission = new Mission();
      Playlist pl = PlaylistModel.byId(playlistId, false);
      if (pl != null) {
        if (YoutubeService.checkChannel(channelId)) {
          if (type.equals("2")) {
            YoutubeService tubeService = new YoutubeService();
            tubeService.setPage(1);
            tubeService.setLimit(49);
            List<Tube> listToAdd = new ArrayList<Tube>();
            tubeService.searchByChannel(channelId, true);
            for (Tube tube : tubeService.getListResult()) {
              tube.setPlaylistId(playlistId);
              listToAdd.add(tube);
            }
            TubeModel.insert(listToAdd);
            mission.setId(IdUniqueHelper.getId());
            mission.setSearchHd(1);
            mission.setSearchType(1);
            mission.setSearchKeyword(channelId);
            mission.setPlaylistId(playlistId);
            mission.setSearchLimit(tubeService.getLimit());
            if (tubeService.getListResult().size() > 0
                && !tubeService.isTooManyRecentCallError()) {
              mission.setSearchPage(tubeService.getPage() + 1);
            } else {
              mission.setSearchPage(tubeService.getPage());
            }
            mission.setSearchTotalPage(tubeService.getTotalPage());
            mission.setType(2);
            mission.setTitle("Get videos from channel " + channelId
                + " to playlist " + pl.getTitle());
            MissionModel.insert(mission);
            session.setAttribute("success", "Action success !");
View Full Code Here

Examples of com.tubeonfire.service.YoutubeService

        String channelId = (String) req.getParameter("channelId");
        String playlistId = (String) req.getParameter("playlistId");
        String subcribe = (String) req.getParameter("subcribe");
        try {
          int limit = 49;
          YoutubeService tubeService = new YoutubeService();
          tubeService.setPage(1);
          tubeService.setLimit(limit);
          List<Tube> listToAdd = new ArrayList<Tube>();
          tubeService.searchByChannel(channelId, true);
          for (Tube tube : tubeService.getListResult()) {
            tube = processTubeDetail(playlistId, tube);
            String uri = tube.getAuthorUrl();
            if (uri != null && uri.length() > 0) {
              if (AuthorModel.getById(uri) == null) {
                processAuthor(uri);
              }
            }
            listToAdd.add(tube);
          }
          TubeModel.insert(listToAdd);
          Mission mission = new Mission();
          mission.setId(IdUniqueHelper.getId());
          mission.setSearchHd(1);
          mission.setSearchType(1);
          mission.setSearchKeyword(channelId);
          mission.setPlaylistId(playlistId);
          mission.setSearchLimit(limit);
          if (tubeService.getListResult().size() > 0
              && !tubeService.isTooManyRecentCallError()) {
            mission.setSearchPage(tubeService.getPage() + 1);
          } else {
            mission.setSearchPage(tubeService.getPage());
          }
          mission.setSearchTotalPage(tubeService.getTotalPage());
          mission.setType(2);
          mission.setTitle("Get all videos from channel " + channelId);
          if (tubeService.getPage() == tubeService.getTotalPage()
              && !tubeService.isTooManyRecentCallError()) {
            mission.setStatus(2);
          }
          MissionModel.insert(mission);
          if (subcribe != null && subcribe.equals("true")) {
            mission = new Mission();
View Full Code Here

Examples of com.tubeonfire.service.YoutubeService

      String action = (String) req.getParameter("action");
      if (action != null && action.length() > 0) {
        if (action.equals("transport")) {
          Mission mission = MissionModel.getNotCompleteByType(2);
          if (mission != null) {
            YoutubeService tubeService = new YoutubeService();
            tubeService.setPage(mission.getSearchPage());
            tubeService.setLimit(mission.getSearchLimit());
            List<Tube> listToAdd = new ArrayList<Tube>();
            tubeService.searchByChannel(mission.getSearchKeyword(),
                true);
            Queue queue = QueueFactory.getDefaultQueue();         
            for (Tube tube : tubeService.getListResult()) {
              tube = processTubeDetail(mission.getPlaylistId(),
                  tube);
              // add author to site.             
              queue.add(TaskOptions.Builder.withUrl(
                  "/task-admin?action=add-author&uri="
                      + tube.getAuthorUrl()).method(
                  TaskOptions.Method.GET));
              listToAdd.add(tube);
            }
            TubeModel.insert(listToAdd);
            if (tubeService.getListResult().size() > 0
                && !tubeService.isTooManyRecentCallError()) {
              mission.setSearchPage(tubeService.getPage() + 1);
            } else {
              mission.setSearchPage(tubeService.getPage());
            }
            if (tubeService.getPage() == tubeService.getTotalPage()
                && !tubeService.isTooManyRecentCallError()) {
              mission.setStatus(2);
            }
            MissionModel.insert(mission);
          }
        } else if (action.equals("follow")) {
View Full Code Here

Examples of com.tubeonfire.service.YoutubeService

      } catch (Exception e) {
        page = 1;
      }
      if (type != null && quanlity != null && keyword != null
          && keyword.length() > 0) {
        YoutubeService tubeService = new YoutubeService();
        if (type.equals("1")) {
          tubeService.setPage(page);
          if (keyword.contains("http://www.youtube.com/user/")) {
            /*
             * example : http://www.youtube.com/user/xuanhung2401
             */
            String pattern = "(?:\\/user\\/)([\\w-]+)";
            Pattern compiledPattern = Pattern.compile(pattern);
            Matcher matcher = compiledPattern.matcher(keyword);
            if (matcher.find()) {
              keyword = matcher.group().replace("/user/", "");
            }
          } else if (keyword.contains("http://www.youtube.com")) {
            /*
             * example : http://www.youtube.com/xuanhung2401
             */
            String pattern = "(?:youtube.com\\/)([\\w-]+)";
            Pattern compiledPattern = Pattern.compile(pattern);
            Matcher matcher = compiledPattern.matcher(keyword);
            if (matcher.find()) {
              keyword = matcher.group().replace("youtube.com/",
                  "");
            }
          }
          tubeService.searchByChannel(keyword, true);
        } else if (type.equals("2")) {
          tubeService.setPage(page);
          tubeService.searchByKey(keyword, quanlity.equals("2"));
        } else if (type.equals("3")) {
          String pattern = "(?:videos\\/|v=)([\\w-]+)";
          Pattern compiledPattern = Pattern.compile(pattern);
          Matcher matcher = compiledPattern.matcher(keyword);
          if (matcher.find()) {
            String fullStrId = matcher.group();
            fullStrId = (fullStrId.substring(
                fullStrId.length() - 11, fullStrId.length()));
            tubeService.searchById(fullStrId);
          }
        }
        resp.setCharacterEncoding("UTF-8");
        req.setAttribute("url", "/admin/youtube/search" + "?type=" + type
            + "&quanlity=" + quanlity + "&keyword=" + keyword
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.