Skip to content

Commit

Permalink
fix bainianmanhua
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleydu committed Aug 19, 2020
1 parent ed6a068 commit 0583be5
Showing 1 changed file with 17 additions and 36 deletions.
53 changes: 17 additions & 36 deletions app/src/main/java/com/hiroshi/cimoc/source/BaiNian.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/**
* Created by ZhiWen on 2019/02/25.
* fixed by haleydu on 2020/8/20.
*/

public class BaiNian extends MangaParser {
Expand All @@ -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/")
Expand All @@ -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
Expand All @@ -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");
Expand All @@ -104,49 +103,31 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept
@Override
public List<Chapter> parseChapter(String html) {
List<Chapter> 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<ImageUrl> parseImages(String html) {
List<ImageUrl> 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();
Expand Down

0 comments on commit 0583be5

Please sign in to comment.