Instance: use getInstance()
[nikiroo-utils.git] / src / be / nikiroo / fanfix / supported / Fanfiction.java
index 9b749bc6753e1efc92c2ffb48d1d6a83f1981b1e..282192e065bb82fd238c06b863d0e9a3647f4917 100644 (file)
@@ -32,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();
@@ -45,9 +40,9 @@ 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!
@@ -123,7 +118,7 @@ class Fanfiction extends BasicSupport_Deprecated {
                        }
                }
 
-               return null;
+               return "";
        }
 
        private String getAuthor(InputStream in) {
@@ -143,7 +138,7 @@ class Fanfiction extends BasicSupport_Deprecated {
                        }
                }
 
-               return BasicSupportHelper.fixAuthor(author);
+               return bsHelper.fixAuthor(author);
        }
 
        private String getDate(InputStream in) {
@@ -158,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));
                                        }
                                }
                        }
@@ -248,11 +241,8 @@ class Fanfiction extends BasicSupport_Deprecated {
                                                        urls.add(new AbstractMap.SimpleEntry<String, URL>(
                                                                        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));
                                                }
                                        }
                                }
@@ -309,10 +299,9 @@ class Fanfiction extends BasicSupport_Deprecated {
                                        int pos = line.indexOf("<hr");
                                        if (pos >= 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;