Esempio n. 1
0
 private ViewModel parseDetail(Document doc, ViewModel item) {
   if (doc.select("select#SeasonSelection").size() > 0) {
     item.setType(ViewModel.Type.SERIES);
     String rel = doc.select("select#SeasonSelection").attr("rel");
     rel = rel.substring(rel.indexOf("SeriesID=") + "SeriesID=".length());
     item.setSeriesID(Integer.valueOf(rel));
     // Fill seasons and episodes
     Elements seasons = doc.select("select#SeasonSelection > option");
     List<Season> list = new ArrayList<Season>();
     for (Element season : seasons) {
       String[] rels = season.attr("rel").split(",");
       Season s = new Season();
       s.id = Integer.valueOf(season.val());
       s.name = season.text();
       s.episodes = rels;
       list.add(s);
     }
     item.setSeasons(list.toArray(new Season[list.size()]));
   } else {
     item.setType(ViewModel.Type.MOVIE);
     List<Host> hostlist = new ArrayList<Host>();
     Elements hosts = doc.select("ul#HosterList").select("li");
     for (Element host : hosts) {
       int hosterId = 0;
       Set<String> classes = host.classNames();
       for (String c : classes) {
         if (c.startsWith("MirStyle")) {
           hosterId = Integer.valueOf(c.substring("MirStyle".length()));
         }
       }
       String name = host.select("div.Named").text();
       String count = host.select("div.Data").text();
       int c = 1;
       if (count.contains("/")) {
         count = count.substring(count.indexOf("/") + 1, count.indexOf(" ", count.indexOf("/")));
         c = Integer.valueOf(count);
       }
       for (int i = 0; i < c; i++) {
         Host h = Host.selectById(hosterId);
         h.setName(name);
         h.setMirror(i + 1);
         if (h.isEnabled()) {
           hostlist.add(h);
         }
       }
     }
     item.setMirrors(hostlist.toArray(new Host[hostlist.size()]));
   }
   String imdb = doc.select("div.IMDBRatingLinks > a").attr("href").trim();
   if (!TextUtils.isEmpty(imdb)) {
     imdb = imdb.replace("/", "");
     item.setImdbId(imdb);
   }
   return item;
 }
Esempio n. 2
0
  @Override
  public List<Host> getHosterList(ViewModel item, int season, String episode) {
    String url =
        "aGET/MirrorByEpisode/?Addr="
            + item.getSlug()
            + "&SeriesID="
            + item.getSeriesID()
            + "&Season="
            + season
            + "&Episode="
            + episode;
    try {
      Document doc = Jsoup.connect(URL_BASE + url).userAgent(Utils.USER_AGENT).timeout(10000).get();

      List<Host> hostlist = new ArrayList<Host>();
      Elements hosts = doc.select("li");
      for (Element host : hosts) {
        int hosterId = Integer.valueOf(host.id().replace("Hoster_", ""));
        String name = host.select("div.Named").text();
        String count = host.select("div.Data").text();
        count = count.substring(count.indexOf("/") + 1, count.indexOf(" ", count.indexOf("/")));
        int c = Integer.valueOf(count);
        for (int i = 0; i < c; i++) {
          Host h = Host.selectById(hosterId);
          h.setName(name);
          h.setMirror(i + 1);
          if (h.isEnabled()) {
            hostlist.add(h);
          }
        }
      }

      return hostlist;

    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }