mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 01:21:52 +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 Headers requestHeaders;
|
||||||
protected LazyHeaders glideHeaders;
|
protected LazyHeaders glideHeaders;
|
||||||
|
|
||||||
protected String lastError;
|
|
||||||
|
|
||||||
public Source() {}
|
public Source() {}
|
||||||
|
|
||||||
public Source(Context context) {
|
public Source(Context context) {
|
||||||
@ -90,7 +88,7 @@ public abstract class Source extends BaseSource {
|
|||||||
List<Chapter> chapters = parseHtmlToChapters(unparsedHtml);
|
List<Chapter> chapters = parseHtmlToChapters(unparsedHtml);
|
||||||
return !chapters.isEmpty() ?
|
return !chapters.isEmpty() ?
|
||||||
Observable.just(chapters) :
|
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;
|
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.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
@ -24,7 +25,6 @@ import java.util.Map;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
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.Chapter;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||||
import eu.kanade.tachiyomi.data.source.SourceManager;
|
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.MangasPage;
|
||||||
import eu.kanade.tachiyomi.data.source.model.Page;
|
import eu.kanade.tachiyomi.data.source.model.Page;
|
||||||
import eu.kanade.tachiyomi.util.Parser;
|
import eu.kanade.tachiyomi.util.Parser;
|
||||||
import eu.kanade.tachiyomi.util.ToastUtil;
|
|
||||||
import okhttp3.FormBody;
|
import okhttp3.FormBody;
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import okhttp3.Response;
|
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 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 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 Pattern datePattern;
|
||||||
private Map<String, Integer> dateFields;
|
private Map<String, Integer> dateFields;
|
||||||
@ -210,9 +209,8 @@ public class Batoto extends LoginSource {
|
|||||||
protected List<Chapter> parseHtmlToChapters(String unparsedHtml) {
|
protected List<Chapter> parseHtmlToChapters(String unparsedHtml) {
|
||||||
Matcher matcher = staffNotice.matcher(unparsedHtml);
|
Matcher matcher = staffNotice.matcher(unparsedHtml);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
this.lastError = matcher.group(1);
|
String notice = Html.fromHtml(matcher.group(1)).toString().trim();
|
||||||
} else {
|
throw new RuntimeException(notice);
|
||||||
lastError = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Document parsedDocument = Jsoup.parse(unparsedHtml);
|
Document parsedDocument = Jsoup.parse(unparsedHtml);
|
||||||
@ -245,6 +243,7 @@ public class Batoto extends LoginSource {
|
|||||||
return chapter;
|
return chapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WrongConstant")
|
||||||
private long parseDateFromElement(Element dateElement) {
|
private long parseDateFromElement(Element dateElement) {
|
||||||
String dateAsString = dateElement.text();
|
String dateAsString = dateElement.text();
|
||||||
|
|
||||||
@ -260,7 +259,6 @@ public class Batoto extends LoginSource {
|
|||||||
String unit = m.group(2);
|
String unit = m.group(2);
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
// Not an error
|
|
||||||
cal.add(dateFields.get(unit), -amount);
|
cal.add(dateFields.get(unit), -amount);
|
||||||
date = cal.getTime();
|
date = cal.getTime();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user