Archived
schon richtig schön mit daten holen
This commit is contained in:
@@ -1,49 +1,52 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ixab.GUI.StreamChooserMenu">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ixab.GUI.StreamChooserMenu">
|
||||||
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="3" column-count="10" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="5" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="20" y="20" width="556" height="400"/>
|
<xy x="20" y="20" width="650" height="400"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties>
|
||||||
|
<minimumSize width="650" height="130"/>
|
||||||
|
<preferredSize width="650" height="130"/>
|
||||||
|
</properties>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<component id="cb567" class="javax.swing.JComboBox" binding="comboBox1" default-binding="true">
|
<component id="cb567" class="javax.swing.JComboBox" binding="comboBoxStreams">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="1" row-span="1" col-span="6" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="1" row-span="1" col-span="4" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
</component>
|
</component>
|
||||||
<component id="c34b7" class="javax.swing.JLabel">
|
<component id="c34b7" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Zuschauer:"/>
|
<text value="Zuschauer:"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="65a1f" class="javax.swing.JLabel">
|
<component id="65a1f" class="javax.swing.JLabel" binding="labelStreamViewers">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="nyi"/>
|
<text value=""/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<hspacer id="a6e26">
|
<hspacer id="a6e26">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="5" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="4" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</hspacer>
|
</hspacer>
|
||||||
<component id="35b31" class="javax.swing.JComboBox" binding="comboBox2" default-binding="true">
|
<component id="35b31" class="javax.swing.JComboBox" binding="comboBox2" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="9" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
</component>
|
</component>
|
||||||
<component id="afcf8" class="javax.swing.JTextField" binding="textField1" default-binding="true">
|
<component id="afcf8" class="javax.swing.JTextField" binding="textField1" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="2" row-span="1" col-span="7" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
<grid row="4" column="1" row-span="1" col-span="6" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
<preferred-size width="150" height="-1"/>
|
<preferred-size width="150" height="-1"/>
|
||||||
</grid>
|
</grid>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -51,7 +54,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="a3649" class="javax.swing.JButton" binding="hinzufügenButton" default-binding="true">
|
<component id="a3649" class="javax.swing.JButton" binding="hinzufügenButton" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="9" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="4" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Hinzufügen"/>
|
<text value="Hinzufügen"/>
|
||||||
@@ -59,7 +62,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="16c11" class="javax.swing.JLabel">
|
<component id="16c11" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Neuer Stream:"/>
|
<text value="Neuer Stream:"/>
|
||||||
@@ -75,7 +78,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="bbe9d" class="javax.swing.JLabel">
|
<component id="bbe9d" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
<preferred-size width="39" height="14"/>
|
<preferred-size width="39" height="14"/>
|
||||||
</grid>
|
</grid>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -83,17 +86,17 @@
|
|||||||
<text value="Status:"/>
|
<text value="Status:"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="e40fa" class="javax.swing.JLabel">
|
<component id="e40fa" class="javax.swing.JLabel" binding="labelStreamStatus">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="nyi"/>
|
<text value=""/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="be49e" class="javax.swing.JButton" binding="streamAbspielenButton" default-binding="true">
|
<component id="be49e" class="javax.swing.JButton" binding="streamAbspielenButton" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="9" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Stream abspielen"/>
|
<text value="Stream abspielen"/>
|
||||||
@@ -101,7 +104,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="3b81f" class="javax.swing.JLabel">
|
<component id="3b81f" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="8" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Qualität:"/>
|
<text value="Qualität:"/>
|
||||||
@@ -109,12 +112,44 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="7c5a1" class="javax.swing.JButton" binding="entfernenButton" default-binding="true">
|
<component id="7c5a1" class="javax.swing.JButton" binding="entfernenButton" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Entfernen"/>
|
<text value="Entfernen"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="a5f20" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Streamtitel:"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="2a9d4" class="javax.swing.JLabel" binding="labelStreamTitle">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value=""/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="a1140" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Kategorie:"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="dcbec" class="javax.swing.JLabel" binding="labelStreamGame">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value=""/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.ixab.GUI;
|
package com.ixab.GUI;
|
||||||
|
|
||||||
import com.ixab.*;
|
|
||||||
import com.ixab.ConfigHandling.Config;
|
|
||||||
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
||||||
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
||||||
|
import com.ixab.StreamHandling.StreamInfo;
|
||||||
import com.ixab.StreamHandling.StreamOpener;
|
import com.ixab.StreamHandling.StreamOpener;
|
||||||
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -15,19 +13,23 @@ import java.awt.event.KeyEvent;
|
|||||||
|
|
||||||
public class StreamChooserMenu {
|
public class StreamChooserMenu {
|
||||||
private JPanel panel;
|
private JPanel panel;
|
||||||
private JComboBox comboBox1;
|
private JComboBox comboBoxStreams;
|
||||||
private JComboBox comboBox2;
|
private JComboBox comboBox2;
|
||||||
private JTextField textField1;
|
private JTextField textField1;
|
||||||
private JButton hinzufügenButton;
|
private JButton hinzufügenButton;
|
||||||
private JButton streamAbspielenButton;
|
private JButton streamAbspielenButton;
|
||||||
private JButton entfernenButton;
|
private JButton entfernenButton;
|
||||||
|
private JLabel labelStreamStatus;
|
||||||
|
private JLabel labelStreamViewers;
|
||||||
|
private JLabel labelStreamTitle;
|
||||||
|
private JLabel labelStreamGame;
|
||||||
|
|
||||||
public StreamChooserMenu() {
|
public StreamChooserMenu() {
|
||||||
this.initComboBoxes();
|
this.initComboBoxes();
|
||||||
streamAbspielenButton.addActionListener(new ActionListener() {
|
streamAbspielenButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBox1.getSelectedItem()), comboBox2.getSelectedItem().toString());
|
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBox2.getSelectedItem().toString());
|
||||||
so.start();
|
so.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -40,15 +42,20 @@ public class StreamChooserMenu {
|
|||||||
entfernenButton.addActionListener(new ActionListener() {
|
entfernenButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ConfigFileInstanceHandler.getConfig().removeStream(comboBox1.getSelectedItem());
|
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
|
||||||
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
||||||
initStreamsComboBox();
|
initStreamsComboBox();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
comboBox1.addActionListener(new ActionListener() {
|
comboBoxStreams.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
// TODO: implement twitch api and update stream info
|
// TODO: implement twitch api and update stream info
|
||||||
|
StreamInfo.getStreamInfo(comboBoxStreams.getSelectedItem().toString());
|
||||||
|
labelStreamStatus.setText(StreamInfo.getStatus());
|
||||||
|
labelStreamGame.setText(StreamInfo.getGame());
|
||||||
|
labelStreamViewers.setText(StreamInfo.getViewers());
|
||||||
|
labelStreamTitle.setText(StreamInfo.getTitle());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
textField1.addKeyListener(new KeyAdapter() {
|
textField1.addKeyListener(new KeyAdapter() {
|
||||||
@@ -72,10 +79,10 @@ public class StreamChooserMenu {
|
|||||||
initStreamsComboBox();
|
initStreamsComboBox();
|
||||||
}
|
}
|
||||||
private void initStreamsComboBox() {
|
private void initStreamsComboBox() {
|
||||||
comboBox1.removeAllItems();
|
comboBoxStreams.removeAllItems();
|
||||||
for (String streamName :
|
for (String streamName :
|
||||||
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
||||||
comboBox1.addItem(streamName);
|
comboBoxStreams.addItem(streamName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void initQualityComboBox() {
|
private void initQualityComboBox() {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.ixab.GUI.StreamChooserMenu;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private final static double version = 0.1;
|
private final static double version = 0.2;
|
||||||
private static Config c = null;
|
private static Config c = null;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package com.ixab.StreamHandling;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class StreamInfo {
|
||||||
|
private static JSONObject streamData = null;
|
||||||
|
private static JSONObject streamPreviewData = null;
|
||||||
|
public static String getGame() {
|
||||||
|
if (streamData == null && streamPreviewData == null) {
|
||||||
|
return "0";
|
||||||
|
} else {
|
||||||
|
JSONObject channelData = new JSONObject(streamData.get("channel").toString());
|
||||||
|
return channelData.get("game").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String getTitle() {
|
||||||
|
if (streamData == null && streamPreviewData == null) {
|
||||||
|
return "0";
|
||||||
|
} else {
|
||||||
|
JSONObject channelData = new JSONObject(streamData.get("channel").toString());
|
||||||
|
return channelData.get("status").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String getViewers() {
|
||||||
|
if (streamData == null && streamPreviewData == null) {
|
||||||
|
return "0";
|
||||||
|
} else {
|
||||||
|
return streamData.get("viewers").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String getStatus() {
|
||||||
|
if (streamData == null && streamPreviewData == null) {
|
||||||
|
return "offline";
|
||||||
|
} else {
|
||||||
|
return "online";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void getStreamInfo(String streamName) {
|
||||||
|
InputStream is = null;
|
||||||
|
URL url = null;
|
||||||
|
JSONObject object = null;
|
||||||
|
StringBuilder urlBuilder = new StringBuilder();
|
||||||
|
urlBuilder.append("https://api.twitch.tv/kraken/streams/");
|
||||||
|
|
||||||
|
urlBuilder.append(streamName);
|
||||||
|
|
||||||
|
String URLString = urlBuilder.toString();
|
||||||
|
|
||||||
|
try {
|
||||||
|
url = new URL(URLString);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
is = url.openStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String line;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
sb.append(line);
|
||||||
|
}
|
||||||
|
object = new JSONObject(sb.toString());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
String result = object.get("stream").toString();
|
||||||
|
|
||||||
|
if (result == "null") {
|
||||||
|
streamData = null;
|
||||||
|
streamPreviewData = null;
|
||||||
|
} else {
|
||||||
|
streamData = new JSONObject(result);
|
||||||
|
streamPreviewData = new JSONObject(streamData.get("preview").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user