X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FMangaFox.java;h=dae2d314f900d79a70c5d6237667d007a9a616dd;hb=12443642377be74159578c99af7a9883571e38bf;hp=f1226076315e844d6b55718fe26394bc556c1ae2;hpb=41c3bba7f6fc6f5ec1fa7fe35643c6aace94240d;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/MangaFox.java b/src/be/nikiroo/fanfix/supported/MangaFox.java index f122607..dae2d31 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(); @@ -329,8 +336,8 @@ class MangaFox extends BasicSupport { */ private InputStream openEx(String url) throws IOException { try { - return Instance.getCache().open(new URL(url), this, true, - withoutQuery(url)); + return Instance.getCache().open(new URL(url), withoutQuery(url), + this, true); } catch (Exception e) { // second chance try { @@ -338,8 +345,8 @@ class MangaFox extends BasicSupport { } catch (InterruptedException ee) { } - return Instance.getCache().open(new URL(url), this, true, - withoutQuery(url)); + return Instance.getCache().open(new URL(url), withoutQuery(url), + this, true); } }