diff --git a/pom.xml b/pom.xml index a90d50e..3203bc8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,16 +1,31 @@ - - 4.0.0 - over9000 - Skadi - 1.0.0-SNAPSHOT - Skadi - livestreamer java gui - - - javafx - jfxrt - ${java.version} - system - ${java.home}/lib/jfxrt.jar - + + 4.0.0 + over9000 + Skadi + 1.0.0-SNAPSHOT + Skadi + livestreamer java gui + + + s1mpl3x + + + + UTF-8 + + + + + + maven-compiler-plugin + 3.0 + + 1.7 + 1.7 + + + + + \ 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 bdd4e64..7a1acc9 100644 --- a/src/main/java/eu/over9000/skadi/SkadiMain.java +++ b/src/main/java/eu/over9000/skadi/SkadiMain.java @@ -1,9 +1,8 @@ package eu.over9000.skadi; -import java.util.Map; +import java.util.TreeMap; import java.util.regex.Pattern; -import javafx.application.Application; import eu.over9000.skadi.channel.ChannelInstance; import eu.over9000.skadi.gui.SkadiGUI; import eu.over9000.skadi.io.PersistenceManager; @@ -12,7 +11,10 @@ public class SkadiMain { private static SkadiMain instance; - private final Map channels = PersistenceManager.getInstance().loadChannels(); + private TreeMap channels = new TreeMap<>(); + + public String livestreamer_exec = "livestreamer"; + public String chrome_exec = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"; public static SkadiMain getInstance() { if (SkadiMain.instance == null) { @@ -27,7 +29,8 @@ public static void main(final String[] args) { private void runInit(final String[] args) { this.addShutdownHook(); - Application.launch(SkadiGUI.class, args); + PersistenceManager.getInstance().loadData(); + SkadiGUI.create(); } private void addShutdownHook() { @@ -35,18 +38,25 @@ private void addShutdownHook() { @Override public void run() { - System.out.println("BEGIN HOOK"); + System.out.println("KILLING STREAMS/CHATS.."); for (final ChannelInstance instance : SkadiMain.this.channels.values()) { instance.closeStreamAndChat(); } - System.out.println("END HOOK"); + System.out.println("SAVING DATA.."); + PersistenceManager.getInstance().saveData(); + System.out.println("SHUTDOWN COMPLETE"); } })); } - public void addAndOpenNewChannel(String url) { + public void addNewChannel(String url) { + if (!url.endsWith("/")) { + url = url + "/"; + } + if (!SkadiMain.validateURL(url)) { + System.out.println("invalid url given"); return; } if (url.startsWith("twitch.tv/")) { @@ -56,21 +66,36 @@ public void addAndOpenNewChannel(String url) { url = "http://" + url; } - if (!url.endsWith("/")) { - url = url + "/"; + if (this.channels.containsKey(url)) { + System.out.println("Channel already in list"); + return; } final ChannelInstance newChannel = new ChannelInstance(url, "best"); this.channels.put(url, newChannel); - newChannel.openStreamAndChat(); - System.out.println("ADDED AND OPENED STREAM AND CHAT FOR URL " + url); + SkadiGUI.handleChannelListUpdate(); + } private static boolean validateURL(final String url) { - return Pattern.matches("(http://)?(www\\.)?(twitch\\.tv/)[0-9a-zA-Z]+/", url); + return Pattern.matches("(http://)?(www\\.)?(twitch\\.tv/)[A-Za-z0-9_]+/", url); + + } + + public TreeMap getChannels() { + return this.channels; + } + + public void setChannels(final TreeMap newChannels) { + this.channels = newChannels; + } + + public void deleteChannel(final ChannelInstance channel) { + this.channels.remove(channel.getURL()); + channel.closeStreamAndChat(); } } diff --git a/src/main/java/eu/over9000/skadi/channel/ChannelInstance.java b/src/main/java/eu/over9000/skadi/channel/ChannelInstance.java index 2aa9040..b7c85d7 100644 --- a/src/main/java/eu/over9000/skadi/channel/ChannelInstance.java +++ b/src/main/java/eu/over9000/skadi/channel/ChannelInstance.java @@ -58,4 +58,12 @@ public void closeStreamAndChat() { this.closeStream(); this.closeChat(); } + + public String getURL() { + return this.url; + } + + public String getQuality() { + return this.quality; + } } diff --git a/src/main/java/eu/over9000/skadi/gui/ChannelDataListModel.java b/src/main/java/eu/over9000/skadi/gui/ChannelDataListModel.java new file mode 100644 index 0000000..ca0ffd0 --- /dev/null +++ b/src/main/java/eu/over9000/skadi/gui/ChannelDataListModel.java @@ -0,0 +1,29 @@ +package eu.over9000.skadi.gui; + +import javax.swing.AbstractListModel; + +import eu.over9000.skadi.SkadiMain; +import eu.over9000.skadi.channel.ChannelInstance; + +public class ChannelDataListModel extends AbstractListModel { + + /** + * serialVersionUID + */ + private static final long serialVersionUID = 7576558662916716790L; + + @Override + public int getSize() { + return SkadiMain.getInstance().getChannels().size(); + } + + @Override + public ChannelInstance getElementAt(final int index) { + return SkadiMain.getInstance().getChannels().values().toArray(new ChannelInstance[0])[index]; + } + + public void handleUpdate() { + this.fireContentsChanged(this, 0, this.getSize()); + } + +} diff --git a/src/main/java/eu/over9000/skadi/gui/ChannelDataListRenderer.java b/src/main/java/eu/over9000/skadi/gui/ChannelDataListRenderer.java new file mode 100644 index 0000000..fb255e4 --- /dev/null +++ b/src/main/java/eu/over9000/skadi/gui/ChannelDataListRenderer.java @@ -0,0 +1,52 @@ +package eu.over9000.skadi.gui; + +import java.awt.Component; + +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; + +import eu.over9000.skadi.channel.ChannelInstance; + +public class ChannelDataListRenderer implements ListCellRenderer { + + private final ChannelDataListDisplayer displayer = new ChannelDataListDisplayer(); + + @Override + public Component getListCellRendererComponent(final JList list, + final ChannelInstance value, final int index, final boolean isSelected, final boolean cellHasFocus) { + return this.displayer.renderFor(list, value, isSelected); + } + + private class ChannelDataListDisplayer extends JPanel { + + /** + * serialVersionUID + */ + private static final long serialVersionUID = 3574128645388761068L; + + private final JLabel labelURL; + + public ChannelDataListDisplayer() { + this.labelURL = new JLabel(); + + this.add(this.labelURL); + } + + public Component renderFor(final JList list, final ChannelInstance value, + final boolean isSelected) { + this.labelURL.setText(value.getURL()); + + if (isSelected) { + this.setBackground(list.getSelectionBackground()); + this.setForeground(list.getSelectionForeground()); + } else { + this.setBackground(list.getBackground()); + this.setForeground(list.getForeground()); + } + return this; + } + + } +} diff --git a/src/main/java/eu/over9000/skadi/gui/SkadiGUI.java b/src/main/java/eu/over9000/skadi/gui/SkadiGUI.java index 20746e0..6020961 100644 --- a/src/main/java/eu/over9000/skadi/gui/SkadiGUI.java +++ b/src/main/java/eu/over9000/skadi/gui/SkadiGUI.java @@ -1,70 +1,216 @@ package eu.over9000.skadi.gui; -import javafx.application.Application; -import javafx.application.Platform; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.HBox; -import javafx.stage.Stage; -import javafx.stage.WindowEvent; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.ScrollPaneConstants; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + import eu.over9000.skadi.SkadiMain; +import eu.over9000.skadi.channel.ChannelInstance; -public class SkadiGUI extends Application { +public class SkadiGUI extends JFrame { - @Override - public void start(final Stage stage) throws Exception { - stage.setTitle("Skadi"); - - stage.setOnCloseRequest(new EventHandler() { - - @Override - public void handle(final WindowEvent e) { - e.consume(); - Platform.exit(); - System.exit(0); - } - }); - - final GridPane grid = new GridPane(); - grid.setAlignment(Pos.CENTER); - grid.setHgap(10); - grid.setVgap(10); - grid.setPadding(new Insets(25, 25, 25, 25)); - - final Scene scene = new Scene(grid, 340, 200); - stage.setScene(scene); - - final Label channelURLLabel = new Label("URL"); - final TextField channelURLField = new TextField(); - final Button channelURLButton = new Button("Open Stream & Chat"); + /** + * serialVersionUID + */ + private static final long serialVersionUID = 2045150091920320920L; + + private static SkadiGUI instance; + + private JPanel pnNew; + private JTextField textNewChannel; + private JButton btnAddChannel; + private JScrollPane spChannels; + private JList listChannels; + private JLabel labelAddChannel; + + private final ChannelDataListModel listModel; + private JPanel panel; + private JButton btnOpenBoth; + private JButton btnStream; + private JButton btnChat; + private JButton btnDelete; + + private SkadiGUI() { + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - final HBox hbBtn = new HBox(10); - hbBtn.setAlignment(Pos.BOTTOM_RIGHT); - hbBtn.getChildren().add(channelURLButton); + this.listModel = new ChannelDataListModel(); - grid.add(channelURLLabel, 0, 0); - grid.add(channelURLField, 1, 0); - grid.add(hbBtn, 1, 1); + this.initialize(); + this.pack(); + this.setMinimumSize(this.getSize()); + this.setVisible(true); + } + + private void initialize() { + this.setTitle("Skadi"); + this.setLocationRelativeTo(null); + this.getContentPane().setLayout(new BorderLayout(0, 0)); + this.getContentPane().add(this.getPnNew(), BorderLayout.NORTH); + this.getContentPane().add(this.getSpChannels(), BorderLayout.CENTER); + this.getContentPane().add(this.getPanel(), BorderLayout.SOUTH); + } + + private JPanel getPnNew() { + if (this.pnNew == null) { + this.pnNew = new JPanel(); + this.pnNew.add(this.getLabelAddChannel()); + this.pnNew.add(this.getTextNewChannel()); + this.pnNew.add(this.getBtnAddChannel()); + } + return this.pnNew; + } + + private JTextField getTextNewChannel() { + if (this.textNewChannel == null) { + this.textNewChannel = new JTextField(); + this.textNewChannel.setColumns(20); + } + return this.textNewChannel; + } + + private JButton getBtnAddChannel() { + if (this.btnAddChannel == null) { + this.btnAddChannel = new JButton("Add channel to list"); + this.btnAddChannel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(final ActionEvent arg0) { + SkadiMain.getInstance().addNewChannel(SkadiGUI.this.getTextNewChannel().getText()); + } + }); + } + return this.btnAddChannel; + } + + private JScrollPane getSpChannels() { + if (this.spChannels == null) { + this.spChannels = new JScrollPane(); + this.spChannels.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + this.spChannels.setViewportView(this.getListChannels()); + } + return this.spChannels; + } + + private JList getListChannels() { + if (this.listChannels == null) { + this.listChannels = new JList<>(this.listModel); + this.listChannels.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + this.listChannels.setCellRenderer(new ChannelDataListRenderer()); + } + return this.listChannels; + } + + private JLabel getLabelAddChannel() { + if (this.labelAddChannel == null) { + this.labelAddChannel = new JLabel("Add channel:"); + } + return this.labelAddChannel; + } + + public static void create() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException + | UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } - channelURLButton.setOnAction(new EventHandler() { - - @Override - public void handle(final ActionEvent event) { - if (channelURLField.getText().isEmpty()) { - return; + SkadiGUI.instance = new SkadiGUI(); + } + + public static void handleChannelListUpdate() { + SkadiGUI.instance.listModel.handleUpdate(); + } + + private JPanel getPanel() { + if (this.panel == null) { + this.panel = new JPanel(); + this.panel.add(this.getBtnOpenBoth()); + this.panel.add(this.getBtnStream()); + this.panel.add(this.getBtnChat()); + this.panel.add(this.getBtnDelete()); + } + return this.panel; + } + + private JButton getBtnOpenBoth() { + if (this.btnOpenBoth == null) { + this.btnOpenBoth = new JButton("Open Stream & Chat"); + this.btnOpenBoth.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + final ChannelInstance channel = SkadiGUI.this.listChannels.getSelectedValue(); + + if (channel != null) { + channel.openStreamAndChat(); + } } + }); + } + return this.btnOpenBoth; + } + + private JButton getBtnStream() { + if (this.btnStream == null) { + this.btnStream = new JButton("Open Stream"); + this.btnStream.addActionListener(new ActionListener() { - SkadiMain.getInstance().addAndOpenNewChannel(channelURLField.getText()); - } - }); - - stage.show(); + @Override + public void actionPerformed(final ActionEvent e) { + final ChannelInstance channel = SkadiGUI.this.listChannels.getSelectedValue(); + + if (channel != null) { + channel.openStream(); + } + } + }); + } + return this.btnStream; + } + + private JButton getBtnChat() { + if (this.btnChat == null) { + this.btnChat = new JButton("Open Chat"); + this.btnChat.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + final ChannelInstance channel = SkadiGUI.this.listChannels.getSelectedValue(); + + if (channel != null) { + channel.openChat(); + } + } + }); + } + return this.btnChat; + } + + private JButton getBtnDelete() { + if (this.btnDelete == null) { + this.btnDelete = new JButton("Delete"); + this.btnDelete.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(final ActionEvent e) { + final ChannelInstance channel = SkadiGUI.this.listChannels.getSelectedValue(); + + SkadiMain.getInstance().deleteChannel(channel); + } + }); + } + return this.btnDelete; } } \ No newline at end of file diff --git a/src/main/java/eu/over9000/skadi/handler/ChatHandler.java b/src/main/java/eu/over9000/skadi/handler/ChatHandler.java index 27dbb93..2448528 100644 --- a/src/main/java/eu/over9000/skadi/handler/ChatHandler.java +++ b/src/main/java/eu/over9000/skadi/handler/ChatHandler.java @@ -2,6 +2,7 @@ import java.io.IOException; +import eu.over9000.skadi.SkadiMain; import eu.over9000.skadi.channel.ChannelInstance; public class ChatHandler extends Thread { @@ -22,12 +23,8 @@ private ChatHandler(final ChannelInstance instance, final String url) throws IOE this.instance = instance; this.setName("ChatHandler Thread for " + url); - final ProcessBuilder builder = new ProcessBuilder( - "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", - "--app=" + url + "chat?popout=true", "--window-size=350,720"); - - builder.inheritIO(); - this.process = builder.start(); + this.process = new ProcessBuilder(SkadiMain.getInstance().chrome_exec, "--app=" + url + "chat?popout=true", + "--window-size=350,720").inheritIO().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 efb41fc..76c250e 100644 --- a/src/main/java/eu/over9000/skadi/handler/StreamHandler.java +++ b/src/main/java/eu/over9000/skadi/handler/StreamHandler.java @@ -2,6 +2,7 @@ import java.io.IOException; +import eu.over9000.skadi.SkadiMain; import eu.over9000.skadi.channel.ChannelInstance; public class StreamHandler extends Thread { @@ -23,9 +24,7 @@ private StreamHandler(final ChannelInstance instance, final String url, final St this.setName("StreamHandler Thread for " + url); - final ProcessBuilder builder = new ProcessBuilder("livestreamer", url, quality); - builder.inheritIO(); - this.process = builder.start(); + this.process = new ProcessBuilder(SkadiMain.getInstance().livestreamer_exec, url, quality).inheritIO().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 f1ae0d6..28c70df 100644 --- a/src/main/java/eu/over9000/skadi/io/PersistenceManager.java +++ b/src/main/java/eu/over9000/skadi/io/PersistenceManager.java @@ -1,13 +1,39 @@ package eu.over9000.skadi.io; -import java.util.HashMap; -import java.util.Map; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.TreeMap; +import javax.management.modelmbean.XMLParseException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import eu.over9000.skadi.SkadiMain; import eu.over9000.skadi.channel.ChannelInstance; public class PersistenceManager { private static PersistenceManager instance; + private static final String persistanceDir = System.getProperty("user.home") + File.separator + ".skadi" + + File.separator; + private static final String persistanceFile = "skadi_data.xml"; + + private final File dataFile; + public static PersistenceManager getInstance() { if (PersistenceManager.instance == null) { PersistenceManager.instance = new PersistenceManager(); @@ -15,8 +41,148 @@ public static PersistenceManager getInstance() { return PersistenceManager.instance; } - public Map loadChannels() { - // TODO Auto-generated method stub - return new HashMap<>(); + private PersistenceManager() { + final File dir = new File(PersistenceManager.persistanceDir); + dir.mkdirs(); + + this.dataFile = new File(PersistenceManager.persistanceDir + PersistenceManager.persistanceFile); + + if (!this.dataFile.exists()) { + try { + this.dataFile.createNewFile(); + this.saveData(); + } catch (final IOException e) { + e.printStackTrace(); + } + } + } + + public void saveData() { + try { + final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + final Document document = documentBuilder.newDocument(); + document.setXmlStandalone(true); + + final Element specificationRoot = document.createElement(XMLConstants.ROOT); + specificationRoot.setAttribute(XMLConstants.VERSION, XMLConstants.VERSION_VALUE); + document.appendChild(specificationRoot); + + final Element execRoot = document.createElement(XMLConstants.EXECUTABLES); + final Element channelsRoot = document.createElement(XMLConstants.CHANNELS); + + specificationRoot.appendChild(execRoot); + + final Element chrome_exec = document.createElement(XMLConstants.CHROME_EXECUTABLE); + chrome_exec.setTextContent(SkadiMain.getInstance().chrome_exec); + execRoot.appendChild(chrome_exec); + + final Element livestreamer_exec = document.createElement(XMLConstants.LIVESTREAMER_EXECUTABLE); + livestreamer_exec.setTextContent(SkadiMain.getInstance().livestreamer_exec); + execRoot.appendChild(livestreamer_exec); + + specificationRoot.appendChild(channelsRoot); + for (final ChannelInstance channel : SkadiMain.getInstance().getChannels().values()) { + final Element channelRoot = document.createElement(XMLConstants.CHANNEL); + + final Element hostElement = document.createElement(XMLConstants.HOST); + hostElement.appendChild(document.createTextNode("TWITCH")); + channelRoot.appendChild(hostElement); + + final Element urlElement = document.createElement(XMLConstants.URL); + urlElement.appendChild(document.createTextNode(channel.getURL())); + channelRoot.appendChild(urlElement); + + final Element qualityElement = document.createElement(XMLConstants.QUALITY); + qualityElement.appendChild(document.createTextNode(channel.getQuality())); + channelRoot.appendChild(qualityElement); + + channelsRoot.appendChild(channelRoot); + } + + final FileOutputStream stream = new FileOutputStream(this.dataFile); + final TransformerFactory transformerFactory = TransformerFactory.newInstance(); + final Transformer transformer = transformerFactory.newTransformer(); + transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "yes"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3"); + final DOMSource source = new DOMSource(document); + final StreamResult result = new StreamResult(stream); + transformer.transform(source, result); + stream.close(); + + } catch (ParserConfigurationException | IOException | TransformerException e) { + e.printStackTrace(); + } + + } + + private TreeMap loadChannels(final Element channelsRootElement) { + final TreeMap loadedChannels = new TreeMap<>(); + + final NodeList channels = channelsRootElement.getElementsByTagName(XMLConstants.CHANNEL); + + for (int index = 0; index < channels.getLength(); index++) { + final Element channel = (Element) channels.item(index); + + // final String host = channel.getElementsByTagName(XMLConstants.HOST).item(0).getTextContent(); + final String url = channel.getElementsByTagName(XMLConstants.URL).item(0).getTextContent(); + final String quality = channel.getElementsByTagName(XMLConstants.QUALITY).item(0).getTextContent(); + + final ChannelInstance loaded = new ChannelInstance(url, quality); + + loadedChannels.put(url, loaded); + } + + return loadedChannels; + } + + public void loadData() { + + try { + final FileInputStream stream = new FileInputStream(this.dataFile); + final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + final Document document = documentBuilder.parse(stream); + + document.getDocumentElement().normalize(); + + // Check doc basics + final String docRoot = document.getDocumentElement().getNodeName(); + if (!docRoot.equals(XMLConstants.ROOT)) { + throw new XMLParseException( + "The given XML Document does not have the correct format. (Wrong root node)."); + } + + final String version = document.getDocumentElement().getAttribute(XMLConstants.VERSION); + if (!version.equals(XMLConstants.VERSION_VALUE)) { + throw new XMLParseException("The version of the file (" + version + + ") is not compatible with this importer (" + XMLConstants.VERSION_VALUE + ")."); + } + + final Element execs = (Element) document.getDocumentElement() + .getElementsByTagName(XMLConstants.EXECUTABLES).item(0); + + SkadiMain.getInstance().chrome_exec = this.loadChromeExec(execs); + SkadiMain.getInstance().livestreamer_exec = this.loadLivestreamerExec(execs); + + final Element channels = (Element) document.getDocumentElement() + .getElementsByTagName(XMLConstants.CHANNELS).item(0); + + SkadiMain.getInstance().setChannels(this.loadChannels(channels)); + + stream.close(); + } catch (final SAXException | IOException | ParserConfigurationException | XMLParseException e) { + e.printStackTrace(); + } + + } + + private String loadLivestreamerExec(final Element execs) { + return execs.getElementsByTagName(XMLConstants.LIVESTREAMER_EXECUTABLE).item(0).getTextContent(); + } + + private String loadChromeExec(final Element execs) { + return execs.getElementsByTagName(XMLConstants.CHROME_EXECUTABLE).item(0).getTextContent(); } } \ No newline at end of file diff --git a/src/main/java/eu/over9000/skadi/io/XMLConstants.java b/src/main/java/eu/over9000/skadi/io/XMLConstants.java new file mode 100644 index 0000000..60966ac --- /dev/null +++ b/src/main/java/eu/over9000/skadi/io/XMLConstants.java @@ -0,0 +1,19 @@ +package eu.over9000.skadi.io; + +public class XMLConstants { + public static final String VERSION = "VERSION"; + public static final String VERSION_VALUE = "1.0"; + public static final String ROOT = "SKADI_DATA"; + public static final String EXECUTABLES = "EXECUTABLES"; + + public static final String CHROME_EXECUTABLE = "CHROME"; + public static final String LIVESTREAMER_EXECUTABLE = "LIVESTREAMER"; + + public static final String CHANNELS = "CHANNELS"; + public static final String CHANNEL = "CHANNEL"; + + public static final String URL = "URL"; + public static final String QUALITY = "QUALITY"; + public static final String HOST = "HOST"; + +}