Skip to content

Commit

Permalink
Merge branch 'release-tci' of https://github.com/Haleydu/Cimoc into r…
Browse files Browse the repository at this point in the history
…elease-tci
  • Loading branch information
Haleydu committed Jul 17, 2020
2 parents a6aaca1 + c1cc931 commit 52f380e
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 70 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:name=".App"
Expand All @@ -13,6 +14,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
android:largeHeap="true"
android:theme="@style/AppTheme">
<activity
Expand Down Expand Up @@ -260,6 +262,7 @@
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:permission="android.permission.MANAGE_DOCUMENTS"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
Expand Down
19 changes: 13 additions & 6 deletions app/src/main/java/com/hiroshi/cimoc/source/CpManHua.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.hiroshi.cimoc.source;

import com.alibaba.fastjson.JSONArray;

import com.google.common.collect.Lists;
import com.hiroshi.cimoc.model.Chapter;
import com.hiroshi.cimoc.model.Comic;
Expand All @@ -13,11 +13,13 @@
import com.hiroshi.cimoc.soup.Node;
import com.hiroshi.cimoc.utils.DecryptionUtils;
import com.hiroshi.cimoc.utils.HttpUtils;
import com.hiroshi.cimoc.utils.LogUtil;
import com.hiroshi.cimoc.utils.StringUtils;

import org.json.JSONException;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -44,19 +46,24 @@ public CpManHua(Source source) {
public Request getSearchRequest(String keyword, int page) throws UnsupportedEncodingException {
if (page != 1) return null;
String url = StringUtils.format("https://www.copymanga.com/search?q=%s", keyword);
//LogUtil.i(url);

return new Request.Builder().url(url).build();
}

@Override
public SearchIterator getSearchIterator(String html, int page) throws JSONException {
//LogUtil.iLength("hrd",html);
Node body = new Node(html);
return new NodeIterator(body.list("ul#listbody > li")) {
return new NodeIterator(body.list("div.tab-content > div.tab-pane > div.row")) {
@Override
protected Comic parse(Node node) {
final String cid = node.href("a.ImgA");
final String title = node.text("a.txtA");
final String cover = node.attr("a.ImgA > img", "src");
return new Comic(TYPE, cid, title, cover, "", "");
final String cid = node.href("div.exemptComicItem-img > a");
final String title = node.text("div.exemptComicItem-txt-box > div.exemptComicItem-txt > a > p");
final String cover = node.attr("div.exemptComicItem-img > a > img", "src");
final String update = node.text("");
final String author = node.text("span.exemptComicItem-txt-span");
return new Comic(TYPE, cid, title, cover, update, author);
}
};
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/hiroshi/cimoc/source/MH50.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hiroshi.cimoc.source;

import android.util.Log;
import android.util.Pair;

import com.alibaba.fastjson.JSONArray;
Expand All @@ -16,6 +17,7 @@
import com.hiroshi.cimoc.soup.Node;
import com.hiroshi.cimoc.utils.DecryptionUtils;
import com.hiroshi.cimoc.utils.HttpUtils;
import com.hiroshi.cimoc.utils.LogUtil;
import com.hiroshi.cimoc.utils.StringUtils;

import java.net.URLEncoder;
Expand Down Expand Up @@ -119,7 +121,7 @@ public Request getImagesRequest(String cid, String path) {
return HttpUtils.getSimpleMobileRequest(url);
}

private final String[] server = {"https://mhcdn.manhuazj.com"};
private final String[] server = {"https://img01.eshanyao.com", "https://manga9.mlxsc.com",};

@Nullable
private String decrypt(String code) {
Expand Down Expand Up @@ -154,6 +156,7 @@ private String getImageUrlByKey(String key, String domain, String chapter) {

@Override
public List<ImageUrl> parseImages(String html) {
LogUtil.iLength("hrd",html);
List<ImageUrl> list = new LinkedList<>();

//该章节的所有图片url,aes加密
Expand All @@ -168,6 +171,7 @@ public List<ImageUrl> parseImages(String html) {
for (int i = 0; i != imageListSize; ++i) {
String key = imageList.getString(i);
String imageUrl = getImageUrlByKey(key, server[0], chapterPath);

list.add(new ImageUrl(i + 1, imageUrl, false));
}

Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/com/hiroshi/cimoc/source/MH517.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.hiroshi.cimoc.source;

import android.util.Log;

import com.hiroshi.cimoc.model.Chapter;
import com.hiroshi.cimoc.model.Comic;
import com.hiroshi.cimoc.model.ImageUrl;
Expand All @@ -10,6 +12,7 @@
import com.hiroshi.cimoc.parser.UrlFilter;
import com.hiroshi.cimoc.soup.Node;
import com.hiroshi.cimoc.utils.DecryptionUtils;
import com.hiroshi.cimoc.utils.LogUtil;
import com.hiroshi.cimoc.utils.StringUtils;

import java.io.UnsupportedEncodingException;
Expand Down Expand Up @@ -55,7 +58,9 @@ protected Comic parse(Node node) {
final String cid = node.href("a.ImgA");
final String title = node.text("a.txtA");
final String cover = node.attr("a.ImgA > img", "src");
return new Comic(TYPE, cid, title, cover, "", "");
final String update = node.text("");
final String author = node.text("");
return new Comic(TYPE, cid, title, cover, update, author);
}
};
}
Expand Down Expand Up @@ -83,8 +88,8 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept
Node body = new Node(html);
String title = body.attr("div#Cover > img", "title");
String cover = body.src("div#Cover > img");
String update = "";
String author = "";
String update = body.text("span.date" );
String author = body.text("");
String intro = body.text("p.txtDesc");
boolean status = false;
comic.setInfo(title, cover, update, intro, author, status);
Expand Down Expand Up @@ -112,7 +117,9 @@ public Request getImagesRequest(String cid, String path) {
public List<ImageUrl> parseImages(String html) {
List<ImageUrl> list = new ArrayList<>();
Matcher pageMatcher = Pattern.compile("qTcms_S_m_murl_e=\"(.*?)\"").matcher(html);
if (!pageMatcher.find()) return null;
if (!pageMatcher.find()) {
return null;
}
try {
final String imgArrStr = DecryptionUtils.base64Decrypt(pageMatcher.group(1));
int i = 0;
Expand Down
104 changes: 50 additions & 54 deletions app/src/main/java/com/hiroshi/cimoc/source/TuHao.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.hiroshi.cimoc.source;

import android.util.Log;

import com.hiroshi.cimoc.App;
import com.hiroshi.cimoc.model.Chapter;
import com.hiroshi.cimoc.model.Comic;
import com.hiroshi.cimoc.model.ImageUrl;
Expand All @@ -9,15 +12,21 @@
import com.hiroshi.cimoc.parser.SearchIterator;
import com.hiroshi.cimoc.parser.UrlFilter;
import com.hiroshi.cimoc.soup.Node;
import com.hiroshi.cimoc.utils.LogUtil;
import com.hiroshi.cimoc.utils.StringUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import okhttp3.Headers;
import okhttp3.Request;

import static com.hiroshi.cimoc.core.Manga.getResponseBody;

/**
* Created by ZhiWen on 2019/02/25.
*/
Expand All @@ -39,61 +48,57 @@ public TuHao(Source source) {
public Request getSearchRequest(String keyword, int page) throws UnsupportedEncodingException {
String url = "";
if (page == 1) {
url = StringUtils.format("https://www.toho8.cn/action/Search?keyword=%s", keyword);
//https://m.tuhaomh.com/e/search/index.php?searchget=1&tempid=1&tbname=book&show=title,writer&keyboard=%s
}
url = StringUtils.format("https://m.tuhaomh.com/e/search/index.php?searchget=1&tempid=1&tbname=book&show=title,writer&keyboard=%s",
//URLEncoder.encode(keyword, "GB2312"));
keyword);
return new Request.Builder().url(url).build();
}

@Override
public String getUrl(String cid) {
return "https://www.toho8.cn/".concat(cid).concat("/");
return "https://m.tuhaomh.com/".concat(cid).concat("/");
}

@Override
protected void initUrlFilterList() {
filter.add(new UrlFilter("www.toho8.cn", "\\w+", 0));
filter.add(new UrlFilter("m.tuhaomh.com", "\\w+", 0));
}

@Override
public SearchIterator getSearchIterator(String html, int page) {
Node body = new Node(html);
return new NodeIterator(body.list("#classList_1 > ul > li")) {
return new NodeIterator(body.list("div.bd > ul.comic-sort > li")) {
@Override
protected Comic parse(Node node) {

String title = node.attr("a", "title");
String title = node.attr("div.comic-item > div.thumbnail >a","title");
title = title.replace("<font color='red'>", "");
title = title.replace("</font>", "");
String urls = node.attr("a", "href");
String cid = urls.substring(1, urls.length() - 1);
String cover = node.attr("a > div > img", "src");
return new Comic(TYPE, cid, title, cover, null, null);
String cid = urls.substring(1, urls.length());
String cover = node.attr("div.comic-item > div.thumbnail > a > img", "data-src");
String update = node.text("div.comic-item > div.thumbnail > a > span.chapter");
return new Comic(TYPE, cid, title, cover, update, null);
}
};
}

@Override
public Request getInfoRequest(String cid) {
String url = "https://www.toho8.cn/".concat(cid).concat("/");
String url = "https://m.tuhaomh.com/"+ cid;
return new Request.Builder().url(url).build();
}

@Override
public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException {
Node body = new Node(html);
String cover = body.src("div.coverForm > img");
String intro = body.text("div.detailContent > p");
String title = body.text("div.detailForm > div > div > h1");

String update = "";
String author = "";
List<Node> upDateAndAuth = body.list("div.detailForm > div > div > p");

if (upDateAndAuth.size() == 5) {
update = upDateAndAuth.get(3).text().substring(5).trim();
author = upDateAndAuth.get(2).text().substring(3).trim();
} else {
update = upDateAndAuth.get(2).text().substring(5).trim();
author = upDateAndAuth.get(1).text().substring(3).trim();
}
String cover = body.attr("div.mk-detail > div.comic-info > div.cover-bg > img.thumbnail","data-src");
String intro = body.text("p.content");
String title = body.text("h1.name");

String update = body.text("time#updateTime");
String author = body.text("span.author");

// 连载状态
boolean status = isFinish("连载");
Expand All @@ -103,38 +108,39 @@ public void parseInfo(String html, Comic comic) throws UnsupportedEncodingExcept
@Override
public List<Chapter> parseChapter(String html) {
List<Chapter> list = new LinkedList<>();
for (Node node : new Node(html).list("#chapterList_1 > ul > li > a")) {
String title = node.text();
String path = node.hrefWithSplit(1);
for (Node node : new Node(html).list("div.mk-chapterlist-box > div.bd > ul.chapterlist > li.item")) {
String title = node.text("a.chapterBtn");
String path = node.attr("a","href");
list.add(new Chapter(title, path));
}
return list;
}

@Override
public Request getImagesRequest(String cid, String path) {
String url = StringUtils.format("https://www.toho8.cn/%s/%s.html", cid, path);
String url = "https://m.tuhaomh.com"+ path;
imgurl = url;
return new Request.Builder().url(url).build();
}
private String imgurl = "";

@Override
public List<ImageUrl> parseImages(String html) {
List<ImageUrl> list = new LinkedList<>();
Node body = new Node(html);
int total = Integer.parseInt(body.text("span.total-page"));
String img = body.attr("img#comic_pic","src");
list.add(new ImageUrl(0, img, false));

String str = StringUtils.match("var pl = \'(.*?)\'", html, 1);
// 得到 https://mh2.wan1979.com/upload/jiemoren/1989998/
String prevStr = str.substring(0, str.length() - 8);

// 得到 0000
int lastStr = Integer.parseInt(str.substring(str.length() - 8, str.length() - 4));
int pagNum = Integer.parseInt(StringUtils.match("var pcount=(.*?);", html, 1));

if (str != null) {
if (imgurl != null) {
try {
for (int i = lastStr; i < pagNum + lastStr; i++) {
String url = StringUtils.format("%s%04d.jpg", prevStr, i);
// https://mh2.wan1979.com/upload/jiemoren/1989998/0000.jpg
list.add(new ImageUrl(i + 1, url, false));
for (int i = 1; i < total; i++) {
String imghtml = "-"+i+".html";
String targetUrl = imgurl.replace(".html", imghtml);
String imhtml = getResponseBody(App.getHttpClient(), new Request.Builder().url(targetUrl).build());
Node body1 = new Node(imhtml);
String img1 = body1.attr("img#comic_pic","src");
list.add(new ImageUrl(i, img1, false));
}
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -151,22 +157,12 @@ public Request getCheckRequest(String cid) {
@Override
public String parseCheck(String html) {
// 这里表示的是更新时间
Node body = new Node(html);

String update = "";
List<Node> upDateAndAuth = body.list("div.detailForm > div > div > p");

if (upDateAndAuth.size() == 5) {
update = upDateAndAuth.get(3).text().substring(5).trim();
} else {
update = upDateAndAuth.get(2).text().substring(5).trim();
}
return update;
return new Node(html).text("time#updateTime");
}

@Override
public Headers getHeader() {
return Headers.of("Referer", "https://www.toho8.cn");
return Headers.of("Referer", "https://m.tuhaomh.com");
}

}
11 changes: 6 additions & 5 deletions app/src/main/java/com/hiroshi/cimoc/utils/DecryptionUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hiroshi.cimoc.utils;

import android.util.Base64;
import android.util.Log;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
Expand All @@ -17,6 +18,7 @@
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;


/**
* Created by Hiroshi on 2016/7/8.
*/
Expand All @@ -34,12 +36,11 @@ public static String desDecrypt(String keyString, String cipherString) throws Ex

// ref: https://jueyue.iteye.com/blog/1830792
public static String aesDecrypt(String value, String key, String ivs) throws Exception {
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES");
IvParameterSpec iv = new IvParameterSpec(ivs.getBytes());
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
IvParameterSpec iv = new IvParameterSpec(ivs.getBytes("UTF-8"));
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);

byte[] code = Base64.decode(value, Base64.NO_WRAP);
byte[] code = Base64.decode(value, Base64.DEFAULT);
return new String(cipher.doFinal(code));
}

Expand Down
Loading

0 comments on commit 52f380e

Please sign in to comment.