Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Dec 9, 2018
1 parent a078629 commit 455f9b9
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions app/src/main/java/com/monke/monkeybook/model/content/BookInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,55 @@ Observable<BookShelfBean> analyzeBookInfo(String s, final BookShelfBean bookShel
if (bookInfoBean == null) {
bookInfoBean = new BookInfoBean();
}
String result;
bookInfoBean.setNoteUrl(bookShelfBean.getNoteUrl()); //id
bookInfoBean.setTag(tag);
if (!StringUtils.isJSONType(s)) {
Document doc = Jsoup.parse(s);
analyzeByXPath.parse(doc);
analyzeByJSoup.parse(doc, bookShelfBean.getNoteUrl());
if (isEmpty(bookInfoBean.getCoverUrl())) {
bookInfoBean.setCoverUrl(analyzeToString(bookSourceBean.getRuleCoverUrl(), bookShelfBean.getNoteUrl()));
result = analyzeToString(bookSourceBean.getRuleCoverUrl(), bookShelfBean.getNoteUrl());
if (!isEmpty(result)) {
bookInfoBean.setCoverUrl(result);
}
if (isEmpty(bookInfoBean.getName())) {
bookInfoBean.setName(analyzeToString(bookSourceBean.getRuleBookName()));
result = analyzeToString(bookSourceBean.getRuleBookName());
if (!isEmpty(result)) {
bookInfoBean.setName(result);
}
if (isEmpty(bookInfoBean.getAuthor())) {
bookInfoBean.setAuthor(FormatWebText.getAuthor(analyzeToString(bookSourceBean.getRuleBookAuthor())));
result = FormatWebText.getAuthor(analyzeToString(bookSourceBean.getRuleBookAuthor()));
if (!isEmpty(result)) {
bookInfoBean.setAuthor(result);
}
result = analyzeToString(bookSourceBean.getRuleIntroduce());
if (!isEmpty(result)) {
bookInfoBean.setIntroduce(result);
}
bookInfoBean.setIntroduce(analyzeToString(bookSourceBean.getRuleIntroduce()));
bookInfoBean.setChapterUrl(analyzeToString(bookSourceBean.getRuleChapterUrl(), bookShelfBean.getNoteUrl()));
if (isEmpty(bookInfoBean.getChapterUrl())) {
bookInfoBean.setChapterUrl(bookShelfBean.getNoteUrl());
}
} else {
analyzeByJSonPath.parse(s);
SourceRule sourceRule;
if (isEmpty(bookInfoBean.getCoverUrl())) {
sourceRule = new SourceRule(bookSourceBean.getRuleCoverUrl());
bookInfoBean.setCoverUrl(analyzeByJSonPath.read(sourceRule.rule));
sourceRule = new SourceRule(bookSourceBean.getRuleCoverUrl());
result = analyzeByJSonPath.read(sourceRule.rule);
if (!isEmpty(result)) {
bookInfoBean.setCoverUrl(result);
}
if (isEmpty(bookInfoBean.getName())) {
sourceRule = new SourceRule(bookSourceBean.getRuleBookName());
bookInfoBean.setCoverUrl(analyzeByJSonPath.read(sourceRule.rule));
sourceRule = new SourceRule(bookSourceBean.getRuleBookName());
result = analyzeByJSonPath.read(sourceRule.rule);
if (!isEmpty(result)) {
bookInfoBean.setName(result);
}
if (isEmpty(bookInfoBean.getAuthor())) {
sourceRule = new SourceRule(bookSourceBean.getRuleBookAuthor());
bookInfoBean.setCoverUrl(analyzeByJSonPath.read(sourceRule.rule));
sourceRule = new SourceRule(bookSourceBean.getRuleBookAuthor());
result = analyzeByJSonPath.read(sourceRule.rule);
if (!isEmpty(result)) {
bookInfoBean.setAuthor(result);
}
if (isEmpty(bookInfoBean.getIntroduce())) {
sourceRule = new SourceRule(bookSourceBean.getRuleIntroduce());
bookInfoBean.setCoverUrl(analyzeByJSonPath.read(sourceRule.rule));
sourceRule = new SourceRule(bookSourceBean.getRuleIntroduce());
result = analyzeByJSonPath.read(sourceRule.rule);
if (!isEmpty(result)) {
bookInfoBean.setIntroduce(result);
}
sourceRule = new SourceRule(bookSourceBean.getRuleChapterUrl());
bookInfoBean.setChapterUrl(analyzeByJSonPath.read(sourceRule.rule));
Expand Down

0 comments on commit 455f9b9

Please sign in to comment.