Fix remote, fix --list
authorNiki Roo <niki@nikiroo.be>
Sun, 26 Nov 2017 17:19:05 +0000 (18:19 +0100)
committerNiki Roo <niki@nikiroo.be>
Sun, 26 Nov 2017 17:19:05 +0000 (18:19 +0100)
src/be/nikiroo/fanfix/Main.java
src/be/nikiroo/fanfix/library/RemoteLibraryServer.java

index a133de789cf3de776e0a8519ffd1ec5b5d3536f9..813a9b40320758e42a4244778b5c86971cc95137 100644 (file)
@@ -4,9 +4,11 @@ import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.List;
 
 import be.nikiroo.fanfix.bundles.StringId;
 import be.nikiroo.fanfix.data.Chapter;
+import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.library.BasicLibrary;
 import be.nikiroo.fanfix.library.CacheLibrary;
@@ -439,7 +441,18 @@ public class Main {
         * @return the exit return code (0 = success)
         */
        private static int list(String source) {
-               BasicReader.getReader().browse(source);
+               List<MetaData> stories;
+               stories = BasicReader.getReader().getLibrary().getListBySource(source);
+
+               for (MetaData story : stories) {
+                       String author = "";
+                       if (story.getAuthor() != null && !story.getAuthor().isEmpty()) {
+                               author = " (" + story.getAuthor() + ")";
+                       }
+
+                       System.out.println(story.getLuid() + ": " + story.getTitle()
+                                       + author);
+               }
                return 0;
        }
 
index 5bbe4cdd1f33b77bb67e609b91b7770aa886a35e..d2d9a6e6fa870fd007d0617b18b540e49124bab8 100644 (file)
@@ -55,7 +55,6 @@ public class RemoteLibraryServer extends Server {
        @Override
        protected Object onRequest(ConnectActionServer action,
                        Version clientVersion, Object data) throws Exception {
-
                String key = "";
                String command = "";
                Object[] args = new Object[0];
@@ -64,7 +63,7 @@ public class RemoteLibraryServer extends Server {
                        if (dataArray.length >= 2) {
                                args = new Object[dataArray.length - 2];
                                for (int i = 2; i < dataArray.length; i++) {
-                                       args[i] = dataArray[i];
+                                       args[i - 2] = dataArray[i];
                                }
 
                                key = "" + dataArray[0];