more code cleanup and bug fixes

* removed year and resolution from all tables as they're not used anywhere
* fixed a bug that caused issues, when refreshing streaming entres with the same title
* like, dislike are now based on the streamUrl insted of the title
* fixed a bug, that ocured when liking/disliking the last entry in the table
This commit is contained in:
Jannik 2018-03-05 22:37:32 +01:00
parent af343dea44
commit f27c3810ff
6 changed files with 320 additions and 322 deletions

View File

@ -39,7 +39,6 @@ import java.io.Writer;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
@ -99,7 +98,8 @@ import javafx.util.Duration;
import kellerkinder.HomeFlix.controller.DBController; import kellerkinder.HomeFlix.controller.DBController;
import kellerkinder.HomeFlix.controller.UpdateController; import kellerkinder.HomeFlix.controller.UpdateController;
import kellerkinder.HomeFlix.controller.apiQuery; import kellerkinder.HomeFlix.controller.apiQuery;
import kellerkinder.HomeFlix.datatypes.tableData; import kellerkinder.HomeFlix.datatypes.SourceDataType;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
public class MainWindowController { public class MainWindowController {
@ -119,10 +119,10 @@ public class MainWindowController {
private VBox sideMenuVBox; private VBox sideMenuVBox;
@FXML @FXML
private TreeTableView<tableData> treeTableViewfilm; private TreeTableView<FilmTabelDataType> treeTableViewfilm;
@FXML @FXML
private TableView<tableData> sourcesTable; private TableView<SourceDataType> sourcesTable;
@FXML @FXML
private TextFlow textFlow; private TextFlow textFlow;
@ -211,28 +211,24 @@ public class MainWindowController {
private ImageView imv1; private ImageView imv1;
@FXML @FXML
public TreeItem<tableData> root = new TreeItem<>(new tableData(1, 1, 1, 5.0, "1", "filme", "1", imv1, false)); private TreeItem<FilmTabelDataType> filmRoot = new TreeItem<>(new FilmTabelDataType(1, 1, 5.0, "filme", "1", imv1, false));
@FXML @FXML
TreeTableColumn<tableData, ImageView> columnRating = new TreeTableColumn<>("Rating"); TreeTableColumn<FilmTabelDataType, ImageView> columnRating = new TreeTableColumn<>("Rating");
@FXML @FXML
TreeTableColumn<tableData, String> columnTitel = new TreeTableColumn<>("Titel"); TreeTableColumn<FilmTabelDataType, String> columnTitel = new TreeTableColumn<>("Titel");
@FXML @FXML
TreeTableColumn<tableData, String> columnStreamUrl = new TreeTableColumn<>("File Name"); TreeTableColumn<FilmTabelDataType, String> columnStreamUrl = new TreeTableColumn<>("File Name");
@FXML @FXML
TreeTableColumn<tableData, String> columnResolution = new TreeTableColumn<>("Resolution"); TreeTableColumn<FilmTabelDataType, Integer> columnSeason = new TreeTableColumn<>("Season");
@FXML @FXML
TreeTableColumn<tableData, Integer> columnYear = new TreeTableColumn<>("Year"); TreeTableColumn<FilmTabelDataType, Integer> columnEpisode = new TreeTableColumn<>("Episode");
@FXML
TreeTableColumn<tableData, Integer> columnSeason = new TreeTableColumn<>("Season");
@FXML
TreeTableColumn<tableData, Integer> columnEpisode = new TreeTableColumn<>("Episode");
@FXML @FXML
public TreeItem<tableData> streamingRoot =new TreeItem<>(new tableData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1", imv1, false)); // TODO make private private TreeItem<SourceDataType> streamingRoot =new TreeItem<>(new SourceDataType("", ""));
@FXML @FXML
private TableColumn<tableData, String> sourceColumn; private TableColumn<SourceDataType, String> sourceColumn;
@FXML @FXML
private TableColumn<tableData, String> modeColumn; private TableColumn<SourceDataType, String> modeColumn;
private boolean menuTrue = false; private boolean menuTrue = false;
private boolean settingsTrue = false; private boolean settingsTrue = false;
@ -256,8 +252,8 @@ public class MainWindowController {
private String vlcNotInstalled; private String vlcNotInstalled;
private String streamingPath; private String streamingPath;
private String color; private String color;
private String name; private String title;
private String datPath; private String streamUrl;
private String mode; private String mode;
private String ratingSortType; private String ratingSortType;
private String local; private String local;
@ -268,12 +264,12 @@ public class MainWindowController {
private int next; private int next;
private ResourceBundle bundle; private ResourceBundle bundle;
private ObservableList<tableData> filterData = FXCollections.observableArrayList(); private ObservableList<FilmTabelDataType> filterData = FXCollections.observableArrayList();
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<tableData> localFilms = FXCollections.observableArrayList(); private ObservableList<FilmTabelDataType> localFilms = FXCollections.observableArrayList();
private ObservableList<tableData> streamingFilms = FXCollections.observableArrayList(); private ObservableList<FilmTabelDataType> streamingFilms = FXCollections.observableArrayList();
private ObservableList<tableData> 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"));
private ImageView skip_next_white = new ImageView(new Image("icons/ic_skip_next_white_18dp_1x.png")); private ImageView skip_next_white = new ImageView(new Image("icons/ic_skip_next_white_18dp_1x.png"));
@ -284,14 +280,15 @@ public class MainWindowController {
private MenuItem like = new MenuItem("like"); private MenuItem like = new MenuItem("like");
private MenuItem dislike = new MenuItem("dislike"); //TODO one option (like or dislike) private MenuItem dislike = new MenuItem("dislike"); //TODO one option (like or dislike)
private ContextMenu menu = new ContextMenu(like, dislike); private ContextMenu menu = new ContextMenu(like, dislike);
Properties props = new Properties(); private Properties props = new Properties();
private Main main; private Main main;
private UpdateController updateController; private UpdateController updateController;
private apiQuery ApiQuery; private apiQuery ApiQuery;
DBController dbController; DBController dbController;
/**"Main" Method called in Main.java main() when starting /**
* "Main" Method called in Main.java main() when starting
* Initialize other objects: Updater, dbController and ApiQuery * Initialize other objects: Updater, dbController and ApiQuery
*/ */
void setMain(Main main) { void setMain(Main main) {
@ -308,44 +305,38 @@ public class MainWindowController {
initUI(); initUI();
} }
//Initialize the tables (treeTableViewfilm and tableViewStreamingdata) // Initialize the tables (treeTableViewfilm and sourcesTable)
private void initTabel() { private void initTabel() {
//film Table // film Table
columnRating.setMaxWidth(80); columnStreamUrl.setMaxWidth(0);
columnTitel.setMaxWidth(260); columnRating.setStyle("-fx-alignment: CENTER;");
columnStreamUrl.setMaxWidth(0);
columnRating.setStyle("-fx-alignment: CENTER;");
treeTableViewfilm.setRoot(root);
treeTableViewfilm.setColumnResizePolicy( TreeTableView.CONSTRAINED_RESIZE_POLICY );
treeTableViewfilm.setShowRoot(false);
//write content into cell
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty());
columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty());
columnResolution.setCellValueFactory(cellData -> cellData.getValue().getValue().resolutionProperty());
columnYear.setCellValueFactory(cellData -> cellData.getValue().getValue().yearProperty().asObject());
columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject());
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
//add columns to treeTableViewfilm treeTableViewfilm.setRoot(filmRoot);
treeTableViewfilm.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
treeTableViewfilm.setShowRoot(false);
// write content into cell
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty());
columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty());
columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject());
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
// add columns to treeTableViewfilm
treeTableViewfilm.getColumns().add(columnTitel); treeTableViewfilm.getColumns().add(columnTitel);
treeTableViewfilm.getColumns().add(columnRating); treeTableViewfilm.getColumns().add(columnRating);
treeTableViewfilm.getColumns().add(columnStreamUrl); treeTableViewfilm.getColumns().add(columnStreamUrl);
treeTableViewfilm.getColumns().add(columnResolution);
treeTableViewfilm.getColumns().add(columnYear);
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(2).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);
// sourcesTreeTable // sourcesTreeTable
sourceColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty()); sourceColumn.setCellValueFactory(cellData -> cellData.getValue().pathProperty());
modeColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty()); modeColumn.setCellValueFactory(cellData -> cellData.getValue().modeProperty());
sourcesTable.setItems(sourcesList); sourcesTable.setItems(sourcesList);
} }
@ -375,9 +366,9 @@ public class MainWindowController {
searchTextField.textProperty().addListener(new ChangeListener<String>() { searchTextField.textProperty().addListener(new ChangeListener<String>() {
@Override @Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
ObservableList<tableData> helpData; ObservableList<FilmTabelDataType> helpData;
filterData.removeAll(filterData); filterData.removeAll(filterData);
root.getChildren().remove(0, root.getChildren().size()); filmRoot.getChildren().removeAll(filmRoot.getChildren());
if (mode.equals("local")) { if (mode.equals("local")) {
helpData = localFilms; helpData = localFilms;
@ -392,7 +383,7 @@ public class MainWindowController {
} }
for (int i = 0; i < filterData.size(); i++) { for (int i = 0; i < filterData.size(); i++) {
root.getChildren().add(new TreeItem<tableData>(filterData.get(i))); // add filtered data to root node after search filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(filterData.get(i))); // add filtered data to root node after search
} }
if (searchTextField.getText().hashCode() == hashA) { if (searchTextField.getText().hashCode() == hashA) {
setColor("000000"); setColor("000000");
@ -428,8 +419,8 @@ public class MainWindowController {
@Override @Override
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
setSize(fontsizeSlider.getValue()); setSize(fontsizeSlider.getValue());
if (name != null) { if (title != null) {
dbController.readCache(datPath); dbController.readCache(streamUrl);
} }
// ta1.setFont(Font.font("System", size)); // ta1.setFont(Font.font("System", size));
saveSettings(); saveSettings();
@ -439,17 +430,8 @@ public class MainWindowController {
like.setOnAction(new EventHandler<ActionEvent>() { like.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
if (mode.equals("streaming")) { dbController.like(streamUrl);
dbController.like(name, streamingFilms.get(selected).getStreamUrl()); dbController.refresh(streamUrl, selected);
} else {
dbController.like(name, localFilms.get(selected).getStreamUrl());
}
dbController.getFavStatus(name);
try {
dbController.refresh(name, selected);
} catch (SQLException e) {
LOGGER.error("(like-problem), it seems as a cat has stolen the \"like-methode\"!", e);
}
refreshTable(); refreshTable();
} }
}); });
@ -457,17 +439,8 @@ public class MainWindowController {
dislike.setOnAction(new EventHandler<ActionEvent>() { dislike.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
if (mode.equals("streaming")) { dbController.dislike(streamUrl);
dbController.dislike(name, streamingFilms.get(selected).getStreamUrl()); dbController.refresh(streamUrl, selected);
} else {
dbController.dislike(name, localFilms.get(selected).getStreamUrl());
}
dbController.getFavStatus(name);
try {
dbController.refresh(name, selected);
} catch (SQLException e) {
LOGGER.error("There was a problem with the like/dislike function!", e);
}
refreshTable(); refreshTable();
} }
}); });
@ -477,15 +450,14 @@ public class MainWindowController {
*/ */
columnRating.sortTypeProperty().addListener(new ChangeListener<SortType>() { columnRating.sortTypeProperty().addListener(new ChangeListener<SortType>() {
@Override @Override
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) {
SortType paramT2) {
LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2); LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
ArrayList<Integer> fav_true = new ArrayList<Integer>(); ArrayList<Integer> fav_true = new ArrayList<Integer>();
ArrayList<Integer> fav_false = new ArrayList<Integer>(); ArrayList<Integer> fav_false = new ArrayList<Integer>();
ObservableList<tableData> helpData; ObservableList<FilmTabelDataType> helpData;
filterData.removeAll(filterData); filterData.removeAll(filterData);
// treeTableViewfilm.getSelectionModel().clearSelection(selected); // treeTableViewfilm.getSelectionModel().clearSelection(selected);
root.getChildren().remove(0, root.getChildren().size()); filmRoot.getChildren().removeAll(filmRoot.getChildren());
if (mode.equals("local")) { if (mode.equals("local")) {
helpData = localFilms; helpData = localFilms;
@ -520,7 +492,8 @@ public class MainWindowController {
LOGGER.info(filterData.size()); // Debug, delete? LOGGER.info(filterData.size()); // Debug, delete?
for (int i = 0; i < filterData.size(); i++) { for (int i = 0; i < filterData.size(); i++) {
// LOGGER.info(filterData.get(i).getTitle()+"; "+filterData.get(i).getRating()); // Debugging // LOGGER.info(filterData.get(i).getTitle()+"; "+filterData.get(i).getRating()); // Debugging
root.getChildren().add(new TreeItem<tableData>(filterData.get(i))); // add filtered data to root node after search // add filtered data to root node after search
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(filterData.get(i)));
} }
} }
}); });
@ -533,23 +506,22 @@ public class MainWindowController {
selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); // get selected item selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); // get selected item
last = selected - 1; last = selected - 1;
next = selected + 1; next = selected + 1;
name = columnTitel.getCellData(selected); // get name of selected item title = columnTitel.getCellData(selected); // get name of selected item
datPath = columnStreamUrl.getCellData(selected); // get file path of selected item streamUrl = columnStreamUrl.getCellData(selected); // get file path of selected item
if (mode.equals("local")) { if (mode.equals("local")) {
if (localFilms.get(selected).getCached() == true) { if (localFilms.get(selected).getCached() == true) {
LOGGER.info("loading from cache: " + name); LOGGER.info("loading from cache: " + title);
dbController.readCache(datPath); dbController.readCache(streamUrl);
} else { } else {
ApiQuery.startQuery(name, datPath); // start api query ApiQuery.startQuery(title, streamUrl); // start api query
} }
} else { } else {
LOGGER.info(streamingFilms.size());
if (streamingFilms.get(selected).getCached() == true) { if (streamingFilms.get(selected).getCached() == true) {
LOGGER.info("loading from cache: " + name); LOGGER.info("loading from cache: " + title);
dbController.readCache(datPath); dbController.readCache(streamUrl);
} else { } else {
ApiQuery.startQuery(name, datPath); // start api query ApiQuery.startQuery(title, streamUrl); // start api query
} }
} }
} }
@ -587,7 +559,7 @@ public class MainWindowController {
if (Desktop.isDesktopSupported()) { if (Desktop.isDesktopSupported()) {
new Thread(() -> { new Thread(() -> {
try { try {
Desktop.getDesktop().browse(new URI(datPath)); //open the streaming URL in browser Desktop.getDesktop().browse(new URI(streamUrl)); //open the streaming URL in browser
} catch (IOException | URISyntaxException e) { } catch (IOException | URISyntaxException e) {
e.printStackTrace(); e.printStackTrace();
showErrorMsg(errorOpenStream, (IOException) e); showErrorMsg(errorOpenStream, (IOException) e);
@ -617,14 +589,14 @@ public class MainWindowController {
vlcInfoDialog.show(); vlcInfoDialog.show();
}else{ }else{
try { try {
Runtime.getRuntime().exec(new String[] { "vlc", datPath}); // TODO switch to ProcessBuilder Runtime.getRuntime().exec(new String[] { "vlc", streamUrl}); // TODO switch to ProcessBuilder
} catch (IOException e) { } catch (IOException e) {
showErrorMsg(errorPlay,e); showErrorMsg(errorPlay,e);
} }
} }
}else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){ }else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){
try { try {
Desktop.getDesktop().open(new File(datPath)); Desktop.getDesktop().open(new File(streamUrl));
} catch (IOException e) { } catch (IOException e) {
showErrorMsg(errorPlay,e); showErrorMsg(errorPlay,e);
} }
@ -639,7 +611,7 @@ public class MainWindowController {
@FXML @FXML
private void openfolderbtnclicked() { private void openfolderbtnclicked() {
String dest = new File(datPath).getParentFile().getAbsolutePath(); String dest = new File(streamUrl).getParentFile().getAbsolutePath();
if (!System.getProperty("os.name").contains("Linux")) { if (!System.getProperty("os.name").contains("Linux")) {
try { try {
Desktop.getDesktop().open(new File(dest)); Desktop.getDesktop().open(new File(dest));
@ -689,7 +661,7 @@ public class MainWindowController {
switchBtn.setText("streaming"); switchBtn.setText("streaming");
} }
saveSettings(); saveSettings();
root.getChildren().remove(0,root.getChildren().size()); filmRoot.getChildren().removeAll(filmRoot.getChildren());
addDataUI(); addDataUI();
settingsScrollPane.setVisible(false); settingsScrollPane.setVisible(false);
sideMenuSlideOut(); //disables side-menu sideMenuSlideOut(); //disables side-menu
@ -750,45 +722,42 @@ public class MainWindowController {
saveSettings(); saveSettings();
} }
private void refreshTable(){ // refresh the selected child of the root node
if(mode.equals("local")){ private void refreshTable() {
root.getChildren().set(selected, new TreeItem<tableData>(localFilms.get(selected))); if (mode.equals("local")) {
}else if(mode.equals("streaming")){ filmRoot.getChildren().get(selected).setValue(localFilms.get(selected));
root.getChildren().set(selected, new TreeItem<tableData>(streamingFilms.get(selected))); } else {
filmRoot.getChildren().get(selected).setValue(streamingFilms.get(selected));
} }
} }
// TODO rework
public void addDataUI(){ public void addDataUI(){
if(mode.equals("local")){ if(mode.equals("local")){
for(int i = 0; i < localFilms.size(); i++){ for(int i = 0; i < localFilms.size(); i++){
root.getChildren().add(new TreeItem<tableData>(localFilms.get(i))); //add data to root-node filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(localFilms.get(i))); //add data to root-node
} }
columnRating.setMaxWidth(85); columnRating.setMaxWidth(85);
columnTitel.setMaxWidth(290); columnTitel.setMaxWidth(290);
treeTableViewfilm.getColumns().get(3).setVisible(false); treeTableViewfilm.getColumns().get(3).setVisible(false);
treeTableViewfilm.getColumns().get(4).setVisible(false); treeTableViewfilm.getColumns().get(4).setVisible(false);
treeTableViewfilm.getColumns().get(5).setVisible(false);
treeTableViewfilm.getColumns().get(6).setVisible(false);
}else if(mode.equals("streaming")){ }else if(mode.equals("streaming")){
for(int i = 0; i < streamingFilms.size(); i++){ for(int i = 0; i < streamingFilms.size(); i++){
root.getChildren().add(new TreeItem<tableData>(streamingFilms.get(i))); //add data to root-node filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(streamingFilms.get(i))); //add data to root-node
} }
columnTitel.setMaxWidth(150); columnTitel.setMaxWidth(215);
columnResolution.setMaxWidth(65); columnRating.setMaxWidth(60);
columnRating.setMaxWidth(50); columnSeason.setMaxWidth(55);
columnYear.setMaxWidth(43); columnEpisode.setMaxWidth(64);
columnSeason.setMaxWidth(42);
columnEpisode.setMaxWidth(44);
treeTableViewfilm.getColumns().get(3).setVisible(true); treeTableViewfilm.getColumns().get(3).setVisible(true);
treeTableViewfilm.getColumns().get(4).setVisible(true); treeTableViewfilm.getColumns().get(4).setVisible(true);
treeTableViewfilm.getColumns().get(5).setVisible(true);
treeTableViewfilm.getColumns().get(6).setVisible(true);
} }
} }
public void addSourceToTable(String path, String mode) { public void addSourceToTable(String path, String mode) {
sourcesList.add(new tableData(1, 1, 1, 5.0, "1", path, mode, imv1, false)); sourcesList.add(new SourceDataType(path, mode));
streamingRoot.getChildren().add(new TreeItem<tableData>(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node streamingRoot.getChildren().add(new TreeItem<SourceDataType>(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node
} }
public void addSource(String path, String mode) { public void addSource(String path, String mode) {
@ -913,9 +882,7 @@ public class MainWindowController {
columnTitel.setText(getBundle().getString("columnName")); columnTitel.setText(getBundle().getString("columnName"));
columnRating.setText(getBundle().getString("columnRating")); columnRating.setText(getBundle().getString("columnRating"));
columnStreamUrl.setText(getBundle().getString("columnStreamUrl")); columnStreamUrl.setText(getBundle().getString("columnStreamUrl"));
columnResolution.setText(getBundle().getString("columnResolution"));
columnSeason.setText(getBundle().getString("columnSeason")); columnSeason.setText(getBundle().getString("columnSeason"));
columnYear.setText(getBundle().getString("columnYear"));
errorPlay = getBundle().getString("errorPlay"); errorPlay = getBundle().getString("errorPlay");
errorOpenStream = getBundle().getString("errorOpenStream"); errorOpenStream = getBundle().getString("errorOpenStream");
errorMode = getBundle().getString("errorMode"); errorMode = getBundle().getString("errorMode");
@ -926,7 +893,7 @@ public class MainWindowController {
} }
// TODO rework to material design // TODO rework to material design
public void showErrorMsg(String msg, IOException exception) { public void showErrorMsg(String msg, Exception exception) {
Alert alert = new Alert(AlertType.ERROR); Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error"); alert.setTitle("Error");
alert.setHeaderText(""); alert.setHeaderText("");
@ -1141,27 +1108,27 @@ public class MainWindowController {
return mode; return mode;
} }
public ObservableList<tableData> getLocalFilms() { public ObservableList<FilmTabelDataType> getLocalFilms() {
return localFilms; return localFilms;
} }
public void setLocalFilms(ObservableList<tableData> localFilms) { public void setLocalFilms(ObservableList<FilmTabelDataType> localFilms) {
this.localFilms = localFilms; this.localFilms = localFilms;
} }
public ObservableList<tableData> getStreamingFilms() { public ObservableList<FilmTabelDataType> getStreamingFilms() {
return streamingFilms; return streamingFilms;
} }
public void setStreamingFilms(ObservableList<tableData> streamingFilms) { public void setStreamingFilms(ObservableList<FilmTabelDataType> streamingFilms) {
this.streamingFilms = streamingFilms; this.streamingFilms = streamingFilms;
} }
public ObservableList<tableData> getSourcesList() { public ObservableList<SourceDataType> getSourcesList() {
return sourcesList; return sourcesList;
} }
public void setSourcesList(ObservableList<tableData> sourcesList) { public void setSourcesList(ObservableList<SourceDataType> sourcesList) {
this.sourcesList = sourcesList; this.sourcesList = sourcesList;
} }
@ -1185,23 +1152,19 @@ public class MainWindowController {
return textFlow; return textFlow;
} }
public void setTextFlow(TextFlow textFlow) {
this.textFlow = textFlow;
}
public ImageView getImage1() { public ImageView getImage1() {
return image1; return image1;
} }
public void setImage1(ImageView image1) {
this.image1 = image1;
}
public JFXButton getUpdateBtn() { public JFXButton getUpdateBtn() {
return updateBtn; return updateBtn;
} }
public void setUpdateBtn(JFXButton updateBtn) { public TreeItem<FilmTabelDataType> getFilmRoot() {
this.updateBtn = updateBtn; return filmRoot;
}
public TreeItem<SourceDataType> getStreamingRoot() {
return streamingRoot;
} }
} }

View File

@ -49,7 +49,8 @@ import javafx.scene.text.FontWeight;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import kellerkinder.HomeFlix.application.Main; import kellerkinder.HomeFlix.application.Main;
import kellerkinder.HomeFlix.application.MainWindowController; import kellerkinder.HomeFlix.application.MainWindowController;
import kellerkinder.HomeFlix.datatypes.tableData; import kellerkinder.HomeFlix.datatypes.SourceDataType;
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType;
public class DBController { public class DBController {
@ -79,7 +80,7 @@ public class DBController {
LOGGER.info("<========== finished loading sql ==========>"); LOGGER.info("<========== finished loading sql ==========>");
} }
public void initDatabaseConnection() { private void initDatabaseConnection() {
DB_PATH = main.getDirectory() + "/Homeflix.db"; DB_PATH = main.getDirectory() + "/Homeflix.db";
try { try {
// create a database connection // create a database connection
@ -99,9 +100,8 @@ public class DBController {
private void createDatabase() { private void createDatabase() {
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, favIcon, cached)"); stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, cached)");
stmt.executeUpdate("create table if not exists film_streaming (year, season, episode," stmt.executeUpdate("create table if not exists film_streaming (season, episode, rating, titel, streamUrl, cached)");
+ " rating, resolution, titel, streamUrl, favIcon, 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,"
@ -119,15 +119,15 @@ public class DBController {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
while (rs.next()) { while (rs.next()) {
filmsdbDir.add(rs.getString(2)); filmsdbDir.add(rs.getString("titel"));
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
rs = stmt.executeQuery("SELECT * FROM film_streaming;"); rs = stmt.executeQuery("SELECT * FROM film_streaming;");
while (rs.next()) { while (rs.next()) {
filmsdbAll.add(rs.getString(6)); filmsdbAll.add(rs.getString("titel"));
filmsdbStreamURL.add(rs.getString(7)); filmsdbStreamURL.add(rs.getString("streamUrl"));
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -145,7 +145,7 @@ public class DBController {
private void loadSources() { private void loadSources() {
// remove sources from table // remove sources from table
mainWindowController.getSourcesList().removeAll(mainWindowController.getSourcesList()); mainWindowController.getSourcesList().removeAll(mainWindowController.getSourcesList());
mainWindowController.streamingRoot.getChildren().removeAll(mainWindowController.streamingRoot.getChildren()); mainWindowController.getStreamingRoot().getChildren().removeAll(mainWindowController.getStreamingRoot().getChildren());
try { try {
JsonArray sources = Json.parse(new FileReader(main.getDirectory() + "/sources.json")).asArray(); JsonArray sources = Json.parse(new FileReader(main.getDirectory() + "/sources.json")).asArray();
@ -187,19 +187,19 @@ public class DBController {
} }
// loading data from database to mainWindowController // loading data from database to mainWindowController
public void loadDataToMWC() { private void loadDataToMWC() {
LOGGER.info("loading data to mwc ..."); LOGGER.info("loading data to mwc ...");
try { try {
//load local Data //load local Data
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY titel"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY titel");
while (rs.next()) { while (rs.next()) {
if (rs.getString(4).equals("favorite_black")) { if (rs.getInt("rating") == 1) {
mainWindowController.getLocalFilms().add(new tableData(1, 1, 1, rs.getDouble(1), "1", mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("titel"),
rs.getString(2), rs.getString(3), new ImageView(favorite_black), rs.getBoolean(5))); rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached")));
} else { } else {
mainWindowController.getLocalFilms().add(new tableData(1, 1, 1, rs.getDouble(1), "1", mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("titel"),
rs.getString(2), rs.getString(3), new ImageView(favorite_border_black), rs.getBoolean(5))); rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached")));
} }
} }
stmt.close(); stmt.close();
@ -208,14 +208,14 @@ public class DBController {
//load streaming Data FIXME check if there are streaming data before loading -> maybe there is an issue now //load streaming Data FIXME check if there are streaming data before loading -> maybe there is an issue now
rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY titel;"); rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY titel;");
while (rs.next()) { while (rs.next()) {
if (rs.getString(8).equals("favorite_black")) { if (rs.getInt("rating") == 1) {
mainWindowController.getStreamingFilms().add(new tableData(rs.getInt(1), mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"),
rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"),
rs.getString(7), new ImageView(favorite_black),rs.getBoolean(9))); new ImageView(favorite_black), rs.getBoolean("cached")));
} else { } else {
mainWindowController.getStreamingFilms().add(new tableData(rs.getInt(1), mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"),
rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getInt("episode"),rs.getDouble("rating"), rs.getString("titel"),rs.getString("streamUrl"),
rs.getString(7), new ImageView(favorite_border_black), rs.getBoolean(9))); new ImageView(favorite_border_black), rs.getBoolean("cached")));
} }
} }
stmt.close(); stmt.close();
@ -228,43 +228,43 @@ public class DBController {
mainWindowController.addDataUI(); mainWindowController.addDataUI();
} }
//Refreshes the data in mainWindowController.newDaten and mainWindowController.streamData /**
//FIXME it seems that there is an issue at the moment with streaming refreshing wrong entry if there is more than one with the same name * refresh data in mainWindowController localFilms and streamingFilms
public void refresh(String name, int i) throws SQLException { * @param title of the film
* @param i index of the film in LocalFilms list
* @throws SQLException
*/
public void refresh(String streamUrl, int index) {
LOGGER.info("refresh ..."); LOGGER.info("refresh ...");
Statement stmt;
try { try {
stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = \""+name+"\";" );
if (rs.getString(4).equals("favorite_black")) { if (mainWindowController.getMode().equals("local")) {
mainWindowController.getLocalFilms().set(i, new tableData(1, 1, 1, rs.getDouble(1), "1", ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE streamUrl = \"" + streamUrl + "\";");
rs.getString(2), rs.getString(3), new ImageView(favorite_black), rs.getBoolean(5))); if (rs.getInt("rating") == 1) {
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"),
rs.getString("titel"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached")));
} else {
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"),
rs.getString("titel"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached")));
}
rs.close();
} else { } else {
mainWindowController.getLocalFilms().set(i, new tableData(1, 1, 1, rs.getDouble(1), "1", ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE streamUrl = \"" + streamUrl + "\";");
rs.getString(2), rs.getString(3), new ImageView(favorite_border_black), rs.getBoolean(5))); if (rs.getInt("rating") == 1) {
mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"),
rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"),
new ImageView(favorite_black), rs.getBoolean("cached")));
} else {
mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"),
rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"),
new ImageView(favorite_border_black), rs.getBoolean("cached")));
}
rs.close();
} }
stmt.close(); stmt.close();
rs.close(); } catch (Exception e) {
} catch (SQLException e) { LOGGER.error("Ups! error while refreshing mwc!", e);
LOGGER.error(e);
try {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = \""+name+"\";" );
if (rs.getString(8).equals("favorite_black")) {
mainWindowController.getStreamingFilms().set(i, new tableData(rs.getInt(1), rs.getInt(2),
rs.getInt(3), rs.getDouble(4),rs.getString(5), rs.getString(6), rs.getString(7),
new ImageView(favorite_black), rs.getBoolean(9)));
} else {
mainWindowController.getStreamingFilms().set(i, new tableData(rs.getInt(1), rs.getInt(2),
rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7),
new ImageView(favorite_border_black), rs.getBoolean(9)));
}
stmt.close();
rs.close();
} catch (SQLException e1) {
LOGGER.error("Ups! an error occured!", e1);
}
} }
} }
@ -297,7 +297,7 @@ public class DBController {
// 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.getStreamingFilms().removeAll(mainWindowController.getStreamingFilms());
mainWindowController.root.getChildren().removeAll(mainWindowController.root.getChildren()); mainWindowController.getFilmRoot().getChildren().removeAll(mainWindowController.getFilmRoot().getChildren());
loadDataToMWC(); // load the new data to the mwc loadDataToMWC(); // load the new data to the mwc
} }
@ -315,7 +315,6 @@ public class DBController {
if (!filmsAll.contains(cutOffEnd(entry))) { if (!filmsAll.contains(cutOffEnd(entry))) {
stmt.executeUpdate("delete from film_local where titel = \"" + entry + "\""); stmt.executeUpdate("delete from film_local where titel = \"" + entry + "\"");
connection.commit(); connection.commit();
stmt.close();
LOGGER.info("removed \"" + entry + "\" from database"); LOGGER.info("removed \"" + entry + "\" from database");
} }
} }
@ -324,11 +323,11 @@ public class DBController {
if (!filmsStreamURL.contains(entry)) { if (!filmsStreamURL.contains(entry)) {
stmt.executeUpdate("delete from film_streaming where streamUrl = \"" + entry + "\""); stmt.executeUpdate("delete from film_streaming where streamUrl = \"" + entry + "\"");
connection.commit(); connection.commit();
stmt.close();
LOGGER.info("removed \"" + entry + "\" from database"); LOGGER.info("removed \"" + entry + "\" from database");
} }
} }
stmt.close();
} catch (Exception e) { } catch (Exception e) {
LOGGER.error(e); LOGGER.error(e);
} }
@ -346,13 +345,13 @@ public class DBController {
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
for (tableData source : mainWindowController.getSourcesList()) { for (SourceDataType source : mainWindowController.getSourcesList()) {
// if it's a local source check the folder for new film // if it's a local source check the folder for new film
if (source.getStreamUrl().equals("local")) { if (source.getMode().equals("local")) {
for (String entry : new File(source.getTitle()).list()) { for (String entry : new File(source.getPath()).list()) {
if (!filmsdbAll.contains(cutOffEnd(entry))) { if (!filmsdbAll.contains(cutOffEnd(entry))) {
stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entry) + "\", \"" stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entry) + "\", \""
+ source.getTitle() + "/" + entry + "\",\"favorite_border_black\",0)"); + source.getPath() + "/" + entry + "\",\"favorite_border_black\",0)");
connection.commit(); connection.commit();
stmt.close(); stmt.close();
LOGGER.info("added \"" + entry + "\" to database"); LOGGER.info("added \"" + entry + "\" to database");
@ -363,7 +362,7 @@ public class DBController {
// if it's a streaming source check the file for new films // if it's a streaming source check the file for new films
for (String entry : filmsStreamURL) { for (String entry : filmsStreamURL) {
if (!filmsdbStreamURL.contains(entry)) { if (!filmsdbStreamURL.contains(entry)) {
JsonArray items = Json.parse(new FileReader(source.getTitle())).asObject().get("entries").asArray(); JsonArray items = Json.parse(new FileReader(source.getPath())).asObject().get("entries").asArray();
// for each item, check if it's the needed // for each item, check if it's the needed
for (JsonValue item : items) { for (JsonValue item : items) {
String streamUrl = item.asObject().getString("streamUrl", ""); String streamUrl = item.asObject().getString("streamUrl", "");
@ -378,8 +377,7 @@ public class DBController {
ps.setString(5, item.asObject().getString("resolution", "")); ps.setString(5, item.asObject().getString("resolution", ""));
ps.setString(6, titel); ps.setString(6, titel);
ps.setString(7, streamUrl); ps.setString(7, streamUrl);
ps.setString(8, "favorite_border_black"); ps.setBoolean(8, false);
ps.setBoolean(9, false);
ps.addBatch(); // adds the entry ps.addBatch(); // adds the entry
LOGGER.info("added \"" + titel + "\" to database"); LOGGER.info("added \"" + titel + "\" to database");
filmsAll.add(cutOffEnd(titel)); filmsAll.add(cutOffEnd(titel));
@ -401,11 +399,10 @@ public class DBController {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getString(1)); System.out.println(rs.getString("rating"));
System.out.println(rs.getString(2)); System.out.println(rs.getString("titel"));
System.out.println(rs.getString(3)); System.out.println(rs.getString("streamUrl"));
System.out.println(rs.getString(4)); System.out.println(rs.getString("cached") + "\n");
System.out.println(rs.getString(5) + "\n");
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -414,15 +411,12 @@ public class DBController {
rs = stmt.executeQuery("SELECT * FROM film_streaming;"); rs = stmt.executeQuery("SELECT * FROM film_streaming;");
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getString(1)); System.out.println(rs.getString("season"));
System.out.println(rs.getString(2)); System.out.println(rs.getString("episode"));
System.out.println(rs.getString(3)); System.out.println(rs.getString("rating"));
System.out.println(rs.getString(4)); System.out.println(rs.getString("titel"));
System.out.println(rs.getString(5)); System.out.println(rs.getString("streamUrl"));
System.out.println(rs.getString(6)); System.out.println(rs.getString("cached") + "\n");
System.out.println(rs.getString(7));
System.out.println(rs.getString(8));
System.out.println(rs.getString(9) + "\n");
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -431,80 +425,21 @@ public class DBController {
LOGGER.error("An error occured, while printing all entries", e); LOGGER.error("An error occured, while printing all entries", e);
} }
} }
// get favorite status
public void getFavStatus(String name) {
try {
if (mainWindowController.getMode().equals("local")) {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT titel, rating, favIcon FROM film_local WHERE titel = \"" + name + "\";"); // SQL Befehl
LOGGER.info("local:" + rs.getString("rating") + ", " + rs.getString("titel") + ", " + rs.getString("favIcon"));
stmt.close();
rs.close();
} else {
Statement stmtS = connection.createStatement();
ResultSet rsS = stmtS.executeQuery("SELECT titel, rating, favIcon FROM film_streaming WHERE titel = \"" + name + "\";");
LOGGER.info("streaming:" + rsS.getString("rating") + ", " + rsS.getString("titel") + ", " + rsS.getString("favIcon"));
stmtS.close();
rsS.close();
}
} catch (SQLException e) {
LOGGER.error("Ups! an error occured!", e);
}
}
// set rating=0 and favorite_border_black /**
public void dislike(String name, String streamUrl) { * update the database entry for the given film, rating = 0
LOGGER.info("defavorisieren ..."); * @param name of the film
try { * @param streamUrl URL of the film
if (mainWindowController.getMode().equals("local")) { */
Statement stmt = connection.createStatement(); public void dislike(String streamUrl) {
stmt.executeUpdate("UPDATE film_local SET rating=0,favIcon='favorite_border_black' WHERE titel=\"" + name + "\";"); LOGGER.info("dislike " + streamUrl);
connection.commit();
stmt.close();
} else {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_streaming SET rating=0,favIcon='favorite_border_black' WHERE streamUrl=\"" + streamUrl + "\";");
connection.commit();
stmt.close();
}
} catch (SQLException e) {
LOGGER.error("Ups! an error occured!", e);
}
}
// set rating=1 and favorite_black
public void like(String name, String streamUrl) {
LOGGER.info("favorisieren ...");
try {
if (mainWindowController.getMode().equals("local")) {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_local SET rating=1,favIcon='favorite_black' WHERE titel=\"" + name + "\";");
connection.commit();
stmt.close();
} else {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_streaming SET rating=1,favIcon='favorite_black' WHERE streamUrl=\"" + streamUrl + "\";");
connection.commit();
stmt.close();
}
} catch (SQLException e) {
LOGGER.error("Ups! an error occured!", e);
}
}
void setCached(String streamUrl) throws SQLException {
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_local SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";"); if (mainWindowController.getMode().equals("local")) {
connection.commit(); stmt.executeUpdate("UPDATE film_local SET rating=0 WHERE streamUrl=\"" + streamUrl + "\";");
stmt.close(); } else {
} catch (SQLException e) { stmt.executeUpdate("UPDATE film_streaming SET rating=0 WHERE streamUrl=\"" + streamUrl + "\";");
LOGGER.error("Ups! an error occured!", e); }
}
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_streaming SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";");
connection.commit(); connection.commit();
stmt.close(); stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
@ -512,6 +447,71 @@ public class DBController {
} }
} }
/**
* update the database entry for the given film, rating = 1
* @param name of the film
* @param streamUrl URL of the film
*/
public void like(String streamUrl) {
LOGGER.info("like " + streamUrl);
try {
Statement stmt = connection.createStatement();
if (mainWindowController.getMode().equals("local")) {
stmt.executeUpdate("UPDATE film_local SET rating=1 WHERE streamUrl=\"" + streamUrl + "\";");
} else {
stmt.executeUpdate("UPDATE film_streaming SET rating=1 WHERE streamUrl=\"" + streamUrl + "\";");
}
connection.commit();
stmt.close();
} catch (SQLException e) {
LOGGER.error("Ups! an error occured!", e);
}
}
/**
* update the database entry for the given film, cached = 1
* @param streamUrl URL of the film
*/
void setCached(String streamUrl) {
try {
Statement stmt = connection.createStatement();
if (mainWindowController.getMode().equals("local")) {
stmt.executeUpdate("UPDATE film_local SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";");
} else {
stmt.executeUpdate("UPDATE film_streaming SET cached=1 WHERE streamUrl=\"" + streamUrl + "\";");
}
connection.commit();
stmt.close();
} catch (SQLException e) {
LOGGER.error("Ups! an error occured!", e);
}
}
/**
* add the received data to the cache table
* @param streamUrl URL of the film
* @param Title
* @param Year
* @param Rated
* @param Released
* @param Runtime
* @param Genre
* @param Director
* @param Writer
* @param Actors
* @param Plot
* @param Language
* @param Country
* @param Awards
* @param Metascore
* @param imdbRating
* @param Type
* @param imdbVotes
* @param imdbID
* @param Poster
* @param Response
* @throws SQLException
*/
void addCache( String streamUrl, String Title, String Year, String Rated, String Released, String Runtime, String Genre, String Director, void addCache( String streamUrl, String Title, String Year, String Rated, String Released, String Runtime, String Genre, String Director,
String Writer, String Actors, String Plot, String Language, String Country, String Awards, String Metascore, String imdbRating, String Writer, String Actors, String Plot, String Language, String Country, String Awards, String Metascore, String imdbRating,
String Type, String imdbVotes, String imdbID, String Poster, String Response) throws SQLException{ String Type, String imdbVotes, String imdbID, String Poster, String Response) throws SQLException{
@ -546,6 +546,10 @@ public class DBController {
LOGGER.info("done!"); LOGGER.info("done!");
} }
/**
* sets the cached data to mwc's TextFlow
* @param streamUrl URL of the film
*/
public void readCache(String streamUrl) { public void readCache(String streamUrl) {
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
@ -573,7 +577,7 @@ public class DBController {
nameText.add(13, new Text(mainWindowController.getBundle().getString("metascore") + ": ")); nameText.add(13, new Text(mainWindowController.getBundle().getString("metascore") + ": "));
nameText.add(14, new Text(mainWindowController.getBundle().getString("imdbRating") + ": ")); nameText.add(14, new Text(mainWindowController.getBundle().getString("imdbRating") + ": "));
nameText.add(15, new Text(mainWindowController.getBundle().getString("type") + ": ")); nameText.add(15, new Text(mainWindowController.getBundle().getString("type") + ": "));
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {
responseText.add(new Text(rs.getString(j) + "\n")); responseText.add(new Text(rs.getString(j) + "\n"));
j++; j++;

View File

@ -32,44 +32,34 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
public class tableData { public class FilmTabelDataType {
private final IntegerProperty year = new SimpleIntegerProperty();
private final IntegerProperty season = new SimpleIntegerProperty(); private final IntegerProperty season = new SimpleIntegerProperty();
private final IntegerProperty episode = new SimpleIntegerProperty(); private final IntegerProperty episode = new SimpleIntegerProperty();
private final DoubleProperty rating = new SimpleDoubleProperty(); private final DoubleProperty rating = new SimpleDoubleProperty();
private final StringProperty resolution = new SimpleStringProperty();
private final StringProperty title = new SimpleStringProperty(); private final StringProperty title = new SimpleStringProperty();
private final StringProperty streamUrl = new SimpleStringProperty(); private final StringProperty streamUrl = new SimpleStringProperty();
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>(); private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
private final BooleanProperty cached = new SimpleBooleanProperty(); private final BooleanProperty cached = new SimpleBooleanProperty();
/** /** TODO rating boolean
* tableData is the data-type of tree-table-view * tableData is the data-type of tree-table-view
* @param year the release year of the film
* @param season season if it's a series * @param season season if it's a series
* @param episode episode if it's a series * @param episode episode if it's a series
* @param rating indicator for favourites, used for sorting the items * @param rating indicator for favorites, used for sorting the items
* @param resolution resolution of the film
* @param titel title of the film * @param titel title of the film
* @param streamUrl the concrete path to the file or the URL * @param streamUrl the concrete path to the file or the URL
* @param image the favourite icon
* @param cached indicator for caching status * @param cached indicator for caching status
*/ */
public tableData (final int year, final int season, final int episode, final double rating, final String resolution, final String title, final String streamUrl, final ImageView image, final boolean cached) { public FilmTabelDataType(final int season, final int episode, final double rating, final String title,
this.year.set(year); final String streamUrl, final ImageView image, final boolean cached) {
this.season.set(season); this.season.set(season);
this.episode.set(episode); this.episode.set(episode);
this.rating.set(rating); this.rating.set(rating);
this.resolution.set(resolution);
this.title.set(title); this.title.set(title);
this.streamUrl.set(streamUrl); this.streamUrl.set(streamUrl);
this.image.set(image); this.image.set(image);
this.cached.set(cached); this.cached.set(cached);
} }
public IntegerProperty yearProperty(){
return year;
}
public IntegerProperty seasonProperty(){ public IntegerProperty seasonProperty(){
return season; return season;
@ -83,10 +73,6 @@ public class tableData {
return rating; return rating;
} }
public StringProperty resolutionProperty(){
return resolution;
}
public StringProperty titleProperty(){ public StringProperty titleProperty(){
return title; return title;
} }
@ -103,10 +89,6 @@ public class tableData {
return cached; return cached;
} }
public final int getYear() {
return yearProperty().get();
}
public final int getSeason() { public final int getSeason() {
return seasonProperty().get(); return seasonProperty().get();
@ -119,10 +101,6 @@ public class tableData {
public final double getRating() { public final double getRating() {
return ratingProperty().get(); return ratingProperty().get();
} }
public final String getResolution() {
return resolutionProperty().get();
}
public final String getTitle() { public final String getTitle() {
return titleProperty().get(); return titleProperty().get();
@ -141,9 +119,6 @@ public class tableData {
} }
public final void setYear(int year) {
yearProperty().set(year);
}
public final void setSeason(int season) { public final void setSeason(int season) {
seasonProperty().set(season); seasonProperty().set(season);
@ -157,10 +132,6 @@ public class tableData {
ratingProperty().set(rating); ratingProperty().set(rating);
} }
public final void setResolution(String resolution) {
resolutionProperty().set(resolution);
}
public final void setTitle(String title) { public final void setTitle(String title) {
titleProperty().set(title); titleProperty().set(title);
} }

View File

@ -0,0 +1,64 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2018 <@Seil0>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package kellerkinder.HomeFlix.datatypes;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class SourceDataType {
private final StringProperty path = new SimpleStringProperty();
private final StringProperty mode = new SimpleStringProperty();
/**
* data type for the source table
* @param path of the source
* @param mode of the source, stream or local
*/
public SourceDataType (final String path, final String mode) {
this.path.set(path);
this.mode.set(mode);
}
public StringProperty pathProperty(){
return path;
}
public StringProperty modeProperty(){
return mode;
}
public final String getPath() {
return pathProperty().get();
}
public final String getMode() {
return modeProperty().get();
}
public final void setPath(String path) {
pathProperty().set(path);
}
public final void setMode(String mode) {
modeProperty().set(mode);
}
}

View File

@ -26,9 +26,7 @@ branchLbl = Updatezweig
columnName = Name columnName = Name
columnRating = Bewertung columnRating = Bewertung
columnStreamUrl = Datei Name columnStreamUrl = Datei Name
columnResolution = Aufl\u00F6sung
columnSeason = Staffel columnSeason = Staffel
columnYear = Jahr
#error translations #error translations
errorUpdateV = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not check update version (nvc)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz errorUpdateV = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not check update version (nvc)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz

View File

@ -26,9 +26,7 @@ branchLbl = Branch
columnName = Name columnName = Name
columnRating = Rating columnRating = Rating
columnStreamUrl = File Name columnStreamUrl = File Name
columnResolution = Resolution
columnSeason = Season columnSeason = Season
columnYear = Year
#error translations #error translations
errorUpdateV = An error has occurred during update! \nError: could not check update version (nvc) \nTo get help, visit www.kellerkinder.xyz \nor contcat support@kellerkinder.xyz errorUpdateV = An error has occurred during update! \nError: could not check update version (nvc) \nTo get help, visit www.kellerkinder.xyz \nor contcat support@kellerkinder.xyz