Package com.tubeilike.entity

Examples of com.tubeilike.entity.TubesFeed


                                      // change
                                      // service
                                      // name.

  public static TubesFeed searchByKey(String key, int page, int type) {
    TubesFeed result = new TubesFeed();
    List<Tube> listTube = new ArrayList<Tube>();
    System.out.println("Searching...");
    try {
      YouTubeQuery query = new YouTubeQuery(new URL(
          "https://gdata.youtube.com/feeds/api/videos"));
      query.setFullTextQuery(key);
      query.setMaxResults(itemPerPage);
      query.setStartIndex(itemPerPage * page);
      query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
      VideoFeed videoFeed = service.query(query, VideoFeed.class);
      result.setTotalResult(videoFeed.getTotalResults());
      result.setCurrentPage(page);
      for (VideoEntry videoEntry : videoFeed.getEntries()) {
        Tube tub = new Tube();
        tub.transformHalfVideoEntry(videoEntry);
        listTube.add(tub);
      }
    } catch (MalformedURLException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
    } catch (IOException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
    } catch (ServiceException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
    }
    result.setListTube(listTube);
    return result;
  }
View Full Code Here


        // request.setAttribute("url", request.getRequestURL());
        // request.getRequestDispatcher("/tube_detail.jsp").forward(
        // request, response);
        List<Tube> list = new ArrayList<Tube>();
        list.add(tub);
        TubesFeed result = new TubesFeed();
        result.setCurrentPage(1);
        result.setTotalResult(1);
        result.setListTube(list);
        request.setAttribute("url", request.getRequestURL());
        request.setAttribute("result", result);
        request.setAttribute("key", tub.getTitle().getValue());
        request.getRequestDispatcher("/tube_show.jsp").forward(request,
            response);
      } else {

      }

    } else {
      // search by input key.
      String[] splitted = request.getRequestURI().split("/");
      String key = null;
      int currentPage = 1;
      if (splitted.length == 3) {
        key = URLDecoder.decode(splitted[2], "UTF-8");
      } else if (splitted.length == 4) {
        key = URLDecoder.decode(splitted[2], "UTF-8");
        try {
          currentPage = Integer.parseInt(splitted[3]);
        } catch (Exception e) {
          currentPage = 1;
        }
      } else {
        response.sendRedirect("/home");
      }
      try {
        System.out.println("Keyword to search : " + key);
        TubesFeed result = TubeService.searchByKey(key, currentPage, 1);
        request.setAttribute("url", request.getRequestURL());
        request.setAttribute("result", result);
        request.setAttribute("key", key);
        request.getRequestDispatcher("/tube_show.jsp").forward(request,
            response);
View Full Code Here

                                      // change
                                      // service
                                      // name.

  public static TubesFeed searchByKey(String key, int page, int type) {
    TubesFeed result = new TubesFeed();
    List<Tube> listTube = new ArrayList<Tube>();
    System.out.println("Searching...");
    try {
      YouTubeQuery query = new YouTubeQuery(new URL(
          "https://gdata.youtube.com/feeds/api/videos"));
      query.setFullTextQuery(key);
      query.setMaxResults(itemPerPage);
      query.setStartIndex(itemPerPage * page);
      query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
      VideoFeed videoFeed = service.query(query, VideoFeed.class);
      result.setTotalResult(videoFeed.getTotalResults());
      result.setCurrentPage(page);
      for (VideoEntry videoEntry : videoFeed.getEntries()) {
        Tube tub = new Tube();
        tub.transformHalfVideoEntry(videoEntry);
        listTube.add(tub);
      }
    } catch (MalformedURLException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
    } catch (IOException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
    } catch (ServiceException e) {
      System.out.println("Error when searching with key : + " + key);
      e.printStackTrace();
    }
    result.setListTube(listTube);
    return result;
  }
View Full Code Here

TOP

Related Classes of com.tubeilike.entity.TubesFeed

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.