mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 01:48:24 +01:00
Show batoto staff notice if updating chapters failed
This commit is contained in:
parent
cb3c3af865
commit
393b4916f6
@ -34,6 +34,8 @@ public abstract class Source extends BaseSource {
|
||||
protected Headers requestHeaders;
|
||||
protected LazyHeaders glideHeaders;
|
||||
|
||||
protected String lastError;
|
||||
|
||||
public Source() {}
|
||||
|
||||
public Source(Context context) {
|
||||
@ -88,7 +90,7 @@ public abstract class Source extends BaseSource {
|
||||
List<Chapter> chapters = parseHtmlToChapters(unparsedHtml);
|
||||
return !chapters.isEmpty() ?
|
||||
Observable.just(chapters) :
|
||||
Observable.error(new Exception("No chapters found"));
|
||||
Observable.error(new Exception((getLastError().equals("")) ? "No chapters found" : getLastError()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -216,4 +218,7 @@ public abstract class Source extends BaseSource {
|
||||
return glideHeaders;
|
||||
}
|
||||
|
||||
public String getLastError() {
|
||||
return lastError;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.kanade.tachiyomi.R;
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||
import eu.kanade.tachiyomi.data.source.SourceManager;
|
||||
@ -31,6 +32,7 @@ import eu.kanade.tachiyomi.data.source.base.LoginSource;
|
||||
import eu.kanade.tachiyomi.data.source.model.MangasPage;
|
||||
import eu.kanade.tachiyomi.data.source.model.Page;
|
||||
import eu.kanade.tachiyomi.util.Parser;
|
||||
import eu.kanade.tachiyomi.util.ToastUtil;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Response;
|
||||
@ -47,6 +49,8 @@ public class Batoto extends LoginSource {
|
||||
public static final String MANGA_URL = "/comic_pop?id=%s";
|
||||
public static final String LOGIN_URL = BASE_URL + "/forums/index.php?app=core&module=global§ion=login";
|
||||
|
||||
public static final Pattern staffNotice = Pattern.compile("=+Batoto Staff Notice=+([^=]+)=+", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private Pattern datePattern;
|
||||
private Map<String, Integer> dateFields;
|
||||
|
||||
@ -204,6 +208,13 @@ public class Batoto extends LoginSource {
|
||||
|
||||
@Override
|
||||
protected List<Chapter> parseHtmlToChapters(String unparsedHtml) {
|
||||
Matcher matcher = staffNotice.matcher(unparsedHtml);
|
||||
if (matcher.find()) {
|
||||
this.lastError = matcher.group(1);
|
||||
} else {
|
||||
lastError = "";
|
||||
}
|
||||
|
||||
Document parsedDocument = Jsoup.parse(unparsedHtml);
|
||||
|
||||
List<Chapter> chapterList = new ArrayList<>();
|
||||
|
@ -161,9 +161,9 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
||||
swipeRefresh.setRefreshing(false);
|
||||
}
|
||||
|
||||
public void onFetchChaptersError() {
|
||||
public void onFetchChaptersError(Throwable error) {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ToastUtil.showShort(getContext(), R.string.fetch_chapters_error);
|
||||
ToastUtil.showShort(getContext(), error.getMessage());
|
||||
}
|
||||
|
||||
public boolean isCatalogueManga() {
|
||||
|
@ -67,7 +67,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||
startableFirst(FETCH_CHAPTERS,
|
||||
this::getOnlineChaptersObs,
|
||||
(view, result) -> view.onFetchChaptersDone(),
|
||||
(view, error) -> view.onFetchChaptersError());
|
||||
(view, error) -> view.onFetchChaptersError(error));
|
||||
|
||||
startableLatestCache(CHAPTER_STATUS_CHANGES,
|
||||
this::getChapterStatusObs,
|
||||
|
Loading…
Reference in New Issue
Block a user