();
- String tagLine = getKeyLine(in, "", 0);
- if (title != null) {
- title = StringUtils.unhtml(title).trim();
- if (title.endsWith(siteName)) {
- title = title.substring(0, title.length() - siteName.length())
- .trim();
- }
- }
-
- return title;
- }
-
- @Override
- protected String getDesc(URL source, InputStream in) throws IOException {
- String desc = null;
-
- String descLine = getKeyLine(in, "Uploader Comment", null,
- "> getChapters(URL source, InputStream in,
- Progress pg) throws IOException {
- List> urls = new ArrayList>();
- int last = 0; // no pool/show when only one page, first page == page 0
-
- @SuppressWarnings("resource")
- Scanner scan = new Scanner(in, "UTF-8");
- scan.useDelimiter(">");
- while (scan.hasNext()) {
- String line = scan.next();
- if (line.contains(source.toString())) {
- String page = line.substring(line.indexOf(source.toString()));
- String pkey = "?p=";
- if (page.contains(pkey)) {
- page = page.substring(page.indexOf(pkey) + pkey.length());
- String number = "";
- while (!page.isEmpty() && page.charAt(0) >= '0'
- && page.charAt(0) <= '9') {
- number += page.charAt(0);
- page = page.substring(1);
- }
- if (number.isEmpty()) {
- number = "0";
- }
-
- int current = Integer.parseInt(number);
- if (last < current) {
- last = current;
- }
- }
- }
- }
-
- for (int i = 0; i <= last; i++) {
- urls.add(new AbstractMap.SimpleEntry(Integer
- .toString(i + 1), new URL(source.toString() + "?p=" + i)));
- }
-
- return urls;
- }
-
- @Override
- protected String getChapterContent(URL source, InputStream in, int number,
- Progress pg) throws IOException {
- String staticSite = "https://e-hentai.org/s/";
- List pages = new ArrayList();
-
- @SuppressWarnings("resource")
- Scanner scan = new Scanner(in, "UTF-8");
- scan.useDelimiter("\"");
- while (scan.hasNext()) {
- String line = scan.next();
- if (line.startsWith(staticSite)) {
- try {
- pages.add(new URL(line));
- } catch (MalformedURLException e) {
- Instance.getTraceHandler().error(
- new IOException(
- "Parsing error, a link is not correctly parsed: "
- + line, e));
- }
- }
- }
-
- if (pg == null) {
- pg = new Progress();
- }
- pg.setMinMax(0, pages.size());
- pg.setProgress(0);
-
- StringBuilder builder = new StringBuilder();
-
- for (URL page : pages) {
- InputStream pageIn = Instance.getCache().open(page, this, false);
- try {
- String link = getKeyLine(pageIn, "id=\"img\"", "src=\"", "\"");
- if (link != null && !link.isEmpty()) {
- builder.append("[");
- builder.append(link);
- builder.append("]
");
- }
- pg.add(1);
- } finally {
- if (pageIn != null) {
- pageIn.close();
- }
- }
- }
-
- pg.done();
- return builder.toString();
- }
-}