Albirew/tachiyomi
Archivé
1
0
Bifurcation 0

Merge pull request #132 from icewind1991/batato-staff-notice

Show batoto staff notice if updating chapters failed
Cette révision appartient à :
inorichi 2016-02-11 23:32:32 +01:00
révision 01d6ddfafb
4 fichiers modifiés avec 20 ajouts et 4 suppressions

Voir le fichier

@ -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;
}
}

Voir le fichier

@ -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&section=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<>();

Voir le fichier

@ -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() {

Voir le fichier

@ -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,