From 0583be5e9755c4ee4543bd8603f65dd1b355e027 Mon Sep 17 00:00:00 2001 From: haleydu <924323178@qq.com> Date: Thu, 20 Aug 2020 01:20:08 +0800 Subject: [PATCH] fix bainianmanhua --- .../com/hiroshi/cimoc/source/BaiNian.java | 53 ++++++------------- 1 file changed, 17 insertions(+), 36 deletions(-) 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 1977e188..deb2db41 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java @@ -22,6 +22,7 @@ /** * Created by ZhiWen on 2019/02/25. + * fixed by haleydu on 2020/8/20. */ public class BaiNian extends MangaParser { @@ -42,11 +43,11 @@ public static Source getDefaultSource() { public Request getSearchRequest(String keyword, int page) throws UnsupportedEncodingException { String url = ""; if (page == 1) { - url = "https://m.bnmanhua.com/index.php?m=vod-search"; + url = "https://m.bnmanhua.com/index.php/search.html"; } RequestBody requestBodyPost = new FormBody.Builder() - .add("wd", keyword) + .add("keyword", keyword) .build(); return new Request.Builder() .addHeader("Referer", "https://m.bnmanhua.com/") @@ -64,17 +65,16 @@ public SearchIterator getSearchIterator(String html, int page) { @Override protected Comic parse(Node node) { String title = node.attr("a.vbox_t", "title"); - String cid = node.attr("a.vbox_t", "href").substring(7); + String cid = node.attr("a.vbox_t", "href"); String cover = node.attr("a.vbox_t > mip-img", "src"); - String update = node.text("h4:eq(2)"); // 从1开始 - return new Comic(TYPE, cid, title, cover, update, null); + return new Comic(TYPE, cid, title, cover, null, null); } }; } @Override public String getUrl(String cid) { - return "http://m.bnmanhua.com/comic/".concat(cid); + return "https://m.bnmanhua.com".concat(cid); } @Override @@ -84,13 +84,12 @@ protected void initUrlFilterList() { @Override public Request getInfoRequest(String cid) { - String url = cid.indexOf(".html") > 0 ? "http://m.bnmanhua.com/comic/".concat(cid) - : "http://m.bnmanhua.com/comic/".concat(cid).concat(".html"); + String url = "https://m.bnmanhua.com".concat(cid); return new Request.Builder().url(url).build(); } @Override - public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + public void 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"); @@ -104,49 +103,31 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept @Override public List parseChapter(String html) { List list = new LinkedList<>(); - // 此处得到的章节列表是从 第1话 开始的 for (Node node : new Node(html).list("div.tabs_block > ul > li > a")) { String title = node.text(); - String path = node.hrefWithSplit(2); - // 将新得到的章节插入到链表的开头 - list.add(0, new Chapter(title, path)); + String path = node.href(); + list.add(new Chapter(title, path)); } return list; } @Override public Request getImagesRequest(String cid, String path) { - cid = cid.substring(0, cid.length() - 5); - String url = StringUtils.format("http://m.bnmanhua.com/comic/%s/%s.html", cid, path); + String url = "https://m.bnmanhua.com".concat(path); return new Request.Builder().url(url).build(); } @Override public List parseImages(String html) { List list = new LinkedList<>(); - String url = StringUtils.match("z_yurl='(.*?)'", html, 1); - String str = StringUtils.match("z_img=\'\\[(.*?)\\]\'", html, 1); - if (str != null && !str.equals("")) { + String host = StringUtils.match("src=\"(.*?)\\/upload", html, 1); + String path_str = StringUtils.match("z_img=\'\\[(.*?)\\]\'", html, 1); + if (path_str != null && !path_str.equals("")) { try { - String[] array = str.split(","); + String[] array = path_str.split(","); for (int i = 0; i != array.length; ++i) { - String[] ss = array[i].split("\\\\/"); - String lastStr = null; - String prevStr = null; - String s = null; - if (ss.length > 5) { - prevStr = ss[3] + "/" + ss[4] + "/"; - lastStr = ss[7].substring(0, ss[7].length() - 1); - s = ss[5] + "/" + ss[6] + "/" + lastStr; - } else { - lastStr = ss[4].substring(0, ss[4].length() - 1); // 需要去掉末尾的双引号 - prevStr = ss[0].substring(1) + "/" + ss[1] + "/"; // 需要去掉开头的双引号 - s = ss[2] + "/" + ss[3] + "/" + lastStr; - } - -// http://bnpic.comic123.net/upload/files/15/2619/15489140020.jpg -// http://bnpic.comic123.net/images/comic/2ain: github.com. Please check that this domain has been added to a service.5/48730/1522165706dcYCM4Z4HjkbKrlQ.jpg - list.add(new ImageUrl(i + 1, url + prevStr + s, false)); + String path = array[i].replace("\"","").replace("\\",""); + list.add(new ImageUrl(i + 1, host+"/"+path, false)); } } catch (Exception e) { e.printStackTrace();