适配发现

pull/21/head
fengyuecanzhu 3 years ago
parent 7d17796e55
commit 4842b731a3
  1. 4
      app/src/main/java/xyz/fycz/myreader/entity/thirdsource/source3/ExploreKind3.kt
  2. 2
      app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookList.kt
  3. 8
      app/src/main/java/xyz/fycz/myreader/ui/activity/FindBookActivity.java
  4. 26
      app/src/main/java/xyz/fycz/myreader/webapi/Third3SourceApi.kt
  5. 4
      app/src/main/java/xyz/fycz/myreader/webapi/ThirdSourceApi.java
  6. 10
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/Third3FindCrawler.kt
  7. 7
      app/src/main/java/xyz/fycz/myreader/webapi/crawler/source/find/ThirdFindCrawler.java

@ -1,6 +1,6 @@
package xyz.fycz.myreader.entity.thirdsource
package xyz.fycz.myreader.entity.thirdsource.source3
data class ExploreKind(
data class ExploreKind3(
val title: String,
val url: String? = null,
val style: Style? = null

@ -58,7 +58,7 @@ object BookList {
var reverse = false
val bookListRule: BookListRule = when {
isSearch -> bookSource.searchRule
bookSource.findRule.url.isNullOrBlank() -> bookSource.searchRule
bookSource.findRule.list.isNullOrBlank() -> bookSource.searchRule
else -> bookSource.findRule
}
var ruleList: String = bookListRule.list ?: ""

@ -19,6 +19,7 @@ import xyz.fycz.myreader.R;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.base.observer.MyObserver;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityFindBookBinding;
import xyz.fycz.myreader.greendao.entity.rule.BookSource;
import xyz.fycz.myreader.ui.adapter.TabFragmentPageAdapter;
@ -27,6 +28,7 @@ import xyz.fycz.myreader.ui.fragment.FindBook1Fragment;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.util.utils.RxUtils;
import xyz.fycz.myreader.webapi.crawler.base.FindCrawler;
import xyz.fycz.myreader.webapi.crawler.source.find.Third3FindCrawler;
import xyz.fycz.myreader.webapi.crawler.source.find.ThirdFindCrawler;
/**
@ -60,7 +62,11 @@ public class FindBookActivity extends BaseActivity {
Object obj = BitIntentDataManager.getInstance().getData(getIntent());
if (obj instanceof BookSource) {
source = (BookSource) obj;
findCrawler = new ThirdFindCrawler(source);
if (APPCONST.THIRD_3_SOURCE.equals(source.getSourceType())) {
findCrawler = new Third3FindCrawler(source);
} else {
findCrawler = new ThirdFindCrawler(source);
}
} else if (obj instanceof FindCrawler) {
findCrawler = (FindCrawler) obj;
}

@ -10,6 +10,7 @@ import xyz.fycz.myreader.greendao.entity.Chapter
import xyz.fycz.myreader.model.mulvalmap.ConMVMap
import xyz.fycz.myreader.model.third3.webBook.WebBook
import xyz.fycz.myreader.webapi.crawler.source.Third3Crawler
import xyz.fycz.myreader.webapi.crawler.source.find.Third3FindCrawler
/**
* @author fengyue
@ -55,7 +56,7 @@ object Third3SourceApi : AndroidViewModel(App.getApplication()) {
}
}
fun getBookChaptersByT3C(book: Book, rc: Third3Crawler): Observable<List<Chapter>>{
fun getBookChaptersByT3C(book: Book, rc: Third3Crawler): Observable<List<Chapter>> {
return Observable.create { emitter ->
WebBook.getChapterList(
scope,
@ -71,7 +72,11 @@ object Third3SourceApi : AndroidViewModel(App.getApplication()) {
}
}
fun getChapterContentByT3C(chapter: Chapter, book: Book, rc: Third3Crawler): Observable<String>{
fun getChapterContentByT3C(
chapter: Chapter,
book: Book,
rc: Third3Crawler
): Observable<String> {
return Observable.create { emitter ->
WebBook.getContent(
scope,
@ -87,4 +92,21 @@ object Third3SourceApi : AndroidViewModel(App.getApplication()) {
}
}
}
fun findBook(url: String, fc: Third3FindCrawler, page: Int): Observable<List<Book>> {
return Observable.create { emitter ->
WebBook.exploreBook(
scope,
fc.source,
url,
page
).onSuccess {
emitter.onNext(it)
}.onError {
emitter.onError(it)
}.onFinally {
emitter.onComplete()
}
}
}
}

@ -25,6 +25,7 @@ import xyz.fycz.myreader.util.utils.OkHttpUtils;
import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler;
import xyz.fycz.myreader.webapi.crawler.source.Third3Crawler;
import xyz.fycz.myreader.webapi.crawler.source.ThirdCrawler;
import xyz.fycz.myreader.webapi.crawler.source.find.Third3FindCrawler;
import xyz.fycz.myreader.webapi.crawler.source.find.ThirdFindCrawler;
import static xyz.fycz.myreader.common.APPCONST.JS_PATTERN;
@ -165,6 +166,9 @@ public class ThirdSourceApi {
* 发现
*/
public static Observable<List<Book>> findBook(String url, ThirdFindCrawler fc, int page) {
if (fc instanceof Third3FindCrawler){
return Third3SourceApi.INSTANCE.findBook(url, (Third3FindCrawler) fc, page);
}
BookSource source = fc.getSource();
Map<String, String> headers = getCookies(fc.getTag());
BookList bookList = new BookList(source.getSourceUrl(), source.getSourceName(), source, true);

@ -0,0 +1,10 @@
package xyz.fycz.myreader.webapi.crawler.source.find
import xyz.fycz.myreader.greendao.entity.rule.BookSource
/**
* @author fengyue
* @date 2022/1/20 15:33
*/
class Third3FindCrawler(source: BookSource) : ThirdFindCrawler(source) {
}

@ -8,10 +8,9 @@ import java.util.List;
import javax.script.SimpleBindings;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import xyz.fycz.myreader.entity.FindKind;
import xyz.fycz.myreader.entity.StrResponse;
import xyz.fycz.myreader.entity.thirdsource.ExploreKind;
import xyz.fycz.myreader.entity.thirdsource.source3.ExploreKind3;
import xyz.fycz.myreader.greendao.entity.Book;
import xyz.fycz.myreader.greendao.entity.rule.BookSource;
import xyz.fycz.myreader.greendao.entity.rule.FindRule;
@ -57,9 +56,9 @@ public class ThirdFindCrawler extends BaseFindCrawler {
return Observable.create(emitter -> {
try {
if (StringUtils.isJsonArray(findRuleBean.getUrl())) {
List<ExploreKind> kinds = GsonUtils.parseJArray(findRuleBean.getUrl(), ExploreKind.class);
List<ExploreKind3> kinds = GsonUtils.parseJArray(findRuleBean.getUrl(), ExploreKind3.class);
StringBuilder sb = new StringBuilder();
for (ExploreKind kind : kinds){
for (ExploreKind3 kind : kinds){
String url = kind.getUrl() == null ? "" : kind.getUrl();
sb.append(kind.getTitle()).append("::").append(url).append("\n");
}

Loading…
Cancel
Save