mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 16:09:16 +01:00
Strip html tags from batoto notice and directly throw an exception
This commit is contained in:
parent
01d6ddfafb
commit
56a45f263e
@ -34,8 +34,6 @@ public abstract class Source extends BaseSource {
|
||||
protected Headers requestHeaders;
|
||||
protected LazyHeaders glideHeaders;
|
||||
|
||||
protected String lastError;
|
||||
|
||||
public Source() {}
|
||||
|
||||
public Source(Context context) {
|
||||
@ -90,7 +88,7 @@ public abstract class Source extends BaseSource {
|
||||
List<Chapter> chapters = parseHtmlToChapters(unparsedHtml);
|
||||
return !chapters.isEmpty() ?
|
||||
Observable.just(chapters) :
|
||||
Observable.error(new Exception((getLastError().equals("")) ? "No chapters found" : getLastError()));
|
||||
Observable.error(new Exception("No chapters found"));
|
||||
});
|
||||
}
|
||||
|
||||
@ -218,7 +216,4 @@ public abstract class Source extends BaseSource {
|
||||
return glideHeaders;
|
||||
}
|
||||
|
||||
public String getLastError() {
|
||||
return lastError;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.source.online.english;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
@ -24,7 +25,6 @@ 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;
|
||||
@ -32,7 +32,6 @@ 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;
|
||||
@ -49,7 +48,7 @@ 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);
|
||||
public static final Pattern staffNotice = Pattern.compile("=+Batoto Staff Notice=+([^=]+)==+", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private Pattern datePattern;
|
||||
private Map<String, Integer> dateFields;
|
||||
@ -210,9 +209,8 @@ public class Batoto extends LoginSource {
|
||||
protected List<Chapter> parseHtmlToChapters(String unparsedHtml) {
|
||||
Matcher matcher = staffNotice.matcher(unparsedHtml);
|
||||
if (matcher.find()) {
|
||||
this.lastError = matcher.group(1);
|
||||
} else {
|
||||
lastError = "";
|
||||
String notice = Html.fromHtml(matcher.group(1)).toString().trim();
|
||||
throw new RuntimeException(notice);
|
||||
}
|
||||
|
||||
Document parsedDocument = Jsoup.parse(unparsedHtml);
|
||||
@ -245,6 +243,7 @@ public class Batoto extends LoginSource {
|
||||
return chapter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("WrongConstant")
|
||||
private long parseDateFromElement(Element dateElement) {
|
||||
String dateAsString = dateElement.text();
|
||||
|
||||
@ -260,7 +259,6 @@ public class Batoto extends LoginSource {
|
||||
String unit = m.group(2);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
// Not an error
|
||||
cal.add(dateFields.get(unit), -amount);
|
||||
date = cal.getTime();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user