update chaps
This commit is contained in:
parent
324d44ca83
commit
96f8998920
|
@ -289,9 +289,9 @@ public class BookUtil {
|
|||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "changing Source: to get site rule");
|
||||
|
||||
|
||||
Log.d(TAG, "to get chaps............................>");
|
||||
Log.d(TAG, "to get chaps siteRule:" +result);
|
||||
Log.d(TAG, "to get chaps mulu:" + mSite.getMuluUrl() );
|
||||
String[] chaps = new String[0];
|
||||
try {
|
||||
JSONObject siteJson = new JSONObject(result);
|
||||
|
@ -300,7 +300,7 @@ public class BookUtil {
|
|||
|
||||
if (chaps != null)
|
||||
for (String s : chaps) {
|
||||
Log.d(TAG, "prepare book readChaptersAsync: chapt: " + s);
|
||||
Log.d(TAG, "prepare book to get chaps readChaptersAsync: chapt: " + s);
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
|
|
|
@ -137,49 +137,69 @@ public class NovelParseUtil {
|
|||
JSONArray muluArray = siteJson.getJSONArray("chapterUrlRegexOnMulu");
|
||||
if (muluArray == null || muluArray.length()== 0) return null;
|
||||
|
||||
Log.d(TAG, "to get chaps muluArray is null: " +( muluArray ==null) );
|
||||
|
||||
Map<String, Object> context = new HashMap<String, Object>();
|
||||
context.put("url", url);
|
||||
Log.d(TAG, "to get chaps url:" + url );
|
||||
List<String> result = new ArrayList<String>();
|
||||
// 最外部的大的规则对象
|
||||
for (int i = 0; i < muluArray.length(); i++) {
|
||||
|
||||
JSONObject regexsJson = muluArray.getJSONObject(i);
|
||||
String source = regexsJson.getString("source");
|
||||
source = getContent(source, context);
|
||||
Log.d(TAG, "to get chaps source:" + source );
|
||||
if (source.startsWith("html:")) {
|
||||
String _url = source.substring("html:".length());
|
||||
source = access(_url);
|
||||
Log.d(TAG, "to get chaps source:" + source );
|
||||
}
|
||||
|
||||
// 第一次Regex对象
|
||||
JSONArray regexsArray = regexsJson.getJSONArray("regexs");
|
||||
Log.d(TAG, "to get chaps regexsArray.length():" + regexsArray.length() );
|
||||
for (int j = 0; j < regexsArray.length(); j++) {
|
||||
JSONObject regexJson = regexsArray.getJSONObject(j);
|
||||
String[] values = null;
|
||||
Log.d(TAG, "to get chaps regexJson.getBoolean(\"group\"):" + regexJson.getBoolean("group") );
|
||||
if (regexJson.getBoolean("group")) {
|
||||
values = REUtil.groups(regexJson.getString("regex"), source);
|
||||
} else {
|
||||
values = REUtil.matchs(regexJson.getString("regex"), source);
|
||||
}
|
||||
Log.d(TAG, "to get chaps values==null? :" + (values==null) );
|
||||
for(String s:values){
|
||||
Log.d(TAG, "to get chaps value :" + s);
|
||||
}
|
||||
if (values != null) context.put(regexJson.getString("name"), values);
|
||||
|
||||
// String child = siteJson.getString("child");
|
||||
|
||||
if ( siteJson.has("child") ) {
|
||||
// String child = siteJson.getString("child");
|
||||
Log.d(TAG, "to get chaps siteJson.has(\"child\")? :" + siteJson.has("child"));
|
||||
if ( regexJson.has("child") ) {
|
||||
// 一般用来做返回结果用的
|
||||
JSONObject childJson = regexJson.getJSONObject("child");
|
||||
Log.d(TAG, "to get chaps childJson :" + childJson.toString());
|
||||
for (String value : values) {
|
||||
Log.d(TAG, "to get chaps value in values :" + value);
|
||||
String[] values2 = null;
|
||||
Log.d(TAG, "to get chaps childJson.getBoolean(\"group\") :" + childJson.getBoolean("group"));
|
||||
if (childJson.getBoolean("group")) {
|
||||
values2 = REUtil.groups(childJson.getString("regex"), value);
|
||||
} else {
|
||||
values2 = REUtil.matchs(childJson.getString("regex"), value);
|
||||
}
|
||||
if (values != null) {
|
||||
Log.d(TAG, "to get chaps values2 != null ? :" + (values2 != null));
|
||||
if (values2 != null) {
|
||||
Log.d(TAG, "to get chaps value in values2 :" + value);
|
||||
context.put(childJson.getString("name"), values2);
|
||||
if (siteJson.has("output")) {
|
||||
Log.d(TAG, "to get chaps siteJson.has(\"output\") :" + siteJson.has("output"));
|
||||
if (childJson.has("output")) {
|
||||
JSONArray outputArray = childJson.getJSONArray("output");
|
||||
for (int m = 0; m < outputArray.length(); m++) {
|
||||
String v = getContent(outputArray.getString(m), context);
|
||||
Log.d(TAG, "to get chaps v :" + v);
|
||||
if (v != null) result.add(v);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +208,7 @@ public class NovelParseUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.d(TAG, "to get chaps <---------------------------- result size :" + result.size());
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
@ -237,7 +257,8 @@ public class NovelParseUtil {
|
|||
try {
|
||||
Response response = HttpMethods.getOkClient().newCall(request).execute();
|
||||
String s =response.body().string();
|
||||
Log.d(TAG, "prepare book access: " +s);
|
||||
|
||||
Log.d(TAG, "to get chaps access result:" + s );
|
||||
return s;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue