@Override protected List<Serie> parseSeries(Document htmlDocument, Website parent) { List<Serie> series = new LinkedList<>(); Elements links = htmlDocument.select("a.manga_info"); for (Element link : links) { Serie serie = new Serie(); serie.setMustBeSaved(true); serie.setUrl(link.attr("href")); serie.setName(link.text()); serie.setWebsite(parent); series.add(serie); } parent.setValidityDate(new Date()); return series; }
@Override protected List<Tome> parseTomes(Document htmlDocument, Serie parent) { Date today = new Date(); List<Tome> tomes = new LinkedList<>(); Elements divChapters = htmlDocument.select("div.detail_list"); if (!divChapters.isEmpty()) { Elements spansLeft = divChapters.first().select("span.left"); if (!spansLeft.isEmpty()) { for (Element span : spansLeft) { Elements tomeNumberElements = span.select("span.mr6"); final String tomeNumberString = StringUtils.substringAfter(tomeNumberElements.first().text(), "Vol "); int tomeNumber = 0; if (tomeNumberString != null && !tomeNumberString.isEmpty()) { Integer.parseInt(tomeNumberString); } Tome foundTome = null; for (Tome tome : tomes) { if (tomeNumber == tome.getNumber()) { foundTome = tome; break; } } if (foundTome == null) { Tome tome = new Tome(); tome.setNumber(tomeNumber); tome.setName("Tome " + tomeNumber); tome.setMustBeSaved(true); tome.setValidityDate(today); tome.setSerie(parent); tomes.add(tome); foundTome = tome; } Element link = span.select("a").first(); Chapter chapter = new Chapter(); chapter.setMustBeSaved(true); chapter.setUrl(link.attr("href")); String chapterNumberToParse = link.text(); String tempNumber = StringUtils.substringAfterLast(chapterNumberToParse, " "); chapter.setNumber(Float.parseFloat(tempNumber)); chapter.setName(span.text()); chapter.setTome(foundTome); foundTome.addChapter(chapter); } } } parent.setValidityDate(today); return tomes; }