removed streaming mode, all films are now in one mode
* removed streaming mode, all films are now in one mode. This will make it easiere to maintain HomeFlix * fixed a bug that caused series to be periodicaly removed * added season and episode column to the film table * lots of code cleanup
This commit is contained in:
parent
ad63d566c9
commit
d23a3bbe4e
|
@ -63,7 +63,6 @@ public class Main extends Application {
|
||||||
|
|
||||||
private String path;
|
private String path;
|
||||||
private String FONT_FAMILY = "System";
|
private String FONT_FAMILY = "System";
|
||||||
private String mode = "local"; //local or streaming TODO
|
|
||||||
private String local = System.getProperty("user.language")+"_"+System.getProperty("user.country");
|
private String local = System.getProperty("user.language")+"_"+System.getProperty("user.country");
|
||||||
private double FONT_SIZE = 17;
|
private double FONT_SIZE = 17;
|
||||||
private ResourceBundle bundle;
|
private ResourceBundle bundle;
|
||||||
|
@ -112,7 +111,6 @@ public class Main extends Application {
|
||||||
mainWindowController.setSize(FONT_SIZE);
|
mainWindowController.setSize(FONT_SIZE);
|
||||||
mainWindowController.setAutoUpdate(false);
|
mainWindowController.setAutoUpdate(false);
|
||||||
mainWindowController.setLocal(local);
|
mainWindowController.setLocal(local);
|
||||||
mainWindowController.setMode(mode);
|
|
||||||
mainWindowController.saveSettings();
|
mainWindowController.saveSettings();
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); // start again (preventing Bugs) TODO is this really needed
|
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); // start again (preventing Bugs) TODO is this really needed
|
||||||
|
|
|
@ -37,8 +37,6 @@ import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -145,9 +143,6 @@ public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton settingsBtn;
|
private JFXButton settingsBtn;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private JFXButton switchBtn;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton debugBtn;
|
private JFXButton debugBtn;
|
||||||
|
|
||||||
|
@ -237,25 +232,22 @@ public class MainWindowController {
|
||||||
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
|
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
|
||||||
private int hashA = -647380320;
|
private int hashA = -647380320;
|
||||||
|
|
||||||
private String version = "0.5.2";
|
private String version = "0.5.99";
|
||||||
private String buildNumber = "131";
|
private String buildNumber = "137";
|
||||||
private String versionName = "solidify cow";
|
private String versionName = "solidify cow";
|
||||||
private String dialogBtnStyle;
|
private String dialogBtnStyle;
|
||||||
|
private String color;
|
||||||
|
private String title;
|
||||||
|
private String streamUrl;
|
||||||
|
private String ratingSortType;
|
||||||
|
private String local;
|
||||||
|
|
||||||
// text strings
|
// text strings
|
||||||
private String errorPlay;
|
private String errorPlay;
|
||||||
private String errorOpenStream;
|
|
||||||
private String errorLoad;
|
private String errorLoad;
|
||||||
private String errorSave;
|
private String errorSave;
|
||||||
private String infoText;
|
private String infoText;
|
||||||
private String vlcNotInstalled;
|
private String vlcNotInstalled;
|
||||||
private String streamingPath;
|
|
||||||
private String color;
|
|
||||||
private String title;
|
|
||||||
private String streamUrl;
|
|
||||||
private String mode;
|
|
||||||
private String ratingSortType;
|
|
||||||
private String local;
|
|
||||||
|
|
||||||
public double size;
|
public double size;
|
||||||
private int last;
|
private int last;
|
||||||
|
@ -267,7 +259,6 @@ public class MainWindowController {
|
||||||
private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)");
|
private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)");
|
||||||
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
|
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
|
||||||
private ObservableList<FilmTabelDataType> localFilms = FXCollections.observableArrayList();
|
private ObservableList<FilmTabelDataType> localFilms = FXCollections.observableArrayList();
|
||||||
private ObservableList<FilmTabelDataType> streamingFilms = FXCollections.observableArrayList();
|
|
||||||
private ObservableList<SourceDataType> sourcesList = FXCollections.observableArrayList();
|
private ObservableList<SourceDataType> sourcesList = FXCollections.observableArrayList();
|
||||||
private ImageView skip_previous_white = new ImageView(new Image("icons/ic_skip_previous_white_18dp_1x.png"));
|
private ImageView skip_previous_white = new ImageView(new Image("icons/ic_skip_previous_white_18dp_1x.png"));
|
||||||
private ImageView skip_previous_black = new ImageView(new Image("icons/ic_skip_previous_black_18dp_1x.png"));
|
private ImageView skip_previous_black = new ImageView(new Image("icons/ic_skip_previous_black_18dp_1x.png"));
|
||||||
|
@ -309,6 +300,10 @@ public class MainWindowController {
|
||||||
|
|
||||||
// film Table
|
// film Table
|
||||||
columnStreamUrl.setMaxWidth(0);
|
columnStreamUrl.setMaxWidth(0);
|
||||||
|
columnTitle.setMaxWidth(215);
|
||||||
|
columnRating.setMaxWidth(60);
|
||||||
|
columnSeason.setMaxWidth(55);
|
||||||
|
columnEpisode.setMaxWidth(64);
|
||||||
columnRating.setStyle("-fx-alignment: CENTER;");
|
columnRating.setStyle("-fx-alignment: CENTER;");
|
||||||
|
|
||||||
treeTableViewfilm.setRoot(filmRoot);
|
treeTableViewfilm.setRoot(filmRoot);
|
||||||
|
@ -323,12 +318,12 @@ public class MainWindowController {
|
||||||
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
|
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
|
||||||
|
|
||||||
// add columns to treeTableViewfilm
|
// add columns to treeTableViewfilm
|
||||||
|
treeTableViewfilm.getColumns().add(columnStreamUrl);
|
||||||
treeTableViewfilm.getColumns().add(columnTitle);
|
treeTableViewfilm.getColumns().add(columnTitle);
|
||||||
treeTableViewfilm.getColumns().add(columnRating);
|
treeTableViewfilm.getColumns().add(columnRating);
|
||||||
treeTableViewfilm.getColumns().add(columnStreamUrl);
|
|
||||||
treeTableViewfilm.getColumns().add(columnSeason);
|
treeTableViewfilm.getColumns().add(columnSeason);
|
||||||
treeTableViewfilm.getColumns().add(columnEpisode);
|
treeTableViewfilm.getColumns().add(columnEpisode);
|
||||||
treeTableViewfilm.getColumns().get(2).setVisible(false); //hide columnStreamUrl (column with file URL, important for opening a file/stream)
|
treeTableViewfilm.getColumns().get(0).setVisible(false); //hide columnStreamUrl (column with file URL, important for opening a file/stream)
|
||||||
|
|
||||||
// context menu for treeTableViewfilm
|
// context menu for treeTableViewfilm
|
||||||
treeTableViewfilm.setContextMenu(menu);
|
treeTableViewfilm.setContextMenu(menu);
|
||||||
|
@ -369,11 +364,8 @@ public class MainWindowController {
|
||||||
filterData.removeAll(filterData);
|
filterData.removeAll(filterData);
|
||||||
filmRoot.getChildren().removeAll(filmRoot.getChildren());
|
filmRoot.getChildren().removeAll(filmRoot.getChildren());
|
||||||
|
|
||||||
if (mode.equals("local")) {
|
helpData = localFilms;
|
||||||
helpData = localFilms;
|
|
||||||
} else {
|
|
||||||
helpData = streamingFilms;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < helpData.size(); i++) {
|
for (int i = 0; i < helpData.size(); i++) {
|
||||||
if (helpData.get(i).getTitle().toLowerCase().contains(searchTextField.getText().toLowerCase())) {
|
if (helpData.get(i).getTitle().toLowerCase().contains(searchTextField.getText().toLowerCase())) {
|
||||||
|
@ -458,11 +450,7 @@ public class MainWindowController {
|
||||||
// treeTableViewfilm.getSelectionModel().clearSelection(selected);
|
// treeTableViewfilm.getSelectionModel().clearSelection(selected);
|
||||||
filmRoot.getChildren().removeAll(filmRoot.getChildren());
|
filmRoot.getChildren().removeAll(filmRoot.getChildren());
|
||||||
|
|
||||||
if (mode.equals("local")) {
|
helpData = localFilms;
|
||||||
helpData = localFilms;
|
|
||||||
} else {
|
|
||||||
helpData = streamingFilms;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < helpData.size(); i++) {
|
for (int i = 0; i < helpData.size(); i++) {
|
||||||
if (helpData.get(i).getRating() == 1.0) {
|
if (helpData.get(i).getRating() == 1.0) {
|
||||||
|
@ -508,20 +496,11 @@ public class MainWindowController {
|
||||||
title = columnTitle.getCellData(selected); // get name of selected item
|
title = columnTitle.getCellData(selected); // get name of selected item
|
||||||
streamUrl = columnStreamUrl.getCellData(selected); // get file path of selected item
|
streamUrl = columnStreamUrl.getCellData(selected); // get file path of selected item
|
||||||
|
|
||||||
if (mode.equals("local")) {
|
if (localFilms.get(selected).getCached() == true) {
|
||||||
if (localFilms.get(selected).getCached() == true) {
|
LOGGER.info("loading from cache: " + title);
|
||||||
LOGGER.info("loading from cache: " + title);
|
dbController.readCache(streamUrl);
|
||||||
dbController.readCache(streamUrl);
|
|
||||||
} else {
|
|
||||||
ApiQuery.startQuery(title, streamUrl); // start api query
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (streamingFilms.get(selected).getCached() == true) {
|
ApiQuery.startQuery(title, streamUrl); // start api query
|
||||||
LOGGER.info("loading from cache: " + title);
|
|
||||||
dbController.readCache(streamUrl);
|
|
||||||
} else {
|
|
||||||
ApiQuery.startQuery(title, streamUrl); // start api query
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -529,7 +508,6 @@ public class MainWindowController {
|
||||||
|
|
||||||
// initialize UI elements
|
// initialize UI elements
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
LOGGER.info("Mode: " + mode); // TODO debugging
|
|
||||||
debugBtn.setDisable(true); // debugging button for tests
|
debugBtn.setDisable(true); // debugging button for tests
|
||||||
debugBtn.setVisible(false);
|
debugBtn.setVisible(false);
|
||||||
|
|
||||||
|
@ -554,55 +532,42 @@ public class MainWindowController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void playbtnclicked() {
|
private void playbtnclicked() {
|
||||||
// TODO open streams with desktop player, works at least with vlc under linux, part of #19
|
// TODO rework when #19 is coming
|
||||||
if (mode.equals("streaming")) {
|
|
||||||
if (Desktop.isDesktopSupported()) {
|
if (System.getProperty("os.name").contains("Linux")) {
|
||||||
new Thread(() -> {
|
String line;
|
||||||
try {
|
String output = "";
|
||||||
Desktop.getDesktop().browse(new URI(streamUrl)); //open the streaming URL in browser
|
Process p;
|
||||||
} catch (IOException | URISyntaxException e) {
|
try {
|
||||||
e.printStackTrace();
|
p = Runtime.getRuntime().exec("which vlc");
|
||||||
showErrorMsg(errorOpenStream, (IOException) e);
|
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||||
}
|
while ((line = input.readLine()) != null) {
|
||||||
}).start();
|
output = line;
|
||||||
} else {
|
}
|
||||||
LOGGER.info("Desktop not supported");
|
LOGGER.info(output);
|
||||||
|
input.close();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}else {
|
if (output.contains("which: no vlc") || output == "") {
|
||||||
if(System.getProperty("os.name").contains("Linux")){
|
JFXInfoDialog vlcInfoDialog = new JFXInfoDialog("Info", vlcNotInstalled, dialogBtnStyle, 350, 200, main.getPane());
|
||||||
String line;
|
vlcInfoDialog.show();
|
||||||
String output = "";
|
|
||||||
Process p;
|
|
||||||
try {
|
|
||||||
p = Runtime.getRuntime().exec("which vlc");
|
|
||||||
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
||||||
while ((line = input.readLine()) != null) {
|
|
||||||
output = line;
|
|
||||||
}
|
|
||||||
LOGGER.info(output);
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
if(output.contains("which: no vlc")||output == ""){
|
|
||||||
JFXInfoDialog vlcInfoDialog = new JFXInfoDialog("Info", vlcNotInstalled, dialogBtnStyle, 350, 200, main.getPane());
|
|
||||||
vlcInfoDialog.show();
|
|
||||||
}else{
|
|
||||||
try {
|
|
||||||
Runtime.getRuntime().exec(new String[] { "vlc", streamUrl}); // TODO switch to ProcessBuilder
|
|
||||||
} catch (IOException e) {
|
|
||||||
showErrorMsg(errorPlay,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){
|
|
||||||
try {
|
|
||||||
Desktop.getDesktop().open(new File(streamUrl));
|
|
||||||
} catch (IOException e) {
|
|
||||||
showErrorMsg(errorPlay,e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error(System.getProperty("os.name") + ", OS is not supported, please contact a developer! ");
|
try {
|
||||||
}
|
Runtime.getRuntime().exec(new String[] { "vlc", streamUrl }); // TODO switch to ProcessBuilder
|
||||||
|
} catch (IOException e) {
|
||||||
|
showErrorMsg(errorPlay, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")) {
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().open(new File(streamUrl));
|
||||||
|
} catch (IOException e) {
|
||||||
|
showErrorMsg(errorPlay, e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOGGER.error(System.getProperty("os.name") + ", OS is not supported, please contact a developer! ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,24 +613,6 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void switchBtnclicked(){
|
|
||||||
if(mode.equals("local")){ //switch to streaming mode
|
|
||||||
setMode("streaming");
|
|
||||||
switchBtn.setText("local");
|
|
||||||
}else if(mode.equals("streaming")){ //switch to local mode
|
|
||||||
setMode("local");
|
|
||||||
switchBtn.setText("streaming");
|
|
||||||
}
|
|
||||||
saveSettings();
|
|
||||||
filmRoot.getChildren().removeAll(filmRoot.getChildren());
|
|
||||||
addDataUI();
|
|
||||||
settingsScrollPane.setVisible(false);
|
|
||||||
sideMenuSlideOut(); //disables side-menu
|
|
||||||
menuTrue = false;
|
|
||||||
settingsTrue = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void debugBtnclicked(){
|
private void debugBtnclicked(){
|
||||||
//for testing
|
//for testing
|
||||||
|
@ -721,57 +668,35 @@ public class MainWindowController {
|
||||||
|
|
||||||
// refresh the selected child of the root node
|
// refresh the selected child of the root node
|
||||||
private void refreshTable() {
|
private void refreshTable() {
|
||||||
if (mode.equals("local")) {
|
filmRoot.getChildren().get(selected).setValue(localFilms.get(selected));
|
||||||
filmRoot.getChildren().get(selected).setValue(localFilms.get(selected));
|
|
||||||
} else {
|
|
||||||
filmRoot.getChildren().get(selected).setValue(streamingFilms.get(selected));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rework
|
// TODO rework
|
||||||
public void addDataUI() {
|
public void addDataUI() {
|
||||||
|
|
||||||
if (mode.equals("local")) {
|
for (FilmTabelDataType element : localFilms) {
|
||||||
for (FilmTabelDataType element : localFilms) {
|
if (element.getSeason() != 0) {
|
||||||
if (element.getSeason() != 0) {
|
// System.out.println("Found Series: " + element.getTitle());
|
||||||
// System.out.println("Found Series: " + element.getTitle());
|
// check if there is a series node to add the item
|
||||||
// check if there is a series node to add the item
|
for (int i = 0; i < filmRoot.getChildren().size(); i++) {
|
||||||
|
if (filmRoot.getChildren().get(i).getValue().getTitle().equals(element.getTitle())) {
|
||||||
for (int i = 0; i < filmRoot.getChildren().size(); i++) {
|
// System.out.println("Found a root node to add child");
|
||||||
if (filmRoot.getChildren().get(i).getValue().getTitle().equals(element.getTitle())) {
|
// System.out.println("Adding: " + element.getStreamUrl());
|
||||||
// System.out.println("Found a root node to add child");
|
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
|
||||||
// System.out.println("Adding: " + element.getStreamUrl());
|
element.getTitle(), element.getSeason(), element.getEpisode(), element.getRating(),
|
||||||
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
|
element.getCached(), element.getImage()));
|
||||||
element.getTitle(), element.getSeason(), element.getEpisode(), element.getRating(),
|
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
|
||||||
element.getCached(), element.getImage()));
|
} else if (i == filmRoot.getChildren().size() - 1) {
|
||||||
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
|
// System.out.println("Create a root node to add child");
|
||||||
} else if (i == filmRoot.getChildren().size() - 1) {
|
// System.out.println("Adding: " + element.getStreamUrl());
|
||||||
// System.out.println("Create a root node to add child");
|
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
|
||||||
// System.out.println("Adding: " + element.getStreamUrl());
|
element.getTitle(), 0, 0, element.getRating(), element.getCached(), element.getImage()));
|
||||||
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
|
filmRoot.getChildren().add(seriesRootNode);
|
||||||
element.getTitle(), 0, 0, element.getRating(), element.getCached(), element.getImage()));
|
|
||||||
filmRoot.getChildren().add(seriesRootNode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(element)); // add data to root-node
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(element)); // add data to root-node
|
||||||
}
|
}
|
||||||
|
|
||||||
columnRating.setMaxWidth(85);
|
|
||||||
columnTitle.setMaxWidth(290);
|
|
||||||
treeTableViewfilm.getColumns().get(3).setVisible(false);
|
|
||||||
treeTableViewfilm.getColumns().get(4).setVisible(false);
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < streamingFilms.size(); i++) {
|
|
||||||
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(streamingFilms.get(i))); // add data to root-node
|
|
||||||
}
|
|
||||||
columnTitle.setMaxWidth(215);
|
|
||||||
columnRating.setMaxWidth(60);
|
|
||||||
columnSeason.setMaxWidth(55);
|
|
||||||
columnEpisode.setMaxWidth(64);
|
|
||||||
treeTableViewfilm.getColumns().get(3).setVisible(true);
|
|
||||||
treeTableViewfilm.getColumns().get(4).setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +741,6 @@ public class MainWindowController {
|
||||||
if (icolor.compareTo(ccolor) == -1) {
|
if (icolor.compareTo(ccolor) == -1) {
|
||||||
dialogBtnStyle = btnStyleWhite;
|
dialogBtnStyle = btnStyleWhite;
|
||||||
settingsBtn.setStyle("-fx-text-fill: WHITE;");
|
settingsBtn.setStyle("-fx-text-fill: WHITE;");
|
||||||
switchBtn.setStyle("-fx-text-fill: WHITE;");
|
|
||||||
aboutBtn.setStyle("-fx-text-fill: WHITE;");
|
aboutBtn.setStyle("-fx-text-fill: WHITE;");
|
||||||
debugBtn.setStyle("-fx-text-fill: WHITE;");
|
debugBtn.setStyle("-fx-text-fill: WHITE;");
|
||||||
addDirectoryBtn.setStyle(btnStyleWhite);
|
addDirectoryBtn.setStyle(btnStyleWhite);
|
||||||
|
@ -833,7 +757,6 @@ public class MainWindowController {
|
||||||
} else {
|
} else {
|
||||||
dialogBtnStyle = btnStyleBlack;
|
dialogBtnStyle = btnStyleBlack;
|
||||||
settingsBtn.setStyle("-fx-text-fill: BLACK;");
|
settingsBtn.setStyle("-fx-text-fill: BLACK;");
|
||||||
switchBtn.setStyle("-fx-text-fill: BLACK;");
|
|
||||||
aboutBtn.setStyle("-fx-text-fill: BLACK;");
|
aboutBtn.setStyle("-fx-text-fill: BLACK;");
|
||||||
debugBtn.setStyle("-fx-text-fill: BLACK;");
|
debugBtn.setStyle("-fx-text-fill: BLACK;");
|
||||||
addDirectoryBtn.setStyle(btnStyleBlack);
|
addDirectoryBtn.setStyle(btnStyleBlack);
|
||||||
|
@ -848,12 +771,6 @@ public class MainWindowController {
|
||||||
forwardBtn.setGraphic(skip_next_black);
|
forwardBtn.setGraphic(skip_next_black);
|
||||||
menuHam.getStyleClass().add("jfx-hamburgerB");
|
menuHam.getStyleClass().add("jfx-hamburgerB");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.equals("local")) {
|
|
||||||
switchBtn.setText("streaming");
|
|
||||||
} else if (mode.equals("streaming")) {
|
|
||||||
switchBtn.setText("local");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// slide in in 400ms
|
// slide in in 400ms
|
||||||
|
@ -906,7 +823,6 @@ public class MainWindowController {
|
||||||
columnStreamUrl.setText(getBundle().getString("columnStreamUrl"));
|
columnStreamUrl.setText(getBundle().getString("columnStreamUrl"));
|
||||||
columnSeason.setText(getBundle().getString("columnSeason"));
|
columnSeason.setText(getBundle().getString("columnSeason"));
|
||||||
errorPlay = getBundle().getString("errorPlay");
|
errorPlay = getBundle().getString("errorPlay");
|
||||||
errorOpenStream = getBundle().getString("errorOpenStream");
|
|
||||||
errorLoad = getBundle().getString("errorLoad");
|
errorLoad = getBundle().getString("errorLoad");
|
||||||
errorSave = getBundle().getString("errorSave");
|
errorSave = getBundle().getString("errorSave");
|
||||||
infoText = getBundle().getString("infoText");
|
infoText = getBundle().getString("infoText");
|
||||||
|
@ -955,8 +871,6 @@ public class MainWindowController {
|
||||||
props.setProperty("useBeta", String.valueOf(isUseBeta()));
|
props.setProperty("useBeta", String.valueOf(isUseBeta()));
|
||||||
props.setProperty("size", getSize().toString());
|
props.setProperty("size", getSize().toString());
|
||||||
props.setProperty("local", getLocal());
|
props.setProperty("local", getLocal());
|
||||||
props.setProperty("streamingPath", getStreamingPath());
|
|
||||||
props.setProperty("mode", getMode());
|
|
||||||
props.setProperty("ratingSortType", columnRating.getSortType().toString());
|
props.setProperty("ratingSortType", columnRating.getSortType().toString());
|
||||||
|
|
||||||
OutputStream outputStream = new FileOutputStream(main.getConfigFile()); // new output-stream
|
OutputStream outputStream = new FileOutputStream(main.getConfigFile()); // new output-stream
|
||||||
|
@ -975,13 +889,6 @@ public class MainWindowController {
|
||||||
InputStream inputStream = new FileInputStream(main.getConfigFile());
|
InputStream inputStream = new FileInputStream(main.getConfigFile());
|
||||||
props.loadFromXML(inputStream); // new input-stream from .xml
|
props.loadFromXML(inputStream); // new input-stream from .xml
|
||||||
|
|
||||||
try {
|
|
||||||
setStreamingPath(props.getProperty("streamingPath"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("cloud not load streamingPath", e);
|
|
||||||
setStreamingPath("");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setColor(props.getProperty("color"));
|
setColor(props.getProperty("color"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1024,23 +931,6 @@ public class MainWindowController {
|
||||||
setRatingSortType("");
|
setRatingSortType("");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
switch (props.getProperty("mode")) {
|
|
||||||
case "local":
|
|
||||||
setMode("local");
|
|
||||||
break;
|
|
||||||
case "streaming":
|
|
||||||
setMode("streaming");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setMode("local");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
setMode("local");
|
|
||||||
LOGGER.error("cloud not load mode", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error(errorSave, e);
|
LOGGER.error(errorSave, e);
|
||||||
|
@ -1081,14 +971,6 @@ public class MainWindowController {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamingPath(String input) {
|
|
||||||
this.streamingPath = input;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStreamingPath() {
|
|
||||||
return streamingPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSize(Double input) {
|
public void setSize(Double input) {
|
||||||
this.size = input;
|
this.size = input;
|
||||||
}
|
}
|
||||||
|
@ -1121,14 +1003,6 @@ public class MainWindowController {
|
||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMode(String input) {
|
|
||||||
this.mode = input;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMode() {
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableList<FilmTabelDataType> getLocalFilms() {
|
public ObservableList<FilmTabelDataType> getLocalFilms() {
|
||||||
return localFilms;
|
return localFilms;
|
||||||
}
|
}
|
||||||
|
@ -1137,14 +1011,6 @@ public class MainWindowController {
|
||||||
this.localFilms = localFilms;
|
this.localFilms = localFilms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<FilmTabelDataType> getStreamingFilms() {
|
|
||||||
return streamingFilms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStreamingFilms(ObservableList<FilmTabelDataType> streamingFilms) {
|
|
||||||
this.streamingFilms = streamingFilms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableList<SourceDataType> getSourcesList() {
|
public ObservableList<SourceDataType> getSourcesList() {
|
||||||
return sourcesList;
|
return sourcesList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,8 @@ public class DBController {
|
||||||
private Image favorite_black = new Image("icons/ic_favorite_black_18dp_1x.png");
|
private Image favorite_black = new Image("icons/ic_favorite_black_18dp_1x.png");
|
||||||
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>();
|
||||||
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> filmsStreamURL = new ArrayList<String>(); // needed
|
private List<String> filmsStreamURL = new ArrayList<String>(); // needed
|
||||||
private Connection connection = null;
|
private Connection connection = null;
|
||||||
private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName());
|
private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName());
|
||||||
|
@ -100,9 +99,7 @@ public class DBController {
|
||||||
private void createDatabase() {
|
private void createDatabase() {
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
// TODO use only one table
|
stmt.executeUpdate("create table if not exists films (streamUrl, title, season, episode, rating, cached)");
|
||||||
stmt.executeUpdate("create table if not exists film_loc (streamUrl, title, season, episode, rating, cached)");
|
|
||||||
stmt.executeUpdate("create table if not exists film_str (streamUrl, title, season, episode, rating, cached)");
|
|
||||||
stmt.executeUpdate("create table if not exists cache ("
|
stmt.executeUpdate("create table if not exists cache ("
|
||||||
+ "streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer,"
|
+ "streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer,"
|
||||||
+ " Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes,"
|
+ " Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes,"
|
||||||
|
@ -114,33 +111,24 @@ public class DBController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDatabase() {
|
private void loadDatabase() {
|
||||||
|
// get all entries from the table
|
||||||
// get all entries from the tables
|
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_loc");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM films");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
filmsdbDir.add(rs.getString("title"));
|
filmsdbDir.add(rs.getString("title"));
|
||||||
filmsdbStreamURL.add(rs.getString("streamUrl"));
|
filmsdbStreamURL.add(rs.getString("streamUrl"));
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
rs = stmt.executeQuery("SELECT * FROM film_str;");
|
|
||||||
while (rs.next()) {
|
|
||||||
filmsdbAll.add(rs.getString("title"));
|
|
||||||
filmsdbStreamURL.add(rs.getString("streamUrl"));
|
|
||||||
}
|
|
||||||
stmt.close();
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Ups! an error occured!", e);
|
LOGGER.error("Ups! an error occured!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all entries to filmsAll and filmsdbAl, for later comparing
|
// add all entries to filmsAll and filmsdbAl, for later comparing
|
||||||
filmsdbAll.addAll(filmsdbDir);
|
filmsdbAll.addAll(filmsdbDir);
|
||||||
LOGGER.info("films in directory: " + filmsAll.size());
|
LOGGER.info("films in directory: " + filmsStreamURL.size());
|
||||||
LOGGER.info("filme in db: " + filmsdbAll.size());
|
LOGGER.info("filme in db: " + filmsdbStreamURL.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the sources from sources.json
|
// load the sources from sources.json
|
||||||
|
@ -156,22 +144,30 @@ public class DBController {
|
||||||
String mode = source.asObject().getString("mode", "");
|
String mode = source.asObject().getString("mode", "");
|
||||||
mainWindowController.addSourceToTable(path, mode); // add source to source-table
|
mainWindowController.addSourceToTable(path, mode); // add source to source-table
|
||||||
if (mode.equals("local")) {
|
if (mode.equals("local")) {
|
||||||
// getting all files from the selected directory
|
for (File file : new File(path).listFiles()) {
|
||||||
if (new File(path).exists()) {
|
if (file.isFile()) {
|
||||||
for (String entry : new File(path).list()) {
|
// get all files (films)
|
||||||
filmsAll.add(cutOffEnd(entry));
|
filmsStreamURL.add(file.getPath());
|
||||||
|
} else {
|
||||||
|
// get all folders (series)
|
||||||
|
for (File season : file.listFiles()) {
|
||||||
|
if (season.isDirectory()) {
|
||||||
|
for (File episode : season.listFiles()) {
|
||||||
|
if (!filmsdbStreamURL.contains(episode.getPath())) {
|
||||||
|
filmsStreamURL.add(episode.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LOGGER.info("added files from: " + path);
|
|
||||||
} else {
|
|
||||||
LOGGER.error(path + "dosen't exist!");
|
|
||||||
}
|
}
|
||||||
|
LOGGER.info("added files from: " + path);
|
||||||
} else {
|
} else {
|
||||||
// getting all entries from the streaming lists
|
// getting all entries from the streaming lists
|
||||||
try {
|
try {
|
||||||
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) {
|
||||||
filmsAll.add(item.asObject().getString("title", ""));
|
|
||||||
filmsStreamURL.add(item.asObject().getString("streamUrl", ""));
|
filmsStreamURL.add(item.asObject().getString("streamUrl", ""));
|
||||||
}
|
}
|
||||||
LOGGER.info("added films from: " + path);
|
LOGGER.info("added films from: " + path);
|
||||||
|
@ -191,7 +187,7 @@ public class DBController {
|
||||||
try {
|
try {
|
||||||
//load local Data
|
//load local Data
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_loc ORDER BY title");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM films ORDER BY title");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
if (rs.getInt("rating") == 1) {
|
if (rs.getInt("rating") == 1) {
|
||||||
mainWindowController.getLocalFilms().add(new FilmTabelDataType(rs.getString("streamUrl"),
|
mainWindowController.getLocalFilms().add(new FilmTabelDataType(rs.getString("streamUrl"),
|
||||||
|
@ -204,23 +200,7 @@ public class DBController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
//load streaming Data
|
|
||||||
rs = stmt.executeQuery("SELECT * FROM film_str ORDER BY title;");
|
|
||||||
while (rs.next()) {
|
|
||||||
if (rs.getInt("rating") == 1) {
|
|
||||||
mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getString("streamUrl"),
|
|
||||||
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
|
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_black)));
|
|
||||||
} else {
|
|
||||||
mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getString("streamUrl"),
|
|
||||||
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
|
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stmt.close();
|
|
||||||
rs.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Ups! an error occured!", e);
|
LOGGER.error("Ups! an error occured!", e);
|
||||||
}
|
}
|
||||||
|
@ -238,32 +218,18 @@ public class DBController {
|
||||||
LOGGER.info("refresh ...");
|
LOGGER.info("refresh ...");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE streamUrl = \"" + streamUrl + "\";");
|
||||||
|
|
||||||
if (mainWindowController.getMode().equals("local")) {
|
if (rs.getInt("rating") == 1) {
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_loc WHERE streamUrl = \"" + streamUrl + "\";");
|
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
|
||||||
if (rs.getInt("rating") == 1) {
|
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
|
||||||
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
|
rs.getBoolean("cached"), new ImageView(favorite_black)));
|
||||||
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
|
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_black)));
|
|
||||||
} else {
|
|
||||||
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
|
|
||||||
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
|
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
} else {
|
} else {
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_str WHERE streamUrl = \"" + streamUrl + "\";");
|
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
|
||||||
if (rs.getInt("rating") == 1) {
|
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
|
||||||
mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
|
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
|
||||||
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
|
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_black)));
|
|
||||||
} else {
|
|
||||||
mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getString("streamUrl"),
|
|
||||||
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
|
|
||||||
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
}
|
}
|
||||||
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Ups! error while refreshing mwc!", e);
|
LOGGER.error("Ups! error while refreshing mwc!", e);
|
||||||
|
@ -282,7 +248,6 @@ public class DBController {
|
||||||
filmsdbAll.removeAll(filmsdbAll);
|
filmsdbAll.removeAll(filmsdbAll);
|
||||||
filmsdbDir.removeAll(filmsdbDir);
|
filmsdbDir.removeAll(filmsdbDir);
|
||||||
filmsdbStreamURL.removeAll(filmsdbStreamURL);
|
filmsdbStreamURL.removeAll(filmsdbStreamURL);
|
||||||
filmsAll.removeAll(filmsAll);
|
|
||||||
filmsStreamURL.removeAll(filmsStreamURL);
|
filmsStreamURL.removeAll(filmsStreamURL);
|
||||||
|
|
||||||
loadSources(); // reload all sources
|
loadSources(); // reload all sources
|
||||||
|
@ -291,46 +256,37 @@ public class DBController {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
checkAddEntry();
|
checkAddEntry();
|
||||||
// checkRemoveEntry();
|
checkRemoveEntry();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while refreshing the database", e);
|
LOGGER.error("Error while refreshing the database", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all films from the mwc lists
|
// remove all films from the mwc lists
|
||||||
mainWindowController.getLocalFilms().removeAll(mainWindowController.getLocalFilms());
|
mainWindowController.getLocalFilms().removeAll(mainWindowController.getLocalFilms());
|
||||||
mainWindowController.getStreamingFilms().removeAll(mainWindowController.getStreamingFilms());
|
|
||||||
mainWindowController.getFilmRoot().getChildren().removeAll(mainWindowController.getFilmRoot().getChildren());
|
mainWindowController.getFilmRoot().getChildren().removeAll(mainWindowController.getFilmRoot().getChildren());
|
||||||
|
|
||||||
loadDataToMWC(); // load the new data to the mwc
|
loadDataToMWC(); // load the new data to the mwc
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO needs reworking currently broken
|
|
||||||
* check if there are any entries that have been removed from the film-directory
|
* check if there are any entries that have been removed from the film-directory
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private void checkRemoveEntry() {
|
private void checkRemoveEntry() {
|
||||||
LOGGER.info("checking for entrys to remove to DB ...");
|
LOGGER.info("checking for entrys to remove to DB ...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
|
|
||||||
for (String entry : filmsdbDir) {
|
|
||||||
if (!filmsAll.contains(entry)) {
|
|
||||||
stmt.executeUpdate("delete from film_loc where title = \"" + entry + "\"");
|
|
||||||
connection.commit();
|
|
||||||
LOGGER.info("removed \"" + entry + "\" from loc database");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String entry : filmsdbStreamURL) {
|
for (String entry : filmsdbStreamURL) {
|
||||||
if (!filmsStreamURL.contains(entry)) {
|
if (!filmsStreamURL.contains(entry)) {
|
||||||
stmt.executeUpdate("delete from film_str where streamUrl = \"" + entry + "\"");
|
System.out.println(filmsdbStreamURL + "\n");
|
||||||
|
System.out.println(filmsStreamURL);
|
||||||
|
stmt.executeUpdate("delete from films where streamUrl = \"" + entry + "\"");
|
||||||
connection.commit();
|
connection.commit();
|
||||||
LOGGER.info("removed \"" + entry + "\" from str database");
|
LOGGER.info("removed \"" + entry + "\" from database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
|
@ -345,7 +301,7 @@ public class DBController {
|
||||||
*/
|
*/
|
||||||
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException {
|
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
PreparedStatement ps = connection.prepareStatement("insert into film_str values (?, ?, ?, ?, ?, ?)");
|
PreparedStatement ps = connection.prepareStatement("insert into films values (?, ?, ?, ?, ?, ?)");
|
||||||
LOGGER.info("checking for entrys to add to DB ...");
|
LOGGER.info("checking for entrys to add to DB ...");
|
||||||
|
|
||||||
// source is a single source of the sources list
|
// source is a single source of the sources list
|
||||||
|
@ -357,13 +313,13 @@ public class DBController {
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
// get all files (films)
|
// get all files (films)
|
||||||
if (!filmsdbStreamURL.contains(file.getPath())) {
|
if (!filmsdbStreamURL.contains(file.getPath())) {
|
||||||
stmt.executeUpdate("insert into film_loc values ("
|
stmt.executeUpdate("insert into films values ("
|
||||||
+ "'" + file.getPath() + "',"
|
+ "'" + file.getPath() + "',"
|
||||||
+ "'" + cutOffEnd(file.getName()) + "', 0, 0, 0, 0)");
|
+ "'" + cutOffEnd(file.getName()) + "', 0, 0, 0, 0)");
|
||||||
connection.commit();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LOGGER.info("Added \"" + file.getName() + "\" to database");
|
LOGGER.info("Added \"" + file.getName() + "\" to database");
|
||||||
filmsAll.add(cutOffEnd(file.getName()));
|
filmsdbStreamURL.add(file.getPath());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// get all folders (series)
|
// get all folders (series)
|
||||||
|
@ -371,19 +327,15 @@ public class DBController {
|
||||||
for (File season : file.listFiles()) {
|
for (File season : file.listFiles()) {
|
||||||
if (season.isDirectory()) {
|
if (season.isDirectory()) {
|
||||||
int ep = 1;
|
int ep = 1;
|
||||||
LOGGER.info("Added \"" + file.getName() + "\", Season " + sn + " to database");
|
|
||||||
// System.out.println("Series name: " + file.getName() + " <=========");
|
|
||||||
// System.out.println("Season found: " + season + " <=========");
|
|
||||||
for (File episode : season.listFiles()) {
|
for (File episode : season.listFiles()) {
|
||||||
if (!filmsdbStreamURL.contains(episode.getPath())) {
|
if (!filmsdbStreamURL.contains(episode.getPath())) {
|
||||||
// System.out.println("Found episode: " + episode);
|
LOGGER.info("Added \"" + file.getName() + "\", Episode: " + episode.getName() + " to database");
|
||||||
// System.out.println("Season: " + sn + "; Episod: " + ep);
|
stmt.executeUpdate("insert into films values ("
|
||||||
|
|
||||||
stmt.executeUpdate("insert into film_loc values ("
|
|
||||||
+ "'" + episode.getPath() + "',"
|
+ "'" + episode.getPath() + "',"
|
||||||
+ "'" + cutOffEnd(file.getName()) + "',"+ sn + "," + ep + ", 0, 0)");
|
+ "'" + cutOffEnd(file.getName()) + "',"+ sn + "," + ep + ", 0, 0)");
|
||||||
connection.commit();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
filmsStreamURL.add(episode.getPath());
|
||||||
filmsdbStreamURL.add(episode.getPath());
|
filmsdbStreamURL.add(episode.getPath());
|
||||||
ep++;
|
ep++;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +366,7 @@ public class DBController {
|
||||||
ps.setBoolean(6, false);
|
ps.setBoolean(6, false);
|
||||||
ps.addBatch(); // adds the entry
|
ps.addBatch(); // adds the entry
|
||||||
LOGGER.info("Added \"" + title + "\" to database");
|
LOGGER.info("Added \"" + title + "\" to database");
|
||||||
filmsAll.add(cutOffEnd(title));
|
filmsdbStreamURL.add(streamUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +383,7 @@ public class DBController {
|
||||||
System.out.println("Outputting all entries ... \n");
|
System.out.println("Outputting all entries ... \n");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_loc");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM films");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
System.out.println(rs.getString("streamUrl"));
|
System.out.println(rs.getString("streamUrl"));
|
||||||
System.out.println(rs.getString("title"));
|
System.out.println(rs.getString("title"));
|
||||||
|
@ -442,21 +394,6 @@ public class DBController {
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
System.out.println("Streaming Entries: \n");
|
|
||||||
|
|
||||||
rs = stmt.executeQuery("SELECT * FROM film_str;");
|
|
||||||
while (rs.next()) {
|
|
||||||
System.out.println(rs.getString("streamUrl"));
|
|
||||||
System.out.println(rs.getString("title"));
|
|
||||||
System.out.println(rs.getString("season"));
|
|
||||||
System.out.println(rs.getString("episode"));
|
|
||||||
System.out.println(rs.getString("rating"));
|
|
||||||
System.out.println(rs.getString("cached") + "\n");
|
|
||||||
}
|
|
||||||
stmt.close();
|
|
||||||
rs.close();
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("An error occured, while printing all entries", e);
|
LOGGER.error("An error occured, while printing all entries", e);
|
||||||
}
|
}
|
||||||
|
@ -471,11 +408,7 @@ public class DBController {
|
||||||
LOGGER.info("dislike " + streamUrl);
|
LOGGER.info("dislike " + streamUrl);
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
if (mainWindowController.getMode().equals("local")) {
|
stmt.executeUpdate("UPDATE films SET rating=0 WHERE streamUrl=\"" + streamUrl + "\";");
|
||||||
stmt.executeUpdate("UPDATE film_loc SET rating=0 WHERE streamUrl=\"" + streamUrl + "\";");
|
|
||||||
} else {
|
|
||||||
stmt.executeUpdate("UPDATE film_str SET rating=0 WHERE streamUrl=\"" + streamUrl + "\";");
|
|
||||||
}
|
|
||||||
connection.commit();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -492,11 +425,7 @@ public class DBController {
|
||||||
LOGGER.info("like " + streamUrl);
|
LOGGER.info("like " + streamUrl);
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
if (mainWindowController.getMode().equals("local")) {
|
stmt.executeUpdate("UPDATE films SET rating=1 WHERE streamUrl=\"" + streamUrl + "\";");
|
||||||
stmt.executeUpdate("UPDATE film_loc SET rating=1 WHERE streamUrl=\"" + streamUrl + "\";");
|
|
||||||
} else {
|
|
||||||
stmt.executeUpdate("UPDATE film_str SET rating=1 WHERE streamUrl=\"" + streamUrl + "\";");
|
|
||||||
}
|
|
||||||
connection.commit();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -511,11 +440,7 @@ public class DBController {
|
||||||
void setCached(String streamUrl) {
|
void setCached(String streamUrl) {
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
if (mainWindowController.getMode().equals("local")) {
|
stmt.executeUpdate("UPDATE films SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";");
|
||||||
stmt.executeUpdate("UPDATE film_loc SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";");
|
|
||||||
} else {
|
|
||||||
stmt.executeUpdate("UPDATE film_str SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";");
|
|
||||||
}
|
|
||||||
connection.commit();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
|
@ -69,11 +69,6 @@
|
||||||
<Font name="System Bold" size="15.0" />
|
<Font name="System Bold" size="15.0" />
|
||||||
</font>
|
</font>
|
||||||
</JFXButton>
|
</JFXButton>
|
||||||
<JFXButton fx:id="switchBtn" onAction="#switchBtnclicked" prefHeight="32.0" prefWidth="150.0" textAlignment="CENTER">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="15.0" />
|
|
||||||
</font>
|
|
||||||
</JFXButton>
|
|
||||||
<JFXButton fx:id="debugBtn" onAction="#debugBtnclicked" prefHeight="32.0" prefWidth="150.0" text="debugging" textAlignment="CENTER">
|
<JFXButton fx:id="debugBtn" onAction="#debugBtnclicked" prefHeight="32.0" prefWidth="150.0" text="debugging" textAlignment="CENTER">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="15.0" />
|
<Font name="System Bold" size="15.0" />
|
||||||
|
|
Loading…
Reference in New Issue