New one-item-per-source-type mode
[nikiroo-utils.git] / src / be / nikiroo / fanfix / library / BasicLibrary.java
index 9ac16ea2a45ba16e058d81f6d950b85e54bc8ea6..63ffdb655bafa658b4bad2dcec37e5671fd4d867 100644 (file)
@@ -52,6 +52,35 @@ abstract public class BasicLibrary {
         */
        public abstract BufferedImage getCover(String luid);
 
+       /**
+        * Return the cover image associated to this source.
+        * <p>
+        * By default, return the cover of the first story with this source.
+        * 
+        * @param source
+        *            the source
+        * 
+        * @return the cover image or NULL
+        */
+       public BufferedImage getSourceCover(String source) {
+               List<MetaData> metas = getListBySource(source);
+               if (metas.size() > 0) {
+                       return getCover(metas.get(0).getLuid());
+               }
+
+               return null;
+       }
+
+       /**
+        * Fix the source cover to the given story cover.
+        * 
+        * @param source
+        *            the source to change
+        * @param luid
+        *            the story LUID
+        */
+       public abstract void setSourceCover(String source, String luid);
+
        /**
         * Return the list of stories (represented by their {@link MetaData}, which
         * <b>MAY</b> not have the cover included).
@@ -338,7 +367,7 @@ abstract public class BasicLibrary {
                        pg.addProgress(pgOut, 1);
                }
 
-               BasicOutput out = BasicOutput.getOutput(type, true);
+               BasicOutput out = BasicOutput.getOutput(type, false);
                if (out == null) {
                        throw new IOException("Output type not supported: " + type);
                }
@@ -401,6 +430,7 @@ abstract public class BasicLibrary {
                if (getInfo(luid) != null) {
                        delete(luid);
                }
+
                doSave(story, pg);
 
                clearCache();