X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FMangaFox.java;h=5dee0d6a9f95cd2bf4e420dbf9cec38bca3322fa;hb=727108fef9dcc661d45fa69ebf8b76f5128a2b6f;hp=f1226076315e844d6b55718fe26394bc556c1ae2;hpb=41c3bba7f6fc6f5ec1fa7fe35643c6aace94240d;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/MangaFox.java b/src/be/nikiroo/fanfix/supported/MangaFox.java index f122607..5dee0d6 100644 --- a/src/be/nikiroo/fanfix/supported/MangaFox.java +++ b/src/be/nikiroo/fanfix/supported/MangaFox.java @@ -28,11 +28,6 @@ class MangaFox extends BasicSupport { return true; } - @Override - public String getSourceName() { - return "MangaFox.me"; - } - @Override protected MetaData getMeta() throws IOException { MetaData meta = new MetaData(); @@ -63,9 +58,9 @@ class MangaFox extends BasicSupport { meta.setDate(StringUtils.unhtml(table.get(0).text()).trim()); meta.setTags(explode(table.get(3).text())); } - meta.setSource(getSourceName()); + meta.setSource(getType().getSourceName()); meta.setUrl(getSource().toString()); - meta.setPublisher(getSourceName()); + meta.setPublisher(getType().getSourceName()); meta.setUuid(getSource().toString()); meta.setLuid(""); meta.setLang("en"); @@ -106,7 +101,7 @@ class MangaFox extends BasicSupport { Element doc = getSourceNode(); Element title = doc.getElementsByClass("summary").first(); if (title != null) { - StringUtils.unhtml(title.text()).trim(); + return StringUtils.unhtml(title.text()).trim(); } return null; @@ -261,8 +256,13 @@ class MangaFox extends BasicSupport { // note: when used, the base URL can be an ad-page imageIn = openEx(url + "1.html"); imageDoc = DataUtil.load(imageIn, "UTF-8", url + "1.html"); + } catch (IOException e) { + Instance.getTraceHandler().error( + new IOException("Cannot get image " + 1 + " of manga", e)); } finally { - imageIn.close(); + if (imageIn != null) { + imageIn.close(); + } } Element select = imageDoc.getElementsByClass("m").first(); Elements options = select.getElementsByTag("option"); @@ -272,26 +272,33 @@ class MangaFox extends BasicSupport { // 2. list them for (int i = 1; i <= size; i++) { - if (i > 1) { // because fist one was opened for size + if (i > 1) { // because first one was opened for size try { imageIn = openEx(url + i + ".html"); imageDoc = DataUtil.load(imageIn, "UTF-8", url + i + ".html"); + + String linkImage = imageDoc.getElementById("image").absUrl( + "src"); + if (linkImage != null) { + builder.append("["); + // to help with the retry and the originalUrl, part 1 + builder.append(withoutQuery(linkImage)); + builder.append("]
"); + } + + // to help with the retry and the originalUrl, part 2 + refresh(linkImage); + } catch (IOException e) { + Instance.getTraceHandler().error( + new IOException("Cannot get image " + i + + " of manga", e)); } finally { - imageIn.close(); + if (imageIn != null) { + imageIn.close(); + } } } - - String linkImage = imageDoc.getElementById("image").absUrl("src"); - if (linkImage != null) { - builder.append("["); - // to help with the retry and the originalUrl, part 1 - builder.append(withoutQuery(linkImage)); - builder.append("]
"); - } - - // to help with the retry and the originalUrl, part 2 - refresh(linkImage); } return builder.toString();