X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FFimfictionApi.java;h=c97ecf7d3e9ea2ff8a7cc782eea5bca660f9f265;hb=9a098d45a555e5d660c41e04f64e9445420cc025;hp=f31f8566e2460b581dfaf78d2ee7509b2eb6a542;hpb=6dd591f08aa6130391dd47ec60db5ae046c1e505;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/FimfictionApi.java b/src/be/nikiroo/fanfix/supported/FimfictionApi.java index f31f856..c97ecf7 100644 --- a/src/be/nikiroo/fanfix/supported/FimfictionApi.java +++ b/src/be/nikiroo/fanfix/supported/FimfictionApi.java @@ -84,11 +84,6 @@ class FimfictionApi extends BasicSupport { return true; } - @Override - public String getSourceName() { - return "FimFiction.net"; - } - /** * Extract the full JSON data we will later use to build the {@link Story}. * @@ -137,9 +132,9 @@ class FimfictionApi extends BasicSupport { meta.setAuthor(getKeyJson(json, 0, "type", "user", "name")); meta.setDate(getKeyJson(json, 0, "type", "story", "date_published")); meta.setTags(getTags()); - 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"); @@ -150,13 +145,22 @@ class FimfictionApi extends BasicSupport { String coverImageLink = getKeyJson(json, 0, "type", "story", "cover_image", "full"); if (!coverImageLink.trim().isEmpty()) { - InputStream in = null; + URL coverImageUrl = new URL(coverImageLink.trim()); + + // No need to use the oauth, cookies... for the cover + // Plus: it crashes on Android because of the referer try { - URL coverImageUrl = new URL(coverImageLink.trim()); - in = Instance.getCache().open(coverImageUrl, this, true); - meta.setCover(new Image(in)); - } finally { - in.close(); + InputStream in = Instance.getCache().open(coverImageUrl, null, + true); + try { + meta.setCover(new Image(in)); + } finally { + in.close(); + } + } catch (IOException e) { + Instance.getTraceHandler().error( + new IOException( + "Cannot get the story cover, ignoring...", e)); } } @@ -212,7 +216,7 @@ class FimfictionApi extends BasicSupport { List> urls = new ArrayList>(); for (String title : chapterNames.values()) { - urls.add(new AbstractMap.SimpleEntry(title, null)); + urls.add(new AbstractMap.SimpleEntry(title, null)); } return urls;