Archived
[ADDED] Streams können nun von Nutzern importiert werden
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -59,7 +59,7 @@
|
||||
<children>
|
||||
<component id="1f1a7" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="2" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" 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="Pfad zu Livestreamer:"/>
|
||||
@@ -67,7 +67,7 @@
|
||||
</component>
|
||||
<component id="42a4f" class="javax.swing.JCheckBox" binding="debugmodusCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
@@ -75,7 +75,7 @@
|
||||
</component>
|
||||
<component id="e34b3" 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"/>
|
||||
<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="Debugmodus:"/>
|
||||
@@ -83,7 +83,7 @@
|
||||
</component>
|
||||
<component id="c2e59" class="javax.swing.JTextField" binding="textField1" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -91,28 +91,23 @@
|
||||
</component>
|
||||
<component id="4ab40" class="javax.swing.JButton" binding="suchenButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="2" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Suchen"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="e5e81">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="c3f1e" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<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"/>
|
||||
<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="Benutzer Import:"/>
|
||||
<text value="Favoriten Import:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3e70" class="javax.swing.JTextField" binding="twitchBenutzernameTextField" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -122,7 +117,7 @@
|
||||
</component>
|
||||
<component id="9749e" class="javax.swing.JButton" binding="buttonImportUserData">
|
||||
<constraints>
|
||||
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Importieren"/>
|
||||
|
||||
@@ -61,8 +61,29 @@ public class SettingsWindow extends JDialog {
|
||||
buttonImportUserData.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
UserInfo.initUserFollowData(twitchBenutzernameTextField.getText());
|
||||
final String old = buttonImportUserData.getText();
|
||||
buttonImportUserData.setText("bitte warten...");
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (UserInfo.initUserFollowData(twitchBenutzernameTextField.getText(), 0)) {
|
||||
UserInfo.getFollowedChannelNames();
|
||||
// TODO: prüfe ob channel schon vorhanden sind
|
||||
for (String name :
|
||||
UserInfo.getFollowedChannelNames()) {
|
||||
ConfigFileInstanceHandler.getConfig().addStream(name);
|
||||
}
|
||||
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
||||
MainWindowGate.getMainWindow().lockStreamInfoGetter = true;
|
||||
MainWindowGate.getMainWindow().initStreamsComboBox();
|
||||
MainWindowGate.getMainWindow().lockStreamInfoGetter = false;
|
||||
}
|
||||
buttonImportUserData.setText(old);
|
||||
ErrorMessageGate.setErrorText("Streams von "+twitchBenutzernameTextField.getText()+" hinzugefügt.");
|
||||
}
|
||||
};
|
||||
Thread t = new Thread(r);
|
||||
t.start();
|
||||
}
|
||||
});
|
||||
twitchBenutzernameTextField.addFocusListener(new FocusAdapter() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ixab.UserInfoHandling;
|
||||
|
||||
import com.ixab.GUI.ErrorMessageGate;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
@@ -10,19 +11,30 @@ import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UserInfo {
|
||||
private static JSONArray userFollowData;
|
||||
private static JSONArray userFollowData; // TODO: change this to an arraylist of multiple jsonarrays
|
||||
private static String userFollowCount;
|
||||
|
||||
private static int getFollowCount() {
|
||||
return Integer.getInteger(userFollowCount);
|
||||
return Integer.parseInt(userFollowCount);
|
||||
}
|
||||
public static ArrayList<String> getFollowedChannelNames() {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
System.out.println(userFollowData.toString()); // TODO: implement something to work with
|
||||
for (int i = 0; i<getFollowCount(); i++) {
|
||||
try {
|
||||
JSONObject followed = new JSONObject(userFollowData.get(i).toString());
|
||||
JSONObject channel = new JSONObject(followed.get("channel").toString());
|
||||
System.out.println(i+" "+channel.get("display_name").toString()); //remove this line if not needed anymore
|
||||
names.add(channel.get("display_name").toString());
|
||||
// TODO: bisher nur maximal 100 importieren wegen twitch api.
|
||||
} catch (JSONException e) {
|
||||
// workaround for stupid limit of jsonarrays of twitch's api.
|
||||
// there's nothing interesting to show.
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static boolean initUserFollowData(String userName) {
|
||||
public static boolean initUserFollowData(String userName, int offset) {
|
||||
if (userName != null) {
|
||||
InputStream is = null;
|
||||
URL url = null;
|
||||
@@ -32,7 +44,9 @@ public class UserInfo {
|
||||
|
||||
urlBuilder.append(userName);
|
||||
|
||||
urlBuilder.append("/follows/channels");
|
||||
urlBuilder.append("/follows/channels?direction=DESC&limit=100&offset=");
|
||||
|
||||
urlBuilder.append(offset);
|
||||
|
||||
String URLString = urlBuilder.toString();
|
||||
|
||||
@@ -67,7 +81,7 @@ public class UserInfo {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String result = object.get("_total").toString();
|
||||
String result = object.get("_total").toString(); // TODO: reagiere hier auf >100, weil dann mehrere jsonarrays benötigt werden.
|
||||
|
||||
if (result == "null") {
|
||||
userFollowData = null;
|
||||
|
||||
Reference in New Issue
Block a user