X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FFanfiction.java;h=282192e065bb82fd238c06b863d0e9a3647f4917;hb=d66deb8d8b30cff6b54db352eef34a3508939f84;hp=4193fa01e92eca1acc4f572ea3efb20eb4386ae8;hpb=276f95c6ca9a79d2fc6879877b240cefb4ceb598;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/Fanfiction.java b/src/be/nikiroo/fanfix/supported/Fanfiction.java index 4193fa0..282192e 100644 --- a/src/be/nikiroo/fanfix/supported/Fanfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fanfiction.java @@ -5,6 +5,7 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.text.SimpleDateFormat; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -31,11 +32,6 @@ class Fanfiction extends BasicSupport_Deprecated { return true; } - @Override - public String getSourceName() { - return "Fanfiction.net"; - } - @Override protected MetaData getMeta(URL source, InputStream in) throws IOException { MetaData meta = new MetaData(); @@ -44,12 +40,12 @@ class Fanfiction extends BasicSupport_Deprecated { meta.setAuthor(getAuthor(reset(in))); meta.setDate(getDate(reset(in))); meta.setTags(getTags(reset(in))); - meta.setSource(getSourceName()); + meta.setSource(getType().getSourceName()); meta.setUrl(source.toString()); - meta.setPublisher(getSourceName()); + meta.setPublisher(getType().getSourceName()); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang("en"); //TODO! + meta.setLang("en"); // TODO! meta.setSubject(getSubject(reset(in))); meta.setType(getType().toString()); meta.setImageDocument(false); @@ -122,7 +118,7 @@ class Fanfiction extends BasicSupport_Deprecated { } } - return null; + return ""; } private String getAuthor(InputStream in) { @@ -142,7 +138,7 @@ class Fanfiction extends BasicSupport_Deprecated { } } - return BasicSupportHelper.fixAuthor(author); + return bsHelper.fixAuthor(author); } private String getDate(InputStream in) { @@ -157,14 +153,12 @@ class Fanfiction extends BasicSupport_Deprecated { line = line.substring(0, pos).trim(); try { SimpleDateFormat sdf = new SimpleDateFormat( - "YYYY-MM-dd"); + "yyyy-MM-dd"); return sdf .format(new Date(1000 * Long.parseLong(line))); } catch (NumberFormatException e) { - Instance.getTraceHandler().error( - new IOException( - "Cannot convert publication date: " - + line, e)); + Instance.getInstance().getTraceHandler() + .error(new IOException("Cannot convert publication date: " + line, e)); } } } @@ -244,30 +238,11 @@ class Fanfiction extends BasicSupport_Deprecated { } try { - final String chapName = name.trim(); - final URL chapURL = new URL(base + i + suffix); - urls.add(new Entry() { - @Override - public URL setValue(URL value) { - return null; - } - - @Override - public URL getValue() { - return chapURL; - } - - @Override - public String getKey() { - return chapName; - } - }); + urls.add(new AbstractMap.SimpleEntry( + name.trim(), new URL(base + i + suffix))); } catch (MalformedURLException e) { - Instance.getTraceHandler() - .error(new IOException( - "Cannot parse chapter " + i - + " url: " - + (base + i + suffix), e)); + Instance.getInstance().getTraceHandler().error( + new IOException("Cannot parse chapter " + i + " url: " + (base + i + suffix), e)); } } } @@ -324,10 +299,9 @@ class Fanfiction extends BasicSupport_Deprecated { int pos = line.indexOf("= 0) { boolean chaptered = false; - for (String lang : Instance.getConfig() - .getString(Config.CHAPTER).split(",")) { - String chapterWord = Instance.getConfig() - .getStringX(Config.CHAPTER, lang); + for (String lang : Instance.getInstance().getConfig().getList(Config.CONF_CHAPTER)) { + String chapterWord = Instance.getInstance().getConfig().getStringX(Config.CONF_CHAPTER, + lang); int posChap = line.indexOf(chapterWord + " "); if (posChap < pos) { chaptered = true;