Skip to content

Commit

Permalink
Merge pull request #225 from zhongfly/CopyMH
Browse files Browse the repository at this point in the history
fix CopyMH
  • Loading branch information
Haleydu authored Apr 14, 2021
2 parents 410d3c8 + e5c24c0 commit b88bc00
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ public Request getSearchRequest(String keyword, int page) {
if (page == 1) {
// JChineseConvertor jChineseConvertor = JChineseConvertor.getInstance();
// keyword = jChineseConvertor.s2t(keyword);
url = StringUtils.format("https://copymanga.com/api/kb/web/search/count?offset=0&platform=2&limit=50&q=%s", keyword);
return new Request.Builder().url(url).build();
url = StringUtils.format("https://api.copymanga.com/api/v3/search/comic?platform=1&limit=30&offset=0&q=%s", keyword);
return new Request.Builder()
.url(url)
.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.build();
}
return null;
}
Expand All @@ -70,7 +73,7 @@ protected void initUrlFilterList() {
public SearchIterator getSearchIterator(String html, int page) throws JSONException {
try {
JSONObject jsonObject = new JSONObject(html);
return new JsonIterator(jsonObject.getJSONObject("results").getJSONObject("comic").getJSONArray("list")) {
return new JsonIterator(jsonObject.getJSONObject("results").getJSONArray("list")) {
@Override
protected Comic parse(JSONObject object) {
try {
Expand All @@ -95,7 +98,10 @@ protected Comic parse(JSONObject object) {
@Override
public Request getInfoRequest(String cid) {
String url = "https://api.copymanga.com/api/v3/comic2/".concat(cid);
return new Request.Builder().url(url).build();
return new Request.Builder()
.url(url)
.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.build();
}

@Override
Expand Down Expand Up @@ -127,7 +133,10 @@ public Comic parseInfo(String html, Comic comic) {
@Override
public Request getChapterRequest(String html, String cid) {
String url = String.format("https://api.copymanga.com/api/v3/comic/%s/group/default/chapters?limit=500&offset=0", cid);
return new Request.Builder().url(url).build();
return new Request.Builder()
.url(url)
.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.build();
}

@Override
Expand All @@ -149,7 +158,10 @@ public List<Chapter> parseChapter(String html, Comic comic, Long sourceComic) th
String path_word = groups.getJSONObject(key).getString("path_word");
String PathName = groups.getJSONObject(key).getString("name");
String url = String.format("https://api.copymanga.com/api/v3/comic/%s/group/%s/chapters?limit=500&offset=0", comic.getCid(), path_word);
Request request = new Request.Builder().url(url).build();
Request request = new Request.Builder()
.url(url)
.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.build();
html = getResponseBody(App.getHttpClient(), request);
jsonObject = new JSONObject(html);
array = jsonObject.getJSONObject("results").getJSONArray("list");
Expand All @@ -172,7 +184,10 @@ public List<Chapter> parseChapter(String html, Comic comic, Long sourceComic) th
@Override
public Request getImagesRequest(String cid, String path) {
String url = StringUtils.format("https://copymanga.com/comic/%s/chapter/%s", cid, path);
return new Request.Builder().url(url).build();
return new Request.Builder()
.url(url)
.addHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.build();
}

@Override
Expand Down

0 comments on commit b88bc00

Please sign in to comment.