- @Override
- protected String getChapterContent(URL source, InputStream in, int number,
- Progress pg) throws IOException {
- StringBuilder builder = new StringBuilder();
- String staticSite = "https://static1.e621.net";
- if (source.getHost().contains("e926")) {
- staticSite = staticSite.replace("e621", "e926");
- }
-
- String key = staticSite + "/data/preview/";
-
- @SuppressWarnings("resource")
- Scanner scan = new Scanner(in, "UTF-8");
- scan.useDelimiter("\\n");
- while (scan.hasNext()) {
- String line = scan.next();
- if (line.contains("class=\"preview")) {
- for (int pos = line.indexOf(key); pos >= 0; pos = line.indexOf(
- key, pos + key.length())) {
- int endPos = line.indexOf("\"", pos);
- if (endPos >= 0) {
- String id = line.substring(pos + key.length(), endPos);
- id = staticSite + "/data/" + id;
-
- int dotPos = id.lastIndexOf(".");
- if (dotPos >= 0) {
- id = id.substring(0, dotPos);
- builder.append("[");
- builder.append(id);
- builder.append("]<br/>");
- }
- }
- }
+ private Image getCover() throws IOException {
+ Image image = null;
+ List<Entry<String, URL>> chapters = getChapters(null);
+ if (!chapters.isEmpty()) {
+ URL chap1Url = chapters.get(0).getValue();
+ String imgsChap1 = getChapterContent(chap1Url, 1, null);
+ if (!imgsChap1.isEmpty()) {
+ imgsChap1 = imgsChap1.split("]")[0].substring(1).trim();
+ image = bsImages.getImage(this, new URL(imgsChap1));