예제 #1
0
  private int getNumberOfVotes(Show show) {
    try {
      String page = getPage(show.getShowLink());
      String temp = getMatch(VOTES_NUMBER_PATTERN, page, 1, 1);
      if (temp != null) {
        return parseNumberOfVotes(temp);
      }

    } catch (IOException e) {
      System.out.println("Error on show link: '" + show.getShowLink() + "'");
    }

    return 0;
  }
예제 #2
0
  public static Document createDocumentFromShows(List<Show> allShows) {
    Document document = new Document();
    Element root = new Element("shows");
    Element showElement, seasonElement, episodeElement;
    for (Show show : allShows) {
      if (show.getTvDotComVotes() < MINIMUM_VOTES) continue;

      showElement = new Element("show");
      showElement.addContent(new Element("name").setText(show.getName()));
      showElement.addContent(new Element("showLink").setText(show.getShowLink()));
      showElement.addContent(new Element("startDate").setText(show.getDate()));
      showElement.addContent(new Element("tvDotComRating").setText(show.getTvDotComRating()));
      showElement.addContent(new Element("tvDotComVotes").setText("" + show.getTvDotComVotes()));
      /*<Season no="0">
      <episode>
      	<epnum>0</epnum>
      	<seasonnum>00</seasonnum>
      	<prodnum>4V79</prodnum>
      	<airdate>0000-00-00</airdate>
      	<link>http://www.tvrage.com/Buffy_The_Vampire_Slayer/episodes/329033</link>
      	<title>Unaired Pilot</title>
      </episode>
      </Season>*/

      if (show.getSeasons() == null) {
        root.addContent(showElement);
        System.out.println("Show name:" + show.getName());
        continue;
      }

      for (Season season : show.getSeasons()) {
        seasonElement = new Element("season");
        seasonElement.addContent(new Element("no").setText(season.getName()));
        for (Episode episode : season.getEpisodes()) {
          episodeElement = new Element("episode");
          episodeElement.addContent(new Element("epnum").setText(episode.getNumber()));
          episodeElement.addContent(new Element("airdate").setText(episode.getAirDate()));
          // episodeElement.addContent(new Element("link").setText(episode.getNumber()));
          episodeElement.addContent(new Element("title").setText(episode.getTitle()));
        }
        showElement.addContent(seasonElement);
      }

      root.addContent(showElement);
    }

    document.setRootElement(root);
    return document;
  }