From 596536368927d8a07d9853240ee831b0c076ab1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Strau=C3=9F?= Date: Wed, 30 Apr 2014 00:04:05 +0200 Subject: [PATCH] fix stream/chat handling from jar --- pom.xml | 24 +++++++++++++++++++ .../java/eu/over9000/skadi/SkadiMain.java | 1 + .../over9000/skadi/handler/ChatHandler.java | 6 +++-- .../over9000/skadi/handler/StreamHandler.java | 7 +++++- .../over9000/skadi/io/PersistenceManager.java | 11 +++++---- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 3203bc8..7d9199f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,31 @@ 1.7 + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + + package + + shade + + + + + + eu.over9000.skadi.SkadiMain + 123 + + + + + + + + \ No newline at end of file diff --git a/src/main/java/eu/over9000/skadi/SkadiMain.java b/src/main/java/eu/over9000/skadi/SkadiMain.java index 7a1acc9..aa1c240 100644 --- a/src/main/java/eu/over9000/skadi/SkadiMain.java +++ b/src/main/java/eu/over9000/skadi/SkadiMain.java @@ -97,5 +97,6 @@ public void setChannels(final TreeMap newChannels) { public void deleteChannel(final ChannelInstance channel) { this.channels.remove(channel.getURL()); channel.closeStreamAndChat(); + SkadiGUI.handleChannelListUpdate(); } } diff --git a/src/main/java/eu/over9000/skadi/handler/ChatHandler.java b/src/main/java/eu/over9000/skadi/handler/ChatHandler.java index 2448528..b1406a2 100644 --- a/src/main/java/eu/over9000/skadi/handler/ChatHandler.java +++ b/src/main/java/eu/over9000/skadi/handler/ChatHandler.java @@ -1,9 +1,11 @@ package eu.over9000.skadi.handler; +import java.io.File; import java.io.IOException; import eu.over9000.skadi.SkadiMain; import eu.over9000.skadi.channel.ChannelInstance; +import eu.over9000.skadi.io.PersistenceManager; public class ChatHandler extends Thread { @@ -23,9 +25,9 @@ private ChatHandler(final ChannelInstance instance, final String url) throws IOE this.instance = instance; this.setName("ChatHandler Thread for " + url); + final File logFile = new File(PersistenceManager.CHAT_LOG_FILE); this.process = new ProcessBuilder(SkadiMain.getInstance().chrome_exec, "--app=" + url + "chat?popout=true", - "--window-size=350,720").inheritIO().start(); - + "--window-size=350,720").redirectError(logFile).redirectOutput(logFile).start(); this.start(); } diff --git a/src/main/java/eu/over9000/skadi/handler/StreamHandler.java b/src/main/java/eu/over9000/skadi/handler/StreamHandler.java index 76c250e..8324548 100644 --- a/src/main/java/eu/over9000/skadi/handler/StreamHandler.java +++ b/src/main/java/eu/over9000/skadi/handler/StreamHandler.java @@ -1,9 +1,11 @@ package eu.over9000.skadi.handler; +import java.io.File; import java.io.IOException; import eu.over9000.skadi.SkadiMain; import eu.over9000.skadi.channel.ChannelInstance; +import eu.over9000.skadi.io.PersistenceManager; public class StreamHandler extends Thread { @@ -24,7 +26,10 @@ private StreamHandler(final ChannelInstance instance, final String url, final St this.setName("StreamHandler Thread for " + url); - this.process = new ProcessBuilder(SkadiMain.getInstance().livestreamer_exec, url, quality).inheritIO().start(); + final File logFile = new File(PersistenceManager.STREAM_LOG_FILE); + + this.process = new ProcessBuilder(SkadiMain.getInstance().livestreamer_exec, url, quality, + "-a --play-and-exit {filename}").redirectError(logFile).redirectOutput(logFile).start(); this.start(); } diff --git a/src/main/java/eu/over9000/skadi/io/PersistenceManager.java b/src/main/java/eu/over9000/skadi/io/PersistenceManager.java index 28c70df..55c92e8 100644 --- a/src/main/java/eu/over9000/skadi/io/PersistenceManager.java +++ b/src/main/java/eu/over9000/skadi/io/PersistenceManager.java @@ -28,9 +28,12 @@ public class PersistenceManager { private static PersistenceManager instance; - private static final String persistanceDir = System.getProperty("user.home") + File.separator + ".skadi" + private static final String PERSISTENCE_DIRECTORY = System.getProperty("user.home") + File.separator + ".skadi" + File.separator; - private static final String persistanceFile = "skadi_data.xml"; + private static final String PERSISTENCE_FILE = "skadi_data.xml"; + + public static final String CHAT_LOG_FILE = PersistenceManager.PERSISTENCE_DIRECTORY + "chat_output.log"; + public static final String STREAM_LOG_FILE = PersistenceManager.PERSISTENCE_DIRECTORY + "stream_output.log"; private final File dataFile; @@ -42,10 +45,10 @@ public static PersistenceManager getInstance() { } private PersistenceManager() { - final File dir = new File(PersistenceManager.persistanceDir); + final File dir = new File(PersistenceManager.PERSISTENCE_DIRECTORY); dir.mkdirs(); - this.dataFile = new File(PersistenceManager.persistanceDir + PersistenceManager.persistanceFile); + this.dataFile = new File(PersistenceManager.PERSISTENCE_DIRECTORY + PersistenceManager.PERSISTENCE_FILE); if (!this.dataFile.exists()) { try {