From e86721d5acd5d69b036ab921b20fcfee5bed644e Mon Sep 17 00:00:00 2001 From: "rongdu.huang" Date: Mon, 20 Jul 2020 21:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0oh=E6=BC=AB=E7=94=BB=E6=BA=90?= =?UTF-8?q?[fixer]Haleydu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hiroshi/cimoc/helper/UpdateHelper.java | 1 + .../hiroshi/cimoc/manager/SourceManager.java | 3 + .../com/hiroshi/cimoc/source/Ohmanhua.java | 167 ++++++++++++++++++ .../cimoc/ui/activity/BrowserFilter.java | 2 + .../hiroshi/cimoc/utils/DecryptionUtils.java | 8 + 5 files changed, 181 insertions(+) create mode 100644 app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java diff --git a/app/src/main/java/com/hiroshi/cimoc/helper/UpdateHelper.java b/app/src/main/java/com/hiroshi/cimoc/helper/UpdateHelper.java index d3f6d256..23ed14dc 100644 --- a/app/src/main/java/com/hiroshi/cimoc/helper/UpdateHelper.java +++ b/app/src/main/java/com/hiroshi/cimoc/helper/UpdateHelper.java @@ -88,6 +88,7 @@ private static void initSource(DaoSession session) { list.add(GuFeng.getDefaultSource()); list.add(YYLS.getDefaultSource()); list.add(Comic18.getDefaultSource()); + list.add(Ohmanhua.getDefaultSource()); session.getSourceDao().insertOrReplaceInTx(list); } } diff --git a/app/src/main/java/com/hiroshi/cimoc/manager/SourceManager.java b/app/src/main/java/com/hiroshi/cimoc/manager/SourceManager.java index 20a49195..074d2386 100644 --- a/app/src/main/java/com/hiroshi/cimoc/manager/SourceManager.java +++ b/app/src/main/java/com/hiroshi/cimoc/manager/SourceManager.java @@ -181,6 +181,9 @@ public Parser getParser(int type) { case Comic18.TYPE: parser = new Comic18(source); break; + case Ohmanhua.TYPE: + parser = new Ohmanhua(source); + break; default: parser = new Null(); break; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java b/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java new file mode 100644 index 00000000..ec59eaf2 --- /dev/null +++ b/app/src/main/java/com/hiroshi/cimoc/source/Ohmanhua.java @@ -0,0 +1,167 @@ +package com.hiroshi.cimoc.source; + +import android.util.Base64; +import android.util.Log; +import android.util.Pair; + +import com.hiroshi.cimoc.model.Chapter; +import com.hiroshi.cimoc.model.Comic; +import com.hiroshi.cimoc.model.ImageUrl; +import com.hiroshi.cimoc.model.Source; +import com.hiroshi.cimoc.parser.MangaCategory; +import com.hiroshi.cimoc.parser.MangaParser; +import com.hiroshi.cimoc.parser.NodeIterator; +import com.hiroshi.cimoc.parser.SearchIterator; +import com.hiroshi.cimoc.parser.UrlFilter; +import com.hiroshi.cimoc.soup.Node; +import com.hiroshi.cimoc.ui.activity.ResultActivity; +import com.hiroshi.cimoc.utils.DecryptionUtils; +import com.hiroshi.cimoc.utils.LogUtil; +import com.hiroshi.cimoc.utils.StringUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import okhttp3.Headers; +import okhttp3.Request; + +import static com.hiroshi.cimoc.utils.DecryptionUtils.desDecrypt; + +/** + * Created by FEILONG on 2017/12/21. + */ + +public class Ohmanhua extends MangaParser { + + public static final int TYPE = 71; + public static final String DEFAULT_TITLE = "oh漫画"; + public static final String baseUrl = "https://www.ohmanhua.com"; + private static final String serverUrl = "https://img.ohmanhua.com/comic/"; + + public Ohmanhua(Source source) { + init(source, null); + } + + public static Source getDefaultSource() { + return new Source(null, DEFAULT_TITLE, TYPE, true); + } + + @Override + public Request getSearchRequest(String keyword, int page) throws UnsupportedEncodingException { + String url = ""; + if (page == 1) { + url = StringUtils.format(baseUrl+"/search?searchString=%s", keyword); + } + return new Request.Builder().url(url).build(); + } + + @Override + public SearchIterator getSearchIterator(String html, int page) { + Node body = new Node(html); + return new NodeIterator(body.list("dl.fed-deta-info")) { + @Override + protected Comic parse(Node node) { + String cid = node.href("dd > h1 > a"); + String title = node.text("dd > h1 > a"); + String cover = node.attr("dt > a", "data-original"); + String author = node.text("dd > ul > li:eq(3)").replace("作者",""); + String update = node.text("dd > ul > li:eq(4)").replace("更新",""); + //Log.d("getSearchIterator",cid + ","+title+ "," + cover + ","+author +","+update); + return new Comic(TYPE, cid, title, cover, update, author); + } + }; + } + + @Override + public String getUrl(String cid) { + return baseUrl+cid; + } + + @Override + protected void initUrlFilterList() { + filter.add(new UrlFilter(baseUrl)); + } + + @Override + public Request getInfoRequest(String cid) { + String url = baseUrl + cid; + return new Request.Builder().url(url).build(); + } + + @Override + public void parseInfo(String html, Comic comic) throws UnsupportedEncodingException { + 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"); + String update = body.text("dl.fed-deta-info > dd > ul > li:eq(2)").replace("更新",""); + String author = body.text("dl.fed-deta-info > dd > ul > li:eq(1) > a"); + String intro = body.text("div.fed-tabs-boxs > div > p"); + boolean status = isFinish(body.text("dl.fed-deta-info > dd > ul > li:eq(0) > a")); + //Log.d("parseInfo",status + ","+title+ "," + cover + ","+author +","+update + ","+intro); + comic.setInfo(title, cover, update, intro, author, status); + } + + @Override + public List parseChapter(String html) { + List list = new LinkedList<>(); + for (Node node : new Node(html).list("div:not(.fed-hidden) > div.all_data_list > ul.fed-part-rows a")) { + String title = node.attr("title"); + String path = node.href("a"); + //Log.d("parseChapter",title+","+path); + list.add(new Chapter(title, path)); + } + return list; + } + + @Override + public Request getImagesRequest(String cid, String path) { + String url = baseUrl + path; + return new Request.Builder().url(url).build(); + } + + @Override + public List parseImages(String html) { + //LogUtil.iLength("html",html); + List list = new LinkedList<>(); + String encodedData = StringUtils.match("C_DATA=\\'(.+?)\\'", html, 1); + if (encodedData != null) { + try { + String decryptKey = "JRUIFMVJDIWE569j"; + String decodedData = new String(Base64.decode(encodedData, Base64.DEFAULT)); + String decryptedData = DecryptionUtils.decryptAES(decodedData, decryptKey); + String imgRelativePath = StringUtils.match("imgpath:\"(.+?)\"",decryptedData,1); + String startImg = StringUtils.match("startimg:([0-9]+?),",decryptedData,1); + String totalPages = StringUtils.match("totalimg:([0-9]+?),",decryptedData,1); + for (int i = Integer.parseInt(startImg); i != Integer.parseInt(totalPages); ++i) { + String jpg = StringUtils.format("%04d.jpg", i); + //LogUtil.iLength("parseImages url",serverUrl + imgRelativePath + jpg); + list.add(new ImageUrl(i + 1, serverUrl + imgRelativePath + jpg, false)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return list; + } + + @Override + public Request getCheckRequest(String cid) { + return getInfoRequest(cid); + } + + @Override + public String parseCheck(String html) { + return new Node(html).text("dl.fed-deta-info > dd > ul > li:eq(2)").replace("更新",""); + } + + @Override + public Headers getHeader() { + return Headers.of("Referer", baseUrl); + } + + +} + diff --git a/app/src/main/java/com/hiroshi/cimoc/ui/activity/BrowserFilter.java b/app/src/main/java/com/hiroshi/cimoc/ui/activity/BrowserFilter.java index b069c2ea..6b32034d 100644 --- a/app/src/main/java/com/hiroshi/cimoc/ui/activity/BrowserFilter.java +++ b/app/src/main/java/com/hiroshi/cimoc/ui/activity/BrowserFilter.java @@ -27,6 +27,7 @@ import com.hiroshi.cimoc.source.Tencent; import com.hiroshi.cimoc.source.TuHao; import com.hiroshi.cimoc.source.U17; +import com.hiroshi.cimoc.source.Ohmanhua; import java.util.ArrayList; import java.util.List; @@ -80,6 +81,7 @@ private List registUrlListener() { list.add(ManHuaDB.TYPE); list.add(TuHao.TYPE); list.add(Comic18.TYPE); + list.add(Ohmanhua.TYPE); return list; } diff --git a/app/src/main/java/com/hiroshi/cimoc/utils/DecryptionUtils.java b/app/src/main/java/com/hiroshi/cimoc/utils/DecryptionUtils.java index 785f3366..fc954b9f 100644 --- a/app/src/main/java/com/hiroshi/cimoc/utils/DecryptionUtils.java +++ b/app/src/main/java/com/hiroshi/cimoc/utils/DecryptionUtils.java @@ -24,6 +24,14 @@ */ public class DecryptionUtils { + public static String decryptAES(String value, String key) throws Exception { + SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, secretKey); + byte[] code = Base64.decode(value, Base64.NO_WRAP); + return new String(cipher.doFinal(code)); + } + public static String desDecrypt(String keyString, String cipherString) throws Exception { byte[] cipherBytes = Base64.decode(cipherString, Base64.DEFAULT); DESKeySpec keySpec = new DESKeySpec(keyString.getBytes());