mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 14:09:17 +01:00
Search mangas from source (unusable yet)
This commit is contained in:
parent
66ab8caf76
commit
0278531e51
@ -75,7 +75,13 @@ public class CatalogueListPresenter extends BasePresenter {
|
|||||||
public void getMangasFromSearch(int page) {
|
public void getMangasFromSearch(int page) {
|
||||||
subscriptions.remove(mMangaSearchSubscription);
|
subscriptions.remove(mMangaSearchSubscription);
|
||||||
|
|
||||||
// TODO fetch mangas from source
|
mMangaSearchSubscription = selectedSource.searchMangasFromNetwork(mSearchName, page)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.flatMap(Observable::from)
|
||||||
|
.map(this::networkToLocalManga)
|
||||||
|
.toList()
|
||||||
|
.subscribe(adapter::setItems);
|
||||||
|
|
||||||
subscriptions.add(mMangaSearchSubscription);
|
subscriptions.add(mMangaSearchSubscription);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ public class Batoto extends Source {
|
|||||||
public static final String BASE_URL = "www.bato.to";
|
public static final String BASE_URL = "www.bato.to";
|
||||||
public static final String INITIAL_UPDATE_URL =
|
public static final String INITIAL_UPDATE_URL =
|
||||||
"http://bato.to/search_ajax?order_cond=views&order=desc&p=";
|
"http://bato.to/search_ajax?order_cond=views&order=desc&p=";
|
||||||
|
public static final String INITIAL_SEARCH_URL = "http://bato.to/search_ajax?";
|
||||||
|
|
||||||
|
|
||||||
public Batoto(NetworkHelper networkService, CacheManager cacheManager) {
|
public Batoto(NetworkHelper networkService, CacheManager cacheManager) {
|
||||||
super(networkService, cacheManager);
|
super(networkService, cacheManager);
|
||||||
@ -99,14 +101,18 @@ public class Batoto extends Source {
|
|||||||
return INITIAL_UPDATE_URL + page;
|
return INITIAL_UPDATE_URL + page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getSearchUrl(String query, int page) {
|
||||||
|
return INITIAL_SEARCH_URL + "name=" + query + "&p=" + page;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getMangaUrl(String defaultMangaUrl) {
|
protected String getMangaUrl(String defaultMangaUrl) {
|
||||||
String mangaId = defaultMangaUrl.substring(defaultMangaUrl.lastIndexOf("r") + 1);
|
String mangaId = defaultMangaUrl.substring(defaultMangaUrl.lastIndexOf("r") + 1);
|
||||||
return "http://bato.to/comic_pop?id=" + mangaId;
|
return "http://bato.to/comic_pop?id=" + mangaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private List<Manga> parseMangasFromHtml(String unparsedHtml) {
|
||||||
public List<Manga> parsePopularMangasFromHtml(String unparsedHtml) {
|
|
||||||
Document parsedDocument = Jsoup.parse(unparsedHtml);
|
Document parsedDocument = Jsoup.parse(unparsedHtml);
|
||||||
|
|
||||||
List<Manga> updatedMangaList = new ArrayList<>();
|
List<Manga> updatedMangaList = new ArrayList<>();
|
||||||
@ -121,6 +127,16 @@ public class Batoto extends Source {
|
|||||||
return updatedMangaList;
|
return updatedMangaList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Manga> parsePopularMangasFromHtml(String unparsedHtml) {
|
||||||
|
return parseMangasFromHtml(unparsedHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Manga> parseSearchFromHtml(String unparsedHtml) {
|
||||||
|
return parseMangasFromHtml(unparsedHtml);
|
||||||
|
}
|
||||||
|
|
||||||
private Manga constructMangaFromHtmlBlock(Element htmlBlock) {
|
private Manga constructMangaFromHtmlBlock(Element htmlBlock) {
|
||||||
Manga mangaFromHtmlBlock = new Manga();
|
Manga mangaFromHtmlBlock = new Manga();
|
||||||
|
|
||||||
|
@ -40,6 +40,12 @@ public abstract class Source {
|
|||||||
.flatMap(response -> Observable.just(parsePopularMangasFromHtml(response)));
|
.flatMap(response -> Observable.just(parsePopularMangasFromHtml(response)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Observable<List<Manga>> searchMangasFromNetwork(String query, int page) {
|
||||||
|
return mNetworkService
|
||||||
|
.getStringResponse(getSearchUrl(query, page), mNetworkService.NULL_CACHE_CONTROL, mRequestHeaders)
|
||||||
|
.flatMap(response -> Observable.just(parseSearchFromHtml(response)));
|
||||||
|
}
|
||||||
|
|
||||||
// Get manga details from the source
|
// Get manga details from the source
|
||||||
public Observable<Manga> pullMangaFromNetwork(final String mangaUrl) {
|
public Observable<Manga> pullMangaFromNetwork(final String mangaUrl) {
|
||||||
return mNetworkService
|
return mNetworkService
|
||||||
@ -98,7 +104,9 @@ public abstract class Source {
|
|||||||
public abstract int getSource();
|
public abstract int getSource();
|
||||||
|
|
||||||
protected abstract String getUrlFromPageNumber(int page);
|
protected abstract String getUrlFromPageNumber(int page);
|
||||||
|
protected abstract String getSearchUrl(String query, int page);
|
||||||
protected abstract List<Manga> parsePopularMangasFromHtml(String unparsedHtml);
|
protected abstract List<Manga> parsePopularMangasFromHtml(String unparsedHtml);
|
||||||
|
protected abstract List<Manga> parseSearchFromHtml(String unparsedHtml);
|
||||||
protected abstract Manga parseHtmlToManga(String mangaUrl, String unparsedHtml);
|
protected abstract Manga parseHtmlToManga(String mangaUrl, String unparsedHtml);
|
||||||
protected abstract List<Chapter> parseHtmlToChapters(String unparsedHtml);
|
protected abstract List<Chapter> parseHtmlToChapters(String unparsedHtml);
|
||||||
protected abstract List<String> parseHtmlToPageUrls(String unparsedHtml);
|
protected abstract List<String> parseHtmlToPageUrls(String unparsedHtml);
|
||||||
|
Loading…
Reference in New Issue
Block a user