fixed streaming support
This commit is contained in:
parent
cca494e415
commit
d005c32443
|
@ -719,7 +719,7 @@ public class MainWindowController {
|
||||||
fileChooser.setTitle("Open Resource File");
|
fileChooser.setTitle("Open Resource File");
|
||||||
File selectedFile = fileChooser.showOpenDialog(main.getPrimaryStage());
|
File selectedFile = fileChooser.showOpenDialog(main.getPrimaryStage());
|
||||||
if (selectedFile != null && selectedFile.exists()) {
|
if (selectedFile != null && selectedFile.exists()) {
|
||||||
addSource(selectedFile.getPath(), "local");
|
addSource(selectedFile.getPath(), "stream");
|
||||||
dbController.refreshDataBase();
|
dbController.refreshDataBase();
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error("The selected file dosen't exist!");
|
LOGGER.error("The selected file dosen't exist!");
|
||||||
|
|
|
@ -65,11 +65,8 @@ public class DBController {
|
||||||
private Image favorite_border_black = new Image("icons/ic_favorite_border_black_18dp_1x.png");
|
private Image favorite_border_black = new Image("icons/ic_favorite_border_black_18dp_1x.png");
|
||||||
private List<String> filmsdbAll = new ArrayList<String>();
|
private List<String> filmsdbAll = new ArrayList<String>();
|
||||||
private List<String> filmsdbDir = new ArrayList<String>(); // needed
|
private List<String> filmsdbDir = new ArrayList<String>(); // needed
|
||||||
private List<String> filmsdbStream = new ArrayList<String>();
|
|
||||||
private List<String> filmsdbStreamURL = new ArrayList<String>(); // needed
|
private List<String> filmsdbStreamURL = new ArrayList<String>(); // needed
|
||||||
private List<String> filmsAll = new ArrayList<String>();
|
private List<String> filmsAll = new ArrayList<String>();
|
||||||
// private List<String> filmsDirURL = new ArrayList<String>();
|
|
||||||
private List<String> filmsStream = new ArrayList<String>();
|
|
||||||
private List<String> filmsStreamURL = new ArrayList<String>(); // needed
|
private List<String> filmsStreamURL = new ArrayList<String>(); // needed
|
||||||
private List<String> filmsStreamData = new ArrayList<String>();
|
private List<String> filmsStreamData = new ArrayList<String>();
|
||||||
private Connection connection = null;
|
private Connection connection = null;
|
||||||
|
@ -130,7 +127,7 @@ public class DBController {
|
||||||
|
|
||||||
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
|
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
filmsdbStream.add(rs.getString(6));
|
filmsdbAll.add(rs.getString(6));
|
||||||
filmsdbStreamURL.add(rs.getString(7));
|
filmsdbStreamURL.add(rs.getString(7));
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
@ -140,9 +137,7 @@ public class DBController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all entries to filmsAll and filmsdbAl, for later comparing
|
// add all entries to filmsAll and filmsdbAl, for later comparing
|
||||||
filmsAll.addAll(filmsStream);
|
|
||||||
filmsdbAll.addAll(filmsdbDir);
|
filmsdbAll.addAll(filmsdbDir);
|
||||||
filmsdbAll.addAll(filmsdbStream);
|
|
||||||
LOGGER.info("films in directory: " + filmsAll.size());
|
LOGGER.info("films in directory: " + filmsAll.size());
|
||||||
LOGGER.info("filme in db: " + filmsdbAll.size());
|
LOGGER.info("filme in db: " + filmsdbAll.size());
|
||||||
}
|
}
|
||||||
|
@ -175,7 +170,7 @@ public class DBController {
|
||||||
JsonObject object = Json.parse(new FileReader(path)).asObject();
|
JsonObject object = Json.parse(new FileReader(path)).asObject();
|
||||||
JsonArray items = object.get("entries").asArray();
|
JsonArray items = object.get("entries").asArray();
|
||||||
for (JsonValue item : items) {
|
for (JsonValue item : items) {
|
||||||
filmsStream.add(item.asObject().getString("titel", ""));
|
filmsAll.add(item.asObject().getString("titel", ""));
|
||||||
filmsStreamURL.add(item.asObject().getString("streamUrl", ""));
|
filmsStreamURL.add(item.asObject().getString("streamUrl", ""));
|
||||||
filmsStreamData.add(path);
|
filmsStreamData.add(path);
|
||||||
// TODO check if all this is needed, maybe only use one table!
|
// TODO check if all this is needed, maybe only use one table!
|
||||||
|
@ -186,7 +181,6 @@ public class DBController {
|
||||||
LOGGER.info("added films from: " + path);
|
LOGGER.info("added films from: " + path);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,10 +282,8 @@ public class DBController {
|
||||||
// clean all ArraLists
|
// clean all ArraLists
|
||||||
filmsdbAll.removeAll(filmsdbAll);
|
filmsdbAll.removeAll(filmsdbAll);
|
||||||
filmsdbDir.removeAll(filmsdbDir);
|
filmsdbDir.removeAll(filmsdbDir);
|
||||||
filmsdbStream.removeAll(filmsdbStream);
|
|
||||||
filmsdbStreamURL.removeAll(filmsdbStreamURL);
|
filmsdbStreamURL.removeAll(filmsdbStreamURL);
|
||||||
filmsAll.removeAll(filmsAll);
|
filmsAll.removeAll(filmsAll);
|
||||||
filmsStream.removeAll(filmsStream);
|
|
||||||
filmsStreamURL.removeAll(filmsStreamURL);
|
filmsStreamURL.removeAll(filmsStreamURL);
|
||||||
filmsStreamData.removeAll(filmsStreamData);
|
filmsStreamData.removeAll(filmsStreamData);
|
||||||
|
|
||||||
|
@ -332,26 +324,15 @@ public class DBController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO needs testing, then remove 1
|
|
||||||
for (String entry : filmsdbStreamURL) {
|
for (String entry : filmsdbStreamURL) {
|
||||||
if (!filmsStreamURL.contains(entry)) {
|
if (!filmsStreamURL.contains(entry)) {
|
||||||
stmt.executeUpdate("delete from film_streaming where titel = \"" + entry + "\"");
|
stmt.executeUpdate("delete from film_streaming where streamUrl = \"" + entry + "\"");
|
||||||
connection.commit();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LOGGER.info("removed \"" + entry + "\" from database");
|
LOGGER.info("removed \"" + entry + "\" from database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is 1
|
|
||||||
// for (int j = 0; j < filmsdbStreamURL.size(); j++) {
|
|
||||||
// if (!filmsStreamURL.contains(filmsdbStreamURL.get(j))) {
|
|
||||||
// stmt.executeUpdate("delete from film_streaming where titel = \"" + filmsdbStream.get(j) + "\"");
|
|
||||||
// connection.commit();
|
|
||||||
// stmt.close();
|
|
||||||
// LOGGER.info("removed \"" + filmsdbStream.get(j) + "\" from database");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue