Skip to content

Commit

Permalink
Add Tapas
Browse files Browse the repository at this point in the history
  • Loading branch information
Flameish committed Aug 22, 2020
1 parent e01f57f commit 3837778
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/grabber/scripts/ChapterListScripts.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public static void getList(Novel novel) {
case "https://scribblehub.com/":
novel.chapterList = scribblehub(novel);
break;
case "https://tapas.io/":
novel.chapterList = tapas(novel);
break;
case "https://novelupdates.com/":
novel.chapterList = novelupdates(novel);
break;
Expand All @@ -103,6 +106,31 @@ private static List<Chapter> mtlnovels(Novel novel) throws IOException {
return chapters;
}

private static List<Chapter> tapas(Novel novel) throws IOException {
List<Chapter> chapters = new ArrayList<>();
novel.tableOfContent = Jsoup.connect(novel.novelLink).timeout(30 * 1000).get();
String seriesId = novel.tableOfContent.select("meta[property=al:android:url]").attr("content");
seriesId = seriesId.substring(seriesId.indexOf("eries/")+6,seriesId.indexOf("/info"));
System.out.println("https://tapas.io/series/"+seriesId+"/episodes?page=1&sort=OLDEST&max_limit=9999");
try {
JSONParser tapreadParser = new JSONParser();
String json = Jsoup.connect("https://tapas.io/series/"+seriesId+"/episodes?page=1&sort=OLDEST&max_limit=9999")
.ignoreContentType(true)
.method(Connection.Method.GET)
.execute().body();
Object obj = tapreadParser.parse(json);
JSONObject jsonObject = (JSONObject) obj;
JSONObject data = (JSONObject) jsonObject.get("data");
String body = (String) data.get("body");
for (Element chapterLink : Jsoup.parse(body).select(novel.chapterLinkSelector)) {
chapters.add(new Chapter(chapterLink.select("a.info__title").text(), "https://tapas.io"+chapterLink.attr("data-href")));
}
} catch (ParseException | IOException e) {
e.printStackTrace();
}
return chapters;
}

private static List<Chapter> novelupdates(Novel novel) throws IOException {
Connection.Response res = Jsoup.connect(novel.novelLink)
.method(Connection.Method.GET)
Expand Down

0 comments on commit 3837778

Please sign in to comment.