Skip to content

Commit

Permalink
fix dmzjv2, closed #78
Browse files Browse the repository at this point in the history
  • Loading branch information
Haleydu committed Aug 19, 2020
1 parent 75df425 commit ed6a068
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions app/src/main/java/com/hiroshi/cimoc/source/Dmzjv2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.util.Pair;

import com.google.common.collect.Lists;
import com.hiroshi.cimoc.model.Chapter;
import com.hiroshi.cimoc.model.Comic;
import com.hiroshi.cimoc.model.ImageUrl;
Expand All @@ -15,6 +14,7 @@
import com.hiroshi.cimoc.parser.UrlFilter;
import com.hiroshi.cimoc.soup.Node;
import com.hiroshi.cimoc.utils.StringUtils;
import com.hiroshi.cimoc.utils.UicodeBackslashU;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down Expand Up @@ -65,19 +65,31 @@ public Request getSearchRequest(String keyword, int page) {

@Override
public SearchIterator getSearchIterator(String html, int page) {
Node body = new Node(html);
return new NodeIterator(body.list("#app > div > .van-list > .itemBox")) {
@Override
protected Comic parse(Node node) {
String cid = node.hrefWithSplit(".itemTxt > a", 1);
String title = node.text(".itemTxt > a");
String cover = node.src(".itemImg > a > img");
if (cover.startsWith("//")) cover = "https:" + cover;
String update = node.text(".itemTxt > p:eq(3)");
String author = node.text(".itemTxt > p:eq(1)");
return new Comic(TYPE, cid, title, cover, update, author);
}
};
try {
String JsonString = StringUtils.match("var serchArry=(\\[\\{.*?\\}\\])", html, 1);
String decodeJsonString = UicodeBackslashU.unicodeToCn(JsonString).replace("\\/","/");
return new JsonIterator(new JSONArray(decodeJsonString)) {
@Override
protected Comic parse(JSONObject object) {
try {
String cid = object.getString("comic_py");
String title = object.getString("name");
String cover = object.getString("cover");
cover = "https://images.dmzj.com/"+cover;
String author = object.optString("authors");
long time = Long.parseLong(object.getString("last_updatetime")) * 1000;
String update = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date(time));
return new Comic(TYPE, cid, title, cover, update, author);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
};
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}

@Override
Expand All @@ -95,35 +107,27 @@ public Request getInfoRequest(String cid) {
public void parseInfo(String html, Comic comic) {
Node body = new Node(html);
String intro = body.textWithSubstring("p.txtDesc", 3);
String title = body.text(".subHeader > .BarTit");
String title = body.text("#comicName");
String cover = body.src("#Cover > img");
String author = body.text("div.Introduct_Sub > div.sub_r > p:eq(0) > a");
String author = body.text("a.pd.introName");
String update = body.textWithSubstring("div.Introduct_Sub > div.sub_r > p:eq(3) > span.date", 0, 10);
boolean status = isFinish(body.text(".list > .qjBar").trim());
boolean status = isFinish(body.text("div.sub_r > p:eq(2)"));
comic.setInfo(title, cover, update, intro, author, status);
}

@Override
public List<Chapter> parseChapter(String html) {
// List<Chapter> list = new LinkedList<>();
// Node body = new Node(html);
// for (Node node : body.list("div.list > ul > li > a")) {
// String title = node.text("span");
// String path = StringUtils.split(node.href(), "/", 3);
// list.add(new Chapter(title, path));
// }
// return Lists.reverse(list);

List<Chapter> list = new LinkedList<>();
try {
String JsonString = StringUtils.match("\"chapter\":\\[(.*\\}\\]\\})\\],", html, 1);
JSONObject object = new JSONObject(JsonString);
JSONArray data = object.getJSONArray("data");
for (int j = 0; j != data.length(); ++j) {
JSONObject chapter = data.getJSONObject(j);
String JsonString = StringUtils.match(":(\\[\\{.*?\\}\\])\\}\\]", html, 1);
String decodeJsonString = UicodeBackslashU.unicodeToCn(JsonString);
JSONArray JSONArray = new JSONArray(decodeJsonString);
for (int j = 0; j != JSONArray.length(); ++j) {
JSONObject chapter = JSONArray.getJSONObject(j);
String title = chapter.getString("chapter_name");
String path = chapter.getString("id");
//Integer.parseInt(chapter.getString("chapter_order"));
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));
}
} catch (Exception e) {
Expand All @@ -134,7 +138,7 @@ public List<Chapter> parseChapter(String html) {

@Override
public Request getImagesRequest(String cid, String path) {
String url = StringUtils.format("http://m.dmzj.com/view/%s/%s.html", cid, path);
String url = StringUtils.format("http://m.dmzj.com/view/%s.html", path);
return new Request.Builder().url(url).build();
}

Expand Down

0 comments on commit ed6a068

Please sign in to comment.