From 42143551e09ecca238d3af31f1bd6374bb37656b Mon Sep 17 00:00:00 2001 From: haleydu <924323178@qq.com> Date: Sun, 30 Aug 2020 22:44:13 +0800 Subject: [PATCH] add all comic source to DB --- .../java/com/hiroshi/cimoc/core/Manga.java | 7 +-- .../com/hiroshi/cimoc/parser/MangaParser.java | 10 ---- .../java/com/hiroshi/cimoc/parser/Parser.java | 3 +- .../java/com/hiroshi/cimoc/source/Animx2.java | 26 +++++++--- .../com/hiroshi/cimoc/source/BaiNian.java | 25 ++++++++-- .../java/com/hiroshi/cimoc/source/BuKa.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/CCMH.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/CCTuku.java | 24 +++++++-- .../com/hiroshi/cimoc/source/Cartoonmad.java | 24 +++++++-- .../com/hiroshi/cimoc/source/ChuiXue.java | 24 +++++++-- .../com/hiroshi/cimoc/source/Chuiyao.java | 24 +++++++-- .../com/hiroshi/cimoc/source/Comic18.java | 49 ++++++++++++------- .../java/com/hiroshi/cimoc/source/CopyMH.java | 22 +++++++-- .../java/com/hiroshi/cimoc/source/DM5.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/Dmzj.java | 23 +++++++-- .../java/com/hiroshi/cimoc/source/Dmzjv2.java | 24 +++++++-- .../com/hiroshi/cimoc/source/EHentai.java | 21 ++++++-- .../java/com/hiroshi/cimoc/source/GuFeng.java | 25 +++++++--- .../java/com/hiroshi/cimoc/source/HHAAZZ.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/HHSSEE.java | 23 +++++++-- .../java/com/hiroshi/cimoc/source/Hhxxee.java | 23 +++++++-- .../com/hiroshi/cimoc/source/IKanman.java | 23 +++++++-- .../com/hiroshi/cimoc/source/Locality.java | 16 +++++- .../java/com/hiroshi/cimoc/source/MH160.java | 5 +- .../java/com/hiroshi/cimoc/source/MH50.java | 4 +- .../java/com/hiroshi/cimoc/source/MH517.java | 25 ++++++++-- .../java/com/hiroshi/cimoc/source/MH57.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/MHLove.java | 23 +++++++-- .../com/hiroshi/cimoc/source/ManHuaDB.java | 25 +++++++--- .../java/com/hiroshi/cimoc/source/MangaBZ.kt | 31 +++++++++--- .../com/hiroshi/cimoc/source/MangaNel.java | 25 +++++++--- .../hiroshi/cimoc/source/Mangakakalot.java | 42 ++++++++++++---- .../com/hiroshi/cimoc/source/Manhuatai.java | 37 +++++++++----- .../java/com/hiroshi/cimoc/source/MiGu.java | 23 +++++++-- .../java/com/hiroshi/cimoc/source/Null.java | 16 +++++- .../com/hiroshi/cimoc/source/Ohmanhua.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/PuFei.java | 25 ++++++++-- .../com/hiroshi/cimoc/source/QiManWu.java | 36 +++++++++++--- .../com/hiroshi/cimoc/source/Tencent.java | 24 +++++++-- .../java/com/hiroshi/cimoc/source/TuHao.java | 24 ++++++--- .../java/com/hiroshi/cimoc/source/U17.java | 25 ++++++++-- .../com/hiroshi/cimoc/source/Webtoon.java | 23 +++++++-- .../cimoc/source/WebtoonDongManManHua.java | 35 +++++++++---- .../java/com/hiroshi/cimoc/source/YYLS.java | 24 ++++++--- 44 files changed, 789 insertions(+), 243 deletions(-) diff --git a/app/src/main/java/com/hiroshi/cimoc/core/Manga.java b/app/src/main/java/com/hiroshi/cimoc/core/Manga.java index 4a63a4a8..2e4a6917 100644 --- a/app/src/main/java/com/hiroshi/cimoc/core/Manga.java +++ b/app/src/main/java/com/hiroshi/cimoc/core/Manga.java @@ -1,7 +1,5 @@ package com.hiroshi.cimoc.core; -import android.util.Log; - import com.hiroshi.cimoc.App; import com.hiroshi.cimoc.manager.ChapterManager; import com.hiroshi.cimoc.manager.SourceManager; @@ -10,6 +8,8 @@ import com.hiroshi.cimoc.model.ImageUrl; import com.hiroshi.cimoc.parser.Parser; import com.hiroshi.cimoc.parser.SearchIterator; +import com.hiroshi.cimoc.rx.RxBus; +import com.hiroshi.cimoc.rx.RxEvent; import org.json.JSONArray; import org.json.JSONObject; @@ -82,7 +82,8 @@ public void call(Subscriber> subscriber) { comic.setUrl(parser.getUrl(comic.getCid())); Request request = parser.getInfoRequest(comic.getCid()); String html = getResponseBody(App.getHttpClient(), request); - parser.parseInfo(html, comic); + Comic newComic = parser.parseInfo(html, comic); + RxBus.getInstance().post(new RxEvent(RxEvent.EVENT_COMIC_UPDATE_INFO, newComic)); request = parser.getChapterRequest(html, comic.getCid()); if (request != null) { html = getResponseBody(App.getHttpClient(), request); diff --git a/app/src/main/java/com/hiroshi/cimoc/parser/MangaParser.java b/app/src/main/java/com/hiroshi/cimoc/parser/MangaParser.java index 0002d32f..1ffc3758 100644 --- a/app/src/main/java/com/hiroshi/cimoc/parser/MangaParser.java +++ b/app/src/main/java/com/hiroshi/cimoc/parser/MangaParser.java @@ -38,11 +38,6 @@ protected void initUrlFilterList() { // filter.add(new UrlFilter("manhua.dmzj.com", "/(\\w+)", 1)); } - @Override - public List parseChapter(String html, Comic comic) throws JSONException{ - return null; - } - @Override public List parseChapter(String html) throws JSONException { return null; @@ -53,11 +48,6 @@ public List parseImages(String html) throws Manga.NetworkErrorExceptio return null; } - @Override - public List parseImages(String html, Chapter chapter) throws Manga.NetworkErrorException, JSONException { - return null; - } - @Override public Request getChapterRequest(String html, String cid) { return null; diff --git a/app/src/main/java/com/hiroshi/cimoc/parser/Parser.java b/app/src/main/java/com/hiroshi/cimoc/parser/Parser.java index 2544ef7b..35a9ed57 100644 --- a/app/src/main/java/com/hiroshi/cimoc/parser/Parser.java +++ b/app/src/main/java/com/hiroshi/cimoc/parser/Parser.java @@ -52,7 +52,8 @@ public interface Parser { * @param html 页面源代码 * @param comic 漫画实体类,需要设置其中的字段 */ - void parseInfo(String html, Comic comic) throws UnsupportedEncodingException; + Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException; + /** * 章节列表的 HTTP 请求,若在 {@link #parseInfo} 中可以解析出章节列表,返回 null,代表不用再次解析 diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Animx2.java b/app/src/main/java/com/hiroshi/cimoc/source/Animx2.java index fa3e9d40..5c3d1266 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Animx2.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Animx2.java @@ -79,7 +79,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("div.position > strong"); String cover = "http://www.2animx.com/" + body.src("dl.mh-detail > dt > a > img"); @@ -88,18 +88,30 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text(".mh-introduce"); boolean status = false; comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("div#oneCon2 > ul > li")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("a", "title"); Matcher mTitle = Pattern.compile("\\d+").matcher(title); title = mTitle.find() ? mTitle.group() : title; - String path2 = node.href("a"); String path = node.hrefWithSplit("a", 0); - list.add(new Chapter(title, path)); + + //list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -117,13 +129,15 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new ArrayList<>(); Matcher pageMatcher = Pattern.compile("id=\"total\" value=\"(.*?)\"").matcher(html); if (!pageMatcher.find()) return null; int page = Integer.parseInt(pageMatcher.group(1)); for (int i = 1; i <= page; ++i) { - list.add(new ImageUrl(i, StringUtils.format("%s-p-%d", _path, i), true)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, StringUtils.format("%s-p-%d", _path, i), true)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java b/app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java index deb2db41..5e637a83 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java @@ -89,7 +89,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String cover = body.attr("div.dbox > div.img > mip-img", "src"); String title = body.text("div.dbox > div.data > h4"); @@ -98,15 +98,28 @@ public void parseInfo(String html, Comic comic) { String update = body.text("div.dbox > div.data > p.act").substring(3, 13).trim(); boolean status = isFinish(body.text("span.list_item")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("div.tabs_block > ul > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); String path = node.href(); - list.add(new Chapter(title, path)); + + //list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -118,7 +131,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html,Chapter chapter) { List list = new LinkedList<>(); String host = StringUtils.match("src=\"(.*?)\\/upload", html, 1); String path_str = StringUtils.match("z_img=\'\\[(.*?)\\]\'", html, 1); @@ -127,7 +140,9 @@ public List parseImages(String html) { String[] array = path_str.split(","); for (int i = 0; i != array.length; ++i) { String path = array[i].replace("\"","").replace("\\",""); - list.add(new ImageUrl(i + 1, host+"/"+path, false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id,comicChapter,i + 1, host+"/"+path, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/BuKa.java b/app/src/main/java/com/hiroshi/cimoc/source/BuKa.java index 54d28c9b..e209a5c3 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/BuKa.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/BuKa.java @@ -100,7 +100,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("p.mangadir-glass-name"); String cover = body.src(".mangadir-glass-img > img"); @@ -109,6 +109,7 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("span.description_intro"); boolean status = isFinish("连载中");//todo: fix here comic.setInfo(title, cover, update, intro, author, status); + return comic; } // @Override @@ -120,12 +121,23 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept // } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("div.chapter-center > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); String path = node.href().split("/")[3]; - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -140,14 +152,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html,Chapter chapter) { List list = new LinkedList<>(); Matcher m = Pattern.compile("").matcher(html); if (m.find()) { try { int i = 0; do { - list.add(new ImageUrl(++i, StringUtils.match("http.*jpg", m.group(0), 0), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id,comicChapter,++i, StringUtils.match("http.*jpg", m.group(0), 0), false)); } while (m.find()); } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/CCMH.java b/app/src/main/java/com/hiroshi/cimoc/source/CCMH.java index c3ad7f89..81cec658 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/CCMH.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/CCMH.java @@ -100,7 +100,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String intro = body.text(".intro"); String title = body.text(".other > div > strong"); @@ -111,16 +111,28 @@ public void parseInfo(String html, Comic comic) { .replace("[", "").replace("]", ""); boolean status = isFinish(body.textWithSplit(".other", "\\s+|:", 10)); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); + int i=0; for (Node node : body.list(".list > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("title"); String path = node.hrefWithSplit(2); - list.add(new Chapter(title, path)); + //list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return Lists.reverse(list); @@ -140,7 +152,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); //find image count @@ -152,7 +164,9 @@ public List parseImages(String html) { } for (int i = 0; i < pageCount; i++) { - list.add(new ImageUrl(i, StringUtils.format("http://m.ccmh6.com/manhua/%s/%s.html?p=%d", _cid, _path, i + 1), true)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, StringUtils.format("http://m.ccmh6.com/manhua/%s/%s.html?p=%d", _cid, _path, i + 1), true)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/CCTuku.java b/app/src/main/java/com/hiroshi/cimoc/source/CCTuku.java index 5d06c4ad..f1bc85b6 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/CCTuku.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/CCTuku.java @@ -74,7 +74,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("div.detailTop > div.content > div.info > p.title"); String cover = body.src("div.detailTop > div.content > img"); @@ -84,17 +84,29 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("div.detailContent > p:eq(1)"); // FIXME 手机版页面好像获取不到状态 电脑板页面太大不想用 暂时先固定为连载吧 comic.setInfo(title, cover, update, intro, author, false); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); + int i=0; for (Node node : body.list("#chapter > div > div > ul > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); // String path = StringUtils.split(node.href(), "/", 3); String path = node.hrefWithSplit(2); - list.add(new Chapter(title, path)); + //list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -113,14 +125,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { // TODO 好像拿不到总页数 GG List list = new ArrayList<>(); // Node body = new Node(html); // int page = Integer.parseInt(body.attr("#hdPageCount", "value"));//max pages unknow... int page = 10; for (int i = 1; i <= page; ++i) { - list.add(new ImageUrl(i, StringUtils.format("http://m.tuku.cc/comic/%s/%s/p%s/", _cid, _path, i), true)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, StringUtils.format("http://m.tuku.cc/comic/%s/%s/p%s/", _cid, _path, i), true)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Cartoonmad.java b/app/src/main/java/com/hiroshi/cimoc/source/Cartoonmad.java index 40f308c5..da02d8a1 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Cartoonmad.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Cartoonmad.java @@ -87,7 +87,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); Matcher mTitle = Pattern.compile(" parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Matcher mChapter = Pattern.compile("(.*?)<\\/a> ").matcher(html); + int i=0; while (mChapter.find()) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = mChapter.group(2); String path = mChapter.group(1); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return Lists.reverse(list); } @@ -124,13 +136,15 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html,Chapter chapter) { List list = new ArrayList<>(); Matcher pageMatcher = Pattern.compile(".*(.*?)<\\/a>").matcher(html); if (!pageMatcher.find()) return null; int page = Integer.parseInt(pageMatcher.group(2)); for (int i = 1; i <= page; ++i) { - list.add(new ImageUrl(i, StringUtils.format("https://www.cartoonmad.com/comic/%s%03d.html", pageMatcher.group(1), i), true)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, StringUtils.format("https://www.cartoonmad.com/comic/%s%03d.html", pageMatcher.group(1), i), true)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/ChuiXue.java b/app/src/main/java/com/hiroshi/cimoc/source/ChuiXue.java index 9cc74bc2..3965ec9c 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/ChuiXue.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/ChuiXue.java @@ -80,7 +80,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("div.intro_l > div.title > h1"); String cover = body.src("div.intro_l > div.info_cover > p.cover > img"); @@ -89,15 +89,27 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("#intro"); boolean status = isFinish(body.text("div.intro_l > div.info > p:eq(2)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#play_0 > ul > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("title"); String path = node.hrefWithSplit(2); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -115,17 +127,19 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("photosr\\[1\\](.*?)(\n|var)", html, 1); if (str != null) { try { String[] array = str.split(";"); for (int i = 0; i != array.length; ++i) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); String s_full = array[i].trim(); int index = s_full.indexOf("="); String s = s_full.substring(index + 2, s_full.length() - 1); - list.add(new ImageUrl(i + 1, "http://chuixue1.tianshigege.com/" + s, false)); + list.add(new ImageUrl(id, comicChapter,i + 1, "http://chuixue1.tianshigege.com/" + s, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Chuiyao.java b/app/src/main/java/com/hiroshi/cimoc/source/Chuiyao.java index 2be49389..66b45fa2 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Chuiyao.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Chuiyao.java @@ -73,7 +73,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("div.main-bar > h1"); String cover = body.src("div.book-detail > div.cont-list > div.thumb > img"); @@ -82,15 +82,27 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("#bookIntro"); boolean status = isFinish(body.text("div.book-detail > div.cont-list > div.thumb > i")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#chapterList > ul > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("title"); String path = node.hrefWithSplit(2); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -102,14 +114,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("parseJSON\\('(.*?)'\\)", html, 1); if (str != null) { try { JSONArray array = new JSONArray(str); for (int i = 0; i != array.length(); ++i) { - list.add(new ImageUrl(i + 1, array.getString(i), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter,i + 1, array.getString(i), false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Comic18.java b/app/src/main/java/com/hiroshi/cimoc/source/Comic18.java index 0c9bb5a9..d72f8001 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Comic18.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Comic18.java @@ -82,7 +82,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { try { Node body = new Node(html); String intro = body.text("#intro-block > div:eq(6)"); @@ -93,23 +93,35 @@ public void parseInfo(String html, Comic comic) { boolean status = isFinish(body.text("#intro-block > div:eq(2) > span")); comic.setInfo(title, cover, update, intro, author, status); }catch (Exception e){ - + e.printStackTrace(); } + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); - - String startTitle = body.text(".col.btn.btn-primary.dropdown-toggle.reading").trim(); - String startPath = body.href(".col.btn.btn-primary.dropdown-toggle.reading"); - list.add(new Chapter(startTitle, startPath)); - + int i=0; for (Node node : body.list("#episode-block > div > div.episode > ul > a")) { - String title = node.text("li").trim(); - String path = node.href(); - list.add(new Chapter(title, path)); + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + + if (i==0){ + String startTitle = body.text(".col.btn.btn-primary.dropdown-toggle.reading").trim(); + String startPath = body.href(".col.btn.btn-primary.dropdown-toggle.reading"); + list.add(new Chapter(id, sourceComic, startTitle, startPath)); + }else { + String title = node.text("li").trim(); + String path = node.href(); + list.add(new Chapter(id, sourceComic, title, path)); + } + i++; } return Lists.reverse(list); } @@ -123,26 +135,27 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new ArrayList<>(); try { int i = 0; for (Node node : new Node(html).list("img.lazy_img")) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + String img1 = node.attr("img","src"); String img2 = node.attr("img","data-original"); String reg[] = imgpath.split("\\/"); if (img1.contains(reg[2])){ - list.add(new ImageUrl(i++, img1, false)); + list.add(new ImageUrl(id, comicChapter, i++, img1, false)); }else if (img2.contains(reg[2])){ - list.add(new ImageUrl(i++, img2, false)); + list.add(new ImageUrl(id, comicChapter, i++, img2, false)); } } - } - catch (Exception e){ + } catch (Exception e){ e.printStackTrace(); - }finally { - return list; } + return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java b/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java index 08d81cd7..4bd3d0e9 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java @@ -95,7 +95,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String cover = body.attr("div.comicParticulars-left-img.loadingIcon > img", "data-src"); String intro = body.text("p.intro"); @@ -108,6 +108,8 @@ public void parseInfo(String html, Comic comic) { boolean finish = isFinish(status); comic.setInfo(title, cover, update, intro, author, finish); + + return comic; } @Override @@ -117,14 +119,22 @@ public Request getChapterRequest(String html, String cid) { } @Override - public List parseChapter(String html) throws JSONException { + public List parseChapter(String html, Comic comic) throws JSONException { List list = new LinkedList<>(); JSONObject jsonObject = new JSONObject(html); JSONArray array = jsonObject.getJSONObject("results").getJSONArray("list"); for (int i = 0; i < array.length(); ++i) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = array.getJSONObject(i).getString("name"); String path = array.getJSONObject(i).getString("uuid"); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); } return Lists.reverse(list); } @@ -136,7 +146,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); Node body = new Node(html); String data = body.attr("div.disposableData", "disposable"); @@ -150,8 +160,10 @@ public List parseImages(String html) { String jsonString = DecryptionUtils.aesDecrypt(encode, key, iv); JSONArray array = new JSONArray(jsonString); for (int i = 0; i < array.length(); ++i) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); String url = array.getJSONObject(i).getString("url"); - list.add(new ImageUrl(i + 1, url, false)); + list.add(new ImageUrl(id, comicChapter,i + 1, url, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/DM5.java b/app/src/main/java/com/hiroshi/cimoc/source/DM5.java index f01e12f8..31aa1fd1 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/DM5.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/DM5.java @@ -107,7 +107,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.textWithSplit("div.banner_detail_form > div.info > p.title", " ", 0); String cover = body.src("div.banner_detail_form > div.cover > img"); @@ -140,16 +140,28 @@ public void parseInfo(String html, Comic comic) { } boolean status = isFinish(body.text("div.banner_detail_form > div.info > p.tip > span:eq(0)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { Set set = new LinkedHashSet<>(); Node body = new Node(html); + int i=0; for (Node node : body.list("#chapterlistload > ul li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = StringUtils.split(node.text(), " ", 0); String path = node.hrefWithSplit(0); - set.add(new Chapter(title, path)); + + set.add(new Chapter(id, sourceComic, title, path)); + i++; } return new LinkedList<>(set); } @@ -164,7 +176,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("eval\\(.*\\)", html, 0); if (str != null) { @@ -172,7 +184,9 @@ public List parseImages(String html) { str = DecryptionUtils.evalDecrypt(str, "newImgs"); String[] array = str.split(","); for (int i = 0; i != array.length; ++i) { - list.add(new ImageUrl(i + 1, array[i], false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter,i + 1, array[i], false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Dmzj.java b/app/src/main/java/com/hiroshi/cimoc/source/Dmzj.java index 8d6bacad..d518a959 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Dmzj.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Dmzj.java @@ -94,7 +94,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { try { JSONObject object = new JSONObject(html); String title = object.getString("title"); @@ -113,21 +113,32 @@ public void parseInfo(String html, Comic comic) { } catch (Exception e) { e.printStackTrace(); } + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); try { JSONObject object = new JSONObject(html); JSONArray array = object.getJSONArray("chapters"); + int k=0; for (int i = 0; i != array.length(); ++i) { JSONArray data = array.getJSONObject(i).getJSONArray("data"); for (int j = 0; j != data.length(); ++j) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+k); + JSONObject chapter = data.getJSONObject(j); String title = chapter.getString("chapter_title"); String path = chapter.getString("chapter_id"); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + k++; } } } catch (Exception e) { @@ -143,13 +154,15 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); try { JSONObject object = new JSONObject(html); JSONArray array = object.getJSONArray("page_url"); for (int i = 0; i < array.length(); ++i) { - list.add(new ImageUrl(i + 1, array.getString(i), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, array.getString(i), false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Dmzjv2.java b/app/src/main/java/com/hiroshi/cimoc/source/Dmzjv2.java index b8cd7b37..bb1486d1 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Dmzjv2.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Dmzjv2.java @@ -104,7 +104,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String intro = body.textWithSubstring("p.txtDesc", 3); String title = body.text("#comicName"); @@ -113,22 +113,34 @@ public void parseInfo(String html, Comic comic) { String update = body.textWithSubstring("div.Introduct_Sub > div.sub_r > p:eq(3) > span.date", 0, 10); boolean status = isFinish(body.text("div.sub_r > p:eq(2)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); try { String JsonString = StringUtils.match(":(\\[\\{.*?\\}\\])\\}\\]", html, 1); String decodeJsonString = UicodeBackslashU.unicodeToCn(JsonString); JSONArray JSONArray = new JSONArray(decodeJsonString); + int k=0; for (int j = 0; j != JSONArray.length(); ++j) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+k); + JSONObject chapter = JSONArray.getJSONObject(j); String title = chapter.getString("chapter_name"); String comic_id = chapter.getString("comic_id"); String chapter_id = chapter.getString("id"); String path = comic_id + "/" +chapter_id; - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + k++; } } catch (Exception e) { e.printStackTrace(); @@ -143,14 +155,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String jsonString = StringUtils.match("\"page_url\":(\\[.*?\\]),", html, 1); if (jsonString != null) { try { JSONArray array = new JSONArray(jsonString); for (int i = 0; i != array.length(); ++i) { - list.add(new ImageUrl(i + 1, array.getString(i), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, array.getString(i), false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/EHentai.java b/app/src/main/java/com/hiroshi/cimoc/source/EHentai.java index 72840b33..cec4e675 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/EHentai.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/EHentai.java @@ -67,7 +67,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String update = body.textWithSubstring("#gdd > table > tbody > tr:eq(0) > td:eq(1)", 0, 10); String title = body.text("#gn"); @@ -76,16 +76,25 @@ public void parseInfo(String html, Comic comic) { // String cover = body.href("#gdt > .gdtm > div > a"); String cover = "https://github.com/Haleydu/Cimoc/raw/release-tci/screenshot/icon.png"; comic.setInfo(title, cover, update, intro, author, true); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); String length = body.textWithSplit("#gdd > table > tbody > tr:eq(5) > td:eq(1)", " ", 0); int size = Integer.parseInt(length) % 40 == 0 ? Integer.parseInt(length) / 40 : Integer.parseInt(length) / 40 + 1; for (int i = 0; i != size; ++i) { - list.add(0, new Chapter("Ch" + i, String.valueOf(i))); + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + + list.add( new Chapter(id, sourceComic,"Ch" + i, String.valueOf(i))); } return list; } @@ -123,12 +132,14 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); Node body = new Node(html); int count = 0; for (Node node : body.list("#gdt > div > div > a")) { - list.add(new ImageUrl(++count, node.href(), true)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + count); + list.add(new ImageUrl(id, comicChapter, ++count, node.href(), true)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/GuFeng.java b/app/src/main/java/com/hiroshi/cimoc/source/GuFeng.java index 3f50eb80..a10b5673 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/GuFeng.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/GuFeng.java @@ -77,7 +77,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String cover = body.src("#Cover > mip-img"); String intro = body.text("div.comic-view.clearfix > p"); @@ -89,15 +89,27 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept // 连载状态 boolean status = isFinish("连载"); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("ul[id^=chapter-list] > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); String path = node.hrefWithSplit(2); - list.add(0, new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -109,7 +121,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("chapterImages = \\[(.*?)\\]", html, 1); if (str != null) { @@ -119,8 +131,9 @@ public List parseImages(String html) { for (int i = 0; i != array.length; ++i) { // 去掉首末两端的双引号 String s = array[i].substring(1, array[i].length() - 1); - // http://res.gufengmh8.com/images/comic/159/316518/1519527843Efo9qfJOY9Jb_VP4.jpg - list.add(new ImageUrl(i + 1, "https://res.xiaoqinre.com/" + urlPrev + s, false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, "https://res.xiaoqinre.com/" + urlPrev + s, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/HHAAZZ.java b/app/src/main/java/com/hiroshi/cimoc/source/HHAAZZ.java index 9ee0e201..4b3e1b2b 100755 --- a/app/src/main/java/com/hiroshi/cimoc/source/HHAAZZ.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/HHAAZZ.java @@ -73,7 +73,7 @@ public Request getInfoRequest(String cid) { private String title = ""; @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { final Node body = new Node(html); final String cover = body.src("#about_style > img"); int index = 0; @@ -102,17 +102,29 @@ public void parseInfo(String html, Comic comic) { } } comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); + int i=0; for (Node node : body.list(".cVolList > ul")) { for (Node cnode : node.list("li")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = cnode.attr("a", "title").replace(this.title, "").trim(); String path = cnode.href("a"); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } } return list; @@ -128,7 +140,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); //save page info @@ -138,7 +150,9 @@ public List parseImages(String html) { Node body = new Node(html); int i = 1; for (Node node : body.list("#iPageHtm > a")) { - list.add(new ImageUrl(i, + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, StringUtils.format("http://www.hhimm.com/%s/%d.html?s=%s&d=0", pathId, i, pathS), true)); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/HHSSEE.java b/app/src/main/java/com/hiroshi/cimoc/source/HHSSEE.java index 95c51120..272b9389 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/HHSSEE.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/HHSSEE.java @@ -71,7 +71,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("#about_kit > ul > li:eq(0) > h1"); String cover = body.src("#about_style > img"); @@ -84,20 +84,31 @@ public void parseInfo(String html, Comic comic) { String intro = body.textWithSubstring("#about_kit > ul > li:eq(7)", 3); boolean status = isFinish(body.text("#about_kit > ul > li:eq(2)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new ArrayList<>(); Node body = new Node(html); String name = body.text("#about_kit > ul > li:eq(0) > h1"); + int i=0; for (Node node : body.list("#permalink > div.cVolList > ul.cVolUl > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); title = title.replaceFirst(name, "").trim(); String[] array = StringUtils.match("/page(\\d+).*s=(\\d+)", node.attr("href"), 1, 2); //String path = array != null ? array[0].concat(" ").concat(array[1]) : ""; String path = array != null ? array[0].concat("-").concat(array[1]) : ""; - list.add(new Chapter(title.trim(), path)); + list.add(new Chapter(id, sourceComic, title.trim(), path)); + i++; } return list; } @@ -110,14 +121,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new ArrayList<>(); Node body = new Node(html); int page = Integer.parseInt(body.attr("#hdPageCount", "value")); String path = body.attr("#hdVolID", "value"); String server = body.attr("#hdS", "value"); for (int i = 1; i <= page; ++i) { - list.add(new ImageUrl(i, StringUtils.format("http://www.hhmmoo.com/page%s/%d.html?s=%s", path, i, server), true)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, StringUtils.format("http://www.hhmmoo.com/page%s/%d.html?s=%s", path, i, server), true)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Hhxxee.java b/app/src/main/java/com/hiroshi/cimoc/source/Hhxxee.java index 72543275..7e821ad7 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Hhxxee.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Hhxxee.java @@ -108,7 +108,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text(".cTitle"); String cover = body.src(".cDefaultImg > img"); @@ -117,15 +117,26 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text(".cCon"); boolean status = false; comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#subBookListAct > div")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("a"); String path = node.hrefWithSplit("a", 2); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -141,14 +152,16 @@ private int getPictureServers(String url) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("var sFiles=\"(.*?)\"", html, 1); if (str != null) { try { String[] array = str.split("\\|"); for (int i = 0; i != array.length; ++i) { - list.add(new ImageUrl(i + 1, servers[getPictureServers(array[i])] + array[i], false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter,i + 1, servers[getPictureServers(array[i])] + array[i], false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/IKanman.java b/app/src/main/java/com/hiroshi/cimoc/source/IKanman.java index 4510b91a..a3feea19 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/IKanman.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/IKanman.java @@ -91,7 +91,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("div.book-title > h1"); String cover = body.src("p.hcover > img"); @@ -100,24 +100,35 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("#intro-cut"); boolean status = isFinish(body.text("div.chapter-bar > span.fr > span:eq(0)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); String baseText = body.id("__VIEWSTATE").attr("value"); if (!StringUtils.isEmpty(baseText)) { body = new Node(DecryptionUtils.LZ64Decrypt(baseText)); } + int i=0; for (Node node : body.list("div.chapter-list")) { List uls = node.list("ul"); Collections.reverse(uls); for (Node ul : uls) { for (Node li : ul.list("li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = li.attr("title"); String path = li.hrefWithSplit(2); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } } } @@ -136,7 +147,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String packed = StringUtils.match("\\(function\\(p,a,c,k,e,d\\).*?0,\\{\\}\\)\\)", html, 0); if (packed != null) { @@ -156,8 +167,10 @@ public List parseImages(String html) { String m = object.getJSONObject("sl").getString("m"); JSONArray array = object.getJSONArray("files"); for (int i = 0; i != array.length(); ++i) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); String url = StringUtils.format("https://i.hamreus.com%s%s?e=%s&m=%s", path, array.getString(i), e, m); - list.add(new ImageUrl(i + 1, url, false)); + list.add(new ImageUrl(id, comicChapter, i + 1, url, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Locality.java b/app/src/main/java/com/hiroshi/cimoc/source/Locality.java index 96bf7c48..4a827d09 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Locality.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Locality.java @@ -1,11 +1,14 @@ package com.hiroshi.cimoc.source; +import com.hiroshi.cimoc.core.Manga; import com.hiroshi.cimoc.model.Chapter; import com.hiroshi.cimoc.model.Comic; import com.hiroshi.cimoc.model.ImageUrl; import com.hiroshi.cimoc.parser.MangaParser; import com.hiroshi.cimoc.parser.SearchIterator; +import org.json.JSONException; + import java.util.List; import okhttp3.Headers; @@ -45,7 +48,8 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { + return comic; } @Override @@ -53,6 +57,11 @@ public List parseChapter(String html) { return null; } + @Override + public List parseChapter(String html, Comic comic) throws JSONException { + return null; + } + @Override public Request getImagesRequest(String cid, String path) { return null; @@ -63,6 +72,11 @@ public List parseImages(String html) { return null; } + @Override + public List parseImages(String html, Chapter chapter) throws Manga.NetworkErrorException, JSONException { + return null; + } + @Override public Request getCheckRequest(String cid) { return null; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MH160.java b/app/src/main/java/com/hiroshi/cimoc/source/MH160.java index 2be49ec3..e7a5d192 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MH160.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MH160.java @@ -90,7 +90,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String cover = body.src(".mh-date-bgpic > a > img"); String intro = body.text("#workint > p"); @@ -100,6 +100,7 @@ public void parseInfo(String html, Comic comic) { boolean status = isFinish(body.text("p.works-info-tc > span:eq(3)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override @@ -135,7 +136,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html,Chapter chapter) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("qTcms_S_m_murl_e=\"(.*?)\"", html, 1); String str_id = StringUtils.match("qTcms_S_p_id=\"(.*?)\"", html, 1); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MH50.java b/app/src/main/java/com/hiroshi/cimoc/source/MH50.java index 4ef0db0e..db12587b 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MH50.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MH50.java @@ -92,7 +92,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String intro = body.text("#full-des"); String title = body.text("#comicName"); @@ -102,7 +102,7 @@ public void parseInfo(String html, Comic comic) { String update = body.text(".Introduct_Sub > .sub_r > .txtItme:eq(4)"); boolean status = isFinish(body.text(".Introduct_Sub > .sub_r > .txtItme:eq(2) > a:eq(3)")); comic.setInfo(title, cover, update, intro, author, status); - RxBus.getInstance().post(new RxEvent(RxEvent.EVENT_COMIC_UPDATE_INFO, comic)); + return comic; } @Override diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MH517.java b/app/src/main/java/com/hiroshi/cimoc/source/MH517.java index b0b01cfa..7c552c2b 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MH517.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MH517.java @@ -84,7 +84,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.attr("div#Cover > img", "title"); String cover = body.src("div#Cover > img"); @@ -93,15 +93,27 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("p.txtDesc"); boolean status = false; comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#mh-chapter-list-ol-0 > li")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("a > span"); String path = node.hrefWithSplit("a", 2); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -114,7 +126,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new ArrayList<>(); Matcher pageMatcher = Pattern.compile("qTcms_S_m_murl_e=\"(.*?)\"").matcher(html); final String mangaid = StringUtils.match("var qTcms_S_m_id=\"(\\w+?)\";", html, 1); @@ -124,7 +136,10 @@ public List parseImages(String html) { int i = 0; for (String item : imgArrStr.split("\\$.*?\\$")) { final String url = "http://m.517manhua.com/statics/pic/?p=" + item + "&wapif=1&picid=" + mangaid + "&m_httpurl="; - list.add(new ImageUrl(i++, url, false)); + + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i++, url, false)); } } finally { return list; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MH57.java b/app/src/main/java/com/hiroshi/cimoc/source/MH57.java index c9ce119a..1c31acf4 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MH57.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MH57.java @@ -93,7 +93,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("div.main-bar > h1"); String cover = body.src("div.book-detail > div.cont-list > div.thumb > img"); @@ -102,16 +102,28 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("#bookIntro"); boolean status = isFinish(body.text("div.book-detail > div.cont-list > div.thumb > i")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); + int i=0; for (Node node : body.list("#chapterList > ul > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); String path = node.hrefWithSplit(1); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -123,7 +135,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String packed = StringUtils.match("eval(.*?)\\n", html, 1); if (packed != null) { @@ -137,7 +149,9 @@ public List parseImages(String html) { if(url.indexOf("http://") == -1){ url = servers[0] + url; } - list.add(new ImageUrl(i + 1, url, false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, url, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MHLove.java b/app/src/main/java/com/hiroshi/cimoc/source/MHLove.java index 5d0faf9f..5a357afd 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MHLove.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MHLove.java @@ -72,7 +72,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String cover = body.src(".mh-date-bgpic > a > img"); String intro = body.text("#workint > p"); @@ -82,15 +82,26 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept // 连载状态 boolean status = isFinish(body.text("p.works-info-tc > span:eq(3)")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#mh-chapter-list-ol-0 > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); String path = node.href(); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -102,7 +113,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("qTcms_S_m_murl_e=\"(.*?)\"", html, 1); if (str != null) { @@ -114,7 +125,9 @@ public List parseImages(String html) { preUrl = "http://www.9qv.cn"; } for (int i = 0; i != array.length; ++i) { - list.add(new ImageUrl(i + 1, preUrl + array[i], false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, preUrl + array[i], false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/ManHuaDB.java b/app/src/main/java/com/hiroshi/cimoc/source/ManHuaDB.java index 40bc7323..efa45756 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/ManHuaDB.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/ManHuaDB.java @@ -85,7 +85,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("h1.comic-title"); // String cover = body.src("div.cover > img"); // 这一个封面可能没有 @@ -99,15 +99,26 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept update = body.text("a.comic-pub-date"); } comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#comic-book-list > div > ol > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("title"); String path = node.hrefWithSplit(2); - list.add(0, new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -119,7 +130,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new ArrayList<>(); try { @@ -130,11 +141,13 @@ public List parseImages(String html) { final JSONArray imageList = JSON.parseArray(jsonStr); for(int i = 0; i < imageList.size(); i++ ) { - final JSONObject image = imageList.getJSONObject(i); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + final JSONObject image = imageList.getJSONObject(i); final String imageUrl = imageHost + imagePre + image.getString("img"); - list.add(new ImageUrl(image.getIntValue("p"), imageUrl, false)); + list.add(new ImageUrl(id, comicChapter, image.getIntValue("p"), imageUrl, false)); } } catch (Exception e) { diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MangaBZ.kt b/app/src/main/java/com/hiroshi/cimoc/source/MangaBZ.kt index 235a2217..4637bd7c 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MangaBZ.kt +++ b/app/src/main/java/com/hiroshi/cimoc/source/MangaBZ.kt @@ -59,7 +59,7 @@ class MangaBZ(source: Source?) : MangaParser() { } @Throws(UnsupportedEncodingException::class) - override fun parseInfo(html: String, comic: Comic) { + override fun parseInfo(html: String, comic: Comic):Comic { val body = Node(html) val title = body.text(".detail-info-title") val cover = body.src(".detail-info-cover") @@ -69,15 +69,28 @@ class MangaBZ(source: Source?) : MangaParser() { val intro = body.text(".detail-info-content") val status = isFinish(".detail-list-form-title") comic.setInfo(title, cover, update, intro, author, status) + return comic; } - override fun parseChapter(html: String): List { + override fun parseChapter(html: String, comic: Comic): List { val list: MutableList = LinkedList() + var i = 0 for (node in Node(html).list("#chapterlistload > a")) { + var sourceComic: Long? + sourceComic = if (comic.id == null) { + (comic.source.toString() + sourceToComic + "00").toLong() + } else { + (comic.source.toString() + sourceToComic + comic.id).toLong() + } + val id = (sourceComic.toString() + "000" + i).toLong() + var title = node.attr("title") if (title == "") title = node.text() val path = node.href().trim('/') - list.add(Chapter(title, path)) + + //list.add(Chapter(title, path)) + list.add(Chapter(id, sourceComic, title, path)) + i++ } return list } @@ -100,7 +113,7 @@ class MangaBZ(source: Source?) : MangaParser() { return match?.groups?.get(1)?.value } - override fun parseImages(html: String): List { + override fun parseImages(html: String,chapter: Chapter ): List { val list: MutableList = LinkedList() try { // get page num @@ -110,7 +123,11 @@ class MangaBZ(source: Source?) : MangaParser() { val pageCount = getValFromRegex(html, "MANGABZ_IMAGE_COUNT", "(\\d+)")!!.toInt() for (i in 1..pageCount) { val url = "http://www.mangabz.com/$_path/chapterimage.ashx?cid=$cid&page=$i&key=&_cid=$cid&_mid=$mid&_sign=$sign&_dt=" - list.add(ImageUrl(i + 1, url, true)) + //list.add(ImageUrl(i + 1, url, true)) + + val comicChapter = chapter.id + val id = (comicChapter.toString() + "000" + i).toLong() + list.add(ImageUrl(id, comicChapter, i + 1, url, true)) } } catch (e: Exception) { e.printStackTrace() @@ -132,11 +149,11 @@ class MangaBZ(source: Source?) : MangaParser() { formatter.format(date) } - val url = url + dateStr + return Request.Builder() .addHeader("Referer", "http://www.mangabz.com/$_path/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36") - .url(url).build() + .url(url + dateStr).build() } override fun parseLazy(html: String?, url: String?): String? { diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MangaNel.java b/app/src/main/java/com/hiroshi/cimoc/source/MangaNel.java index e6d41eca..0bd640d2 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MangaNel.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MangaNel.java @@ -109,7 +109,7 @@ public Request getInfoRequest(String cid) { * @param comic 漫画实体类,需要设置其中的字段 */ @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.attr(".info-image > img","title"); String cover = body.src(".info-image > img"); @@ -118,6 +118,7 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("#panel-story-info-description").replace("Description :",""); boolean status = isFinish(body.text("table.variations-tableInfo > tbody > tr:eq(2) > td.table-value > a")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } /** @@ -126,13 +127,23 @@ public void parseInfo(String html, Comic comic) { * @param html 页面源代码 */ @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { Set set = new LinkedHashSet<>(); Node body = new Node(html); + int i=0; for (Node node : body.list(".row-content-chapter > li")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("a"); String path = node.href("a"); - set.add(new Chapter(title, path)); + set.add(new Chapter(id, sourceComic, title, path)); + i++; } return new LinkedList<>(set); } @@ -149,7 +160,7 @@ public Request getImagesRequest(String cid, String path) { } /** - * 解析图片列表,若为惰性加载,则 {@link ImageUrl#lazy} 为 true + * 解析图片列表,若为惰性加载,则 {@link ImageUrl lazy} 为 true * 惰性加载的情况,一次性不能拿到所有图片链接,例如网站使用了多次异步请求 {@link DM5#parseImages},或需要跳转到不同页面 * 才能获取 {@link HHSSEE#parseImages},这些情况一般可以根据页码构造出相应的请求链接,到阅读时再解析 * 支持多个链接 ,例如 {@link IKanman#parseImages} @@ -157,12 +168,14 @@ public Request getImagesRequest(String cid, String path) { * @param html 页面源代码 */ @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); Node body = new Node(html); int i = 0; for (Node node : body.list("div.container-chapter-reader > img")) { - list.add(new ImageUrl(++i, node.src(), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, ++i, node.src(), false)); } return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Mangakakalot.java b/app/src/main/java/com/hiroshi/cimoc/source/Mangakakalot.java index a6f44614..adea0392 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Mangakakalot.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Mangakakalot.java @@ -102,7 +102,7 @@ public Request getInfoRequest(String cid) { * @param comic 漫画实体类,需要设置其中的字段 */ @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); if (cidUrl.contains("mangakakalot")){ String title = body.attr(".manga-info-pic > img","alt"); @@ -121,7 +121,7 @@ public void parseInfo(String html, Comic comic) { boolean status = isFinish(body.text("table.variations-tableInfo > tbody > tr:eq(2) > td.table-value > a")); comic.setInfo(title, cover, update, intro, author, status); } - + return comic; } /** @@ -130,20 +130,40 @@ public void parseInfo(String html, Comic comic) { * @param html 页面源代码 */ @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { Set set = new LinkedHashSet<>(); Node body = new Node(html); if (cidUrl.contains("mangakakalot")) { + int i=0; for (Node node : body.list(".chapter-list > div")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("span > a"); String path = node.href("span > a"); - set.add(new Chapter(title, path)); + set.add(new Chapter(id, sourceComic, title, path)); + i++; } }else if (cidUrl.contains("manganelo")){ + int i=0; for (Node node : body.list(".row-content-chapter > li")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("a"); String path = node.href("a"); - set.add(new Chapter(title, path)); + set.add(new Chapter(id, sourceComic, title, path)); + i++; } } return new LinkedList<>(set); @@ -161,7 +181,7 @@ public Request getImagesRequest(String cid, String path) { } /** - * 解析图片列表,若为惰性加载,则 {@link ImageUrl#lazy} 为 true + * 解析图片列表,若为惰性加载,则 {@link ImageUrl lazy} 为 true * 惰性加载的情况,一次性不能拿到所有图片链接,例如网站使用了多次异步请求 {@link DM5#parseImages},或需要跳转到不同页面 * 才能获取 {@link HHSSEE#parseImages},这些情况一般可以根据页码构造出相应的请求链接,到阅读时再解析 * 支持多个链接 ,例如 {@link IKanman#parseImages} @@ -169,17 +189,21 @@ public Request getImagesRequest(String cid, String path) { * @param html 页面源代码 */ @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); Node body = new Node(html); int i = 0; if (cidUrl.contains("mangakakalot")){ for (Node node : body.list("div#vungdoc > img")) { - list.add(new ImageUrl(++i, node.src(), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id,comicChapter,++i, node.src(), false)); } }else if (cidUrl.contains("manganelo")){ for (Node node : body.list("div.container-chapter-reader > img")) { - list.add(new ImageUrl(++i, node.src(), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id,comicChapter,++i, node.src(), false)); } } return list; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Manhuatai.java b/app/src/main/java/com/hiroshi/cimoc/source/Manhuatai.java index feec3a1f..a1c12cd4 100755 --- a/app/src/main/java/com/hiroshi/cimoc/source/Manhuatai.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Manhuatai.java @@ -121,7 +121,7 @@ public Request getInfoRequest(String cid) { //获取封面等信息(非搜索页) @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.attr("h1#detail-title", "title"); // String cover = body.src("#offlinebtn-container > img");//封面链接已改到style属性里了 @@ -133,17 +133,27 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("div#js_comciDesc > p.desc-content"); // boolean status = isFinish(body.text("div.jshtml > ul > li:nth-child(2)").substring(3)); comic.setInfo(title, cover, update, intro, author, false); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("ol#j_chapter_list > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr( "title"); -// String path = node.hrefWithSplit(0);//于2018.3失效 String path = node.hrefWithSplit(1); -// Log.i("Path", path); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return Lists.reverse(list); } @@ -159,7 +169,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); try { JSONObject object = new JSONObject(html); @@ -168,20 +178,23 @@ public List parseImages(String html) { } JSONArray chapters = object.getJSONObject("data").getJSONArray("comic_chapter"); - JSONObject chapter = null; + JSONObject chapterNew = null; for (int i = 0; i < chapters.length(); i++) { - chapter = chapters.getJSONObject(i); - String a = chapter.getString("chapter_id"); + chapterNew = chapters.getJSONObject(i); + String a = chapterNew.getString("chapter_id"); if(a.equals(_path)) { break; } } - String ImagePattern = "http://mhpic." + chapter.getString("chapter_domain") + chapter.getString("rule") + "-mht.low.webp"; + String ImagePattern = "http://mhpic." + chapterNew.getString("chapter_domain") + chapterNew.getString("rule") + "-mht.low.webp"; + + for (int index = chapterNew.getInt("start_num"); index <= chapterNew.getInt("end_num"); index++) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + index); - for (int index = chapter.getInt("start_num"); index <= chapter.getInt("end_num"); index++) { String image = ImagePattern.replaceFirst("\\$\\$", Integer.toString(index)); - list.add(new ImageUrl(index, image, false)); + list.add(new ImageUrl(id, comicChapter, index, image, false)); } } catch (JSONException ex) { // ignore diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MiGu.java b/app/src/main/java/com/hiroshi/cimoc/source/MiGu.java index 8af4d778..0d332228 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MiGu.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MiGu.java @@ -96,7 +96,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("div.inner > .ctdbRight > .ctdbRightInner > .title").trim(); String cover = body.attr("div.inner > .ctdbLeft > a > img", "src"); @@ -105,14 +105,25 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("#worksDesc").trim(); boolean status = false; comic.setInfo(title, cover, "", intro, "", status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Matcher m = Pattern.compile("").matcher(html); + int i=0; while (m.find()) { - list.add(new Chapter(m.group(2), m.group(1))); + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + + list.add(new Chapter(id, sourceComic, m.group(2), m.group(1))); + i++; } return Lists.reverse(list); } @@ -149,14 +160,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new ArrayList<>(); try { JSONObject json = new JSONObject(html); JSONArray jpgJsonArr = json.getJSONObject("data").getJSONArray("jpgList"); for (int i = 0; i < jpgJsonArr.length(); i++) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); JSONObject j = jpgJsonArr.getJSONObject(i); - list.add(new ImageUrl(i + 1, j.getString("url"), false)); + list.add(new ImageUrl(id, comicChapter, i + 1, j.getString("url"), false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Null.java b/app/src/main/java/com/hiroshi/cimoc/source/Null.java index bbf51d1f..404dc949 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Null.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Null.java @@ -1,11 +1,14 @@ package com.hiroshi.cimoc.source; +import com.hiroshi.cimoc.core.Manga; import com.hiroshi.cimoc.model.Chapter; import com.hiroshi.cimoc.model.Comic; import com.hiroshi.cimoc.model.ImageUrl; import com.hiroshi.cimoc.parser.MangaParser; import com.hiroshi.cimoc.parser.SearchIterator; +import org.json.JSONException; + import java.util.List; import okhttp3.Headers; @@ -41,7 +44,8 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { + return comic; } @Override @@ -49,6 +53,11 @@ public List parseChapter(String html) { return null; } + @Override + public List parseChapter(String html, Comic comic) throws JSONException { + return null; + } + @Override public Request getImagesRequest(String cid, String path) { return null; @@ -59,6 +68,11 @@ public List parseImages(String html) { return null; } + @Override + public List parseImages(String html, Chapter chapter) throws Manga.NetworkErrorException, JSONException { + return null; + } + @Override public Request getCheckRequest(String cid) { return null; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java b/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java index 39bafa83..97384e19 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java @@ -91,7 +91,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("dl.fed-deta-info > dd > h1"); String cover = body.attr("dl.fed-deta-info > dt > a","data-original"); @@ -112,15 +112,27 @@ public void parseInfo(String html, Comic comic) { boolean status = isFinish(statusStr.replace("状态","")); comic.setInfo(title, cover, update.replace("更新",""), intro, author.replace("作者",""), status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("div:not(.fed-hidden) > div.all_data_list > ul.fed-part-rows a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("title"); String path = node.href("a"); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -132,7 +144,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String encodedData = StringUtils.match("C_DATA=\\'(.+?)\\'", html, 1); @@ -146,8 +158,10 @@ public List parseImages(String html) { String totalPages = StringUtils.match("totalimg:([0-9]+?),",decryptedData,1); for (int i = Integer.parseInt(Objects.requireNonNull(startImg)); i <= Integer.parseInt(Objects.requireNonNull(totalPages)); ++i) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); String jpg = StringUtils.format("%04d.jpg", i); - list.add(new ImageUrl(i, serverUrl + imgRelativePath + jpg, false)); + list.add(new ImageUrl(id, comicChapter, i, serverUrl + imgRelativePath + jpg, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/PuFei.java b/app/src/main/java/com/hiroshi/cimoc/source/PuFei.java index 0b9b89a6..3ad3825c 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/PuFei.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/PuFei.java @@ -27,6 +27,7 @@ /** * Created by FEILONG on 2017/12/21. + * fix by Haleydu on 2020/8/30 */ public class PuFei extends MangaParser { @@ -86,7 +87,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("div.main-bar > h1"); String cover = body.src("div.book-detail > div.cont-list > div.thumb > img"); @@ -95,15 +96,27 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("#bookIntro"); boolean status = isFinish(body.text("div.book-detail > div.cont-list > div.thumb > i")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("#chapterList2 > ul > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.attr("title"); String path = node.hrefWithSplit(2); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -115,7 +128,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("cp=\"(.*?)\"", html, 1); if (str != null) { @@ -123,7 +136,9 @@ public List parseImages(String html) { str = DecryptionUtils.evalDecrypt(DecryptionUtils.base64Decrypt(str)); String[] array = str.split(","); for (int i = 0; i != array.length; ++i) { - list.add(new ImageUrl(i + 1, "http://res.img.youzipi.net/" + array[i], false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, "http://res.img.youzipi.net/" + array[i], false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/QiManWu.java b/app/src/main/java/com/hiroshi/cimoc/source/QiManWu.java index cdd3a72b..a32d1d50 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/QiManWu.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/QiManWu.java @@ -93,7 +93,7 @@ public Request getInfoRequest(String cid) { private static String ChapterHtml; @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { ChapterHtml = html; Node body = new Node(html); String update = body.text(".box-back2 > :eq(4)"); @@ -105,6 +105,7 @@ public void parseInfo(String html, Comic comic) { String cover = body.src(".box-back1 > img"); boolean status = isFinish(body.text(".box-back2 > p.txtItme.c1")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override @@ -120,20 +121,41 @@ public Request getChapterRequest(String html, String cid) { } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int k=0; for (Node node : new Node(ChapterHtml).list("div.catalog-list > ul > li")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+k); + String title = node.text("a"); String path = node.attr("li", "data-id"); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + k++; } try { JSONArray array = new JSONArray(html); for (int i = 0; i != array.length(); ++i) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+k); + JSONObject chapter = array.getJSONObject(i); String title = chapter.getString("name"); String path = chapter.getString("id"); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + k++; } } catch (Exception e) { e.printStackTrace(); @@ -148,14 +170,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("eval\\((.*?\\}\\))\\)", html, 0); try { str = DecryptionUtils.evalDecrypt(str, "newImgs"); String[] array = str.split(","); for (int i = 0; i != array.length; ++i) { - list.add(new ImageUrl(i + 1, array[i], false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id,comicChapter,i + 1, array[i], false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Tencent.java b/app/src/main/java/com/hiroshi/cimoc/source/Tencent.java index 0e062419..d6ba9c85 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Tencent.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Tencent.java @@ -89,7 +89,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("li.head-info-title > h1"); String cover = body.src("div.head-info-cover > img"); @@ -98,6 +98,7 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept String intro = body.text("div.detail-summary > p"); boolean status = isFinish("连载中");//todo: fix here comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override @@ -109,12 +110,23 @@ public Request getChapterRequest(String html, String cid) { } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("ul.normal > li.chapter-item")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("a"); String path = node.href("a").substring("/chapter/index/id/518333/cid/".length()); - list.add(new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return Lists.reverse(list); } @@ -149,7 +161,7 @@ private String decodeData(String str, String nonce) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("data:\\s*'(.*)?',", html, 1); if (str != null) { @@ -160,7 +172,9 @@ public List parseImages(String html) { JSONObject object = new JSONObject(str); JSONArray array = object.getJSONArray("picture"); for (int i = 0; i != array.length(); ++i) { - list.add(new ImageUrl(i + 1, array.getJSONObject(i).getString("url"), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i + 1, array.getJSONObject(i).getString("url"), false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/TuHao.java b/app/src/main/java/com/hiroshi/cimoc/source/TuHao.java index 7c3efb5d..d726e75d 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/TuHao.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/TuHao.java @@ -78,7 +78,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String cover = body.src("img.pic"); String intro = body.text("p#comic-description"); @@ -90,15 +90,25 @@ public void parseInfo(String html, Comic comic) { // 连载状态 boolean status = isFinish(body.text("div.cy_xinxi > span:eq(1) > a")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i = 0; for (Node node : new Node(html).list("div.cy_plist > ul > li")) { + Long sourceComic = null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic + "000" + i); String title = node.text(); String path = node.hrefWithSplit("a", 1); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -110,14 +120,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String str = StringUtils.match("\"page_url\":\"(.*?)\",", html, 1); int i = 0; - for(String url : Objects.requireNonNull(str).split("\\|72cms\\|")) { - list.add(new ImageUrl(++i, url, false)); + for (String url : Objects.requireNonNull(str).split("\\|72cms\\|")) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, ++i, url, false)); } return list; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/U17.java b/app/src/main/java/com/hiroshi/cimoc/source/U17.java index 9ea6ca15..78b8fd16 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/U17.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/U17.java @@ -22,6 +22,7 @@ import java.util.LinkedList; import java.util.List; +import okhttp3.CipherSuite; import okhttp3.FormBody; import okhttp3.Headers; import okhttp3.Request; @@ -82,7 +83,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("div.comic_info > div.left > h1.fl"); String cover = body.src("div.comic_info > div.left > div.coverBox > div.cover > a > img"); @@ -91,17 +92,29 @@ public void parseInfo(String html, Comic comic) { boolean status = isFinish(body.text("div.comic_info > div.left > div.info > div.top > div.line1 > span:eq(2)")); String update = body.textWithSubstring("div.main > div.chapterlist > div.chapterlist_box > div.bot > div.fl > span", 7); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { // http://m.u17.com/chapter/list?comicId=%s List list = new LinkedList<>(); Node body = new Node(html); + int i=0; for (Node node : body.list("#chapter > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); String path = node.hrefWithSplit(1); - list.add(0, new Chapter(title, path)); + + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -114,7 +127,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); /* String result = StringUtils.match("image_list: .*?\\('(.*?)'\\)", html, 1); @@ -131,8 +144,10 @@ public List parseImages(String html) { JSONObject object = new JSONObject(html); JSONArray array = object.getJSONArray("image_list"); for (int i = 0; i < array.length(); ++i) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); String url = array.getJSONObject(i).getString("src"); - list.add(new ImageUrl(i + 1, url, false)); + list.add(new ImageUrl(id, comicChapter, i + 1, url, false)); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Webtoon.java b/app/src/main/java/com/hiroshi/cimoc/source/Webtoon.java index 476896e7..a4384956 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/Webtoon.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/Webtoon.java @@ -80,7 +80,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { Node body = new Node(html); String title = body.text("#ct > div.detail_info > a._btnInfo > p.subj"); String cover = body.src("#_episodeList > li > a > div.row > div.pic > img"); @@ -93,16 +93,27 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("#_informationLayer > p.summary_area"); boolean status = isFinish(body.text("#_informationLayer > div.info_update")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); Node body = new Node(html); + int i=0; for (Node node : body.list("#_episodeList > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text("div.row > div.info > p.sub_title > span"); String path = node.hrefWithSubString(30); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } return list; } @@ -114,7 +125,7 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); String jsonString = StringUtils.match("var imageList = ([\\s\\S]*?);", html, 1); if (jsonString != null) { @@ -122,8 +133,10 @@ public List parseImages(String html) { JSONArray array = new JSONArray(jsonString); int size = array.length(); for (int i = 0; i != size; ++i) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); JSONObject object = array.getJSONObject(i); - list.add(new ImageUrl(i + 1, object.getString("url"), false)); + list.add(new ImageUrl(id, comicChapter, i + 1, object.getString("url"), false)); } } catch (JSONException e) { e.printStackTrace(); diff --git a/app/src/main/java/com/hiroshi/cimoc/source/WebtoonDongManManHua.java b/app/src/main/java/com/hiroshi/cimoc/source/WebtoonDongManManHua.java index 65b0985e..ca4d5f57 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/WebtoonDongManManHua.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/WebtoonDongManManHua.java @@ -79,7 +79,8 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) { + public Comic parseInfo(String html, Comic comic) { + k=0; Node body = new Node(html); String title = body.text(".detail_header > .info > h1.subj"); String cover = body.src("ul#_listUl > li:eq(0) > a > span.thmb > img"); @@ -88,20 +89,30 @@ public void parseInfo(String html, Comic comic) { String intro = body.text("#_asideDetail > p.summary"); boolean status = isFinish(body.text("#_asideDetail > p.day_info")); comic.setInfo(title, cover, update, intro, author, status); + return comic; } - public List parseChapter(Node body){ + private int k=0; + public List parseChapter(Node body, Comic comic){ List list = new LinkedList<>(); for (Node node : body.list("ul#_listUl > li > a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+k); String title = node.text("span.subj > span")+" "+node.text("span.tx"); String path = "https:" + node.href(); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + k++; } return list; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { //下次再优化吧,这样写比较容易但是效率低。 List list = new LinkedList<>(); Node body = new Node(html); @@ -109,7 +120,7 @@ public List parseChapter(String html) { String urlPage = nodePage.href(); String urlPageTag = nodePage.attr("a","class"); if (urlPage.equals("#") && (urlPageTag==null || urlPageTag.equals(""))){ - list.addAll(parseChapter(body)); + list.addAll(parseChapter(body,comic)); }else if (urlPageTag==null || urlPageTag.equals("")){ try { String pageTagUrl = baseUrl + urlPage; @@ -118,7 +129,7 @@ public List parseChapter(String html) { .addHeader("Referer", "www.dongmanmanhua.cn") .build(); String htmlPage = getResponseBody(App.getHttpClient(), request); - list.addAll(parseChapter(new Node(htmlPage))); + list.addAll(parseChapter(new Node(htmlPage),comic)); } catch (Manga.NetworkErrorException e) { e.printStackTrace(); } @@ -130,7 +141,7 @@ public List parseChapter(String html) { .addHeader("Referer", "www.dongmanmanhua.cn") .build(); String htmlPageNext = getResponseBody(App.getHttpClient(), request); - list.addAll(parseChapter(htmlPageNext)); + list.addAll(parseChapter(htmlPageNext,comic)); } catch (Manga.NetworkErrorException e) { e.printStackTrace(); } @@ -145,14 +156,16 @@ public Request getImagesRequest(String cid, String path) { } @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); Node body = new Node(html); int i = 1; for (Node node : body.list("div#_imageList > img")) { + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); String url = node.attr("img", "data-url"); - list.add(new ImageUrl(i++, url, false)); + list.add(new ImageUrl(id, comicChapter, i++, url, false)); } if (!list.isEmpty()) return list; @@ -171,7 +184,9 @@ public List parseImages(String html) { while (Json_Iterator.hasNext()) { String key = Json_Iterator.next(); if (key.contains("layer")) { - list.add(new ImageUrl(i, motiontoonPath + motiontoonJson.getString(key), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id, comicChapter, i, motiontoonPath + motiontoonJson.getString(key), false)); i++; } } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/YYLS.java b/app/src/main/java/com/hiroshi/cimoc/source/YYLS.java index ed8a51cf..a98a651b 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/YYLS.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/YYLS.java @@ -75,7 +75,7 @@ public Request getInfoRequest(String cid) { } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public Comic parseInfo(String html, Comic comic) throws UnsupportedEncodingException { Node body = new Node(html); String title = body.text("#main > div > div.entry-header.cf > div > h1"); String cover = body.src("#details > div.entry-content.rich-content > table > tbody > tr:nth-child(1) > td:nth-child(1) > img"); @@ -85,17 +85,27 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept Matcher matcher = Pattern.compile("經典完結").matcher(html); boolean status = matcher.find(); comic.setInfo(title, cover, update, intro, author, status); + return comic; } @Override - public List parseChapter(String html) { + public List parseChapter(String html, Comic comic) { List list = new LinkedList<>(); + int i=0; for (Node node : new Node(html).list("div.entry-content.rich-content a")) { + Long sourceComic=null; + if (comic.getId() == null) { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + "00"); + } else { + sourceComic = Long.parseLong(comic.getSource() + sourceToComic + comic.getId()); + } + Long id = Long.parseLong(sourceComic+"000"+i); + String title = node.text(); -// title = Pattern.compile("[^0-9.]").matcher(title).replaceAll(""); String path = node.href(); path = path.substring(17, path.length() - 1); - list.add(new Chapter(title, path)); + list.add(new Chapter(id, sourceComic, title, path)); + i++; } Collections.reverse(list); return list; @@ -109,7 +119,7 @@ public Request getImagesRequest(String cid, String path) { @Override - public List parseImages(String html) { + public List parseImages(String html, Chapter chapter) { List list = new LinkedList<>(); Matcher pageMatcher = Pattern.compile("id=.*?caonima.*?src=\"(.*?)\\d{3}\\.jpg").matcher(html); if (!pageMatcher.find()) return null; @@ -117,7 +127,9 @@ public List parseImages(String html) { if (!NumMatcher.find()) return null; int page = Integer.parseInt(NumMatcher.group(1)); for (int i = 1; i <= page; ++i) { - list.add(new ImageUrl(i, StringUtils.format("%s//%03d.jpg", pageMatcher.group(1), i), false)); + Long comicChapter = chapter.getId(); + Long id = Long.parseLong(comicChapter + "000" + i); + list.add(new ImageUrl(id,comicChapter,i, StringUtils.format("%s//%03d.jpg", pageMatcher.group(1), i), false)); } return list; }