series work
This commit is contained in:
parent
2c1ce23315
commit
913513a237
|
@ -103,13 +103,11 @@ public class MainWindowController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane mainAnchorPane;
|
private AnchorPane mainAnchorPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane tableModeAnchorPane;
|
private AnchorPane tableModeAnchorPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ScrollPane settingsScrollPane;
|
private ScrollPane settingsScrollPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ScrollPane textScrollPane;
|
private ScrollPane textScrollPane;
|
||||||
|
|
||||||
|
@ -130,31 +128,22 @@ public class MainWindowController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton playbtn;
|
private JFXButton playbtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton openfolderbtn;
|
private JFXButton openfolderbtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton returnBtn;
|
private JFXButton returnBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton forwardBtn;
|
private JFXButton forwardBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton aboutBtn;
|
private JFXButton aboutBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton settingsBtn;
|
private JFXButton settingsBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton debugBtn;
|
private JFXButton debugBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton updateBtn;
|
private JFXButton updateBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton addDirectoryBtn;
|
private JFXButton addDirectoryBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton addStreamSourceBtn;
|
private JFXButton addStreamSourceBtn;
|
||||||
|
|
||||||
|
@ -163,7 +152,6 @@ public class MainWindowController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXToggleButton autoUpdateToggleBtn;
|
private JFXToggleButton autoUpdateToggleBtn;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXToggleButton autoplayToggleBtn;
|
private JFXToggleButton autoplayToggleBtn;
|
||||||
|
|
||||||
|
@ -171,38 +159,30 @@ public class MainWindowController {
|
||||||
private JFXTextField searchTextField;
|
private JFXTextField searchTextField;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public JFXColorPicker colorPicker;
|
private JFXColorPicker colorPicker;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public ChoiceBox<String> languageChoisBox = new ChoiceBox<>();
|
private ChoiceBox<String> languageChoisBox = new ChoiceBox<>();
|
||||||
|
@FXML
|
||||||
|
private ChoiceBox<String> branchChoisBox = new ChoiceBox<>();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public ChoiceBox<String> branchChoisBox = new ChoiceBox<>();
|
private JFXSlider fontsizeSlider;
|
||||||
|
|
||||||
@FXML
|
|
||||||
public JFXSlider fontsizeSlider;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label homeflixSettingsLbl;
|
private Label homeflixSettingsLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label mainColorLbl;
|
private Label mainColorLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label fontsizeLbl;
|
private Label fontsizeLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label languageLbl;
|
private Label languageLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label updateLbl;
|
private Label updateLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label branchLbl;
|
private Label branchLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label sourcesLbl;
|
private Label sourcesLbl;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label versionLbl;
|
private Label versionLbl;
|
||||||
|
|
||||||
|
@ -578,8 +558,9 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO improve function
|
/** TODO add all other supported mime types
|
||||||
* check if a film is supported by the HomeFlixPlayer or not
|
* check if a film is supported by the HomeFlixPlayer or not
|
||||||
|
* this is the case if the mime type is mp4
|
||||||
* @param entry the film you want to check
|
* @param entry the film you want to check
|
||||||
* @return true if so, false if not
|
* @return true if so, false if not
|
||||||
*/
|
*/
|
||||||
|
@ -708,29 +689,32 @@ public class MainWindowController {
|
||||||
|
|
||||||
// only if the entry contains a season and a episode it's a valid series
|
// only if the entry contains a season and a episode it's a valid series
|
||||||
if (!element.getSeason().isEmpty() && !element.getEpisode().isEmpty()) {
|
if (!element.getSeason().isEmpty() && !element.getEpisode().isEmpty()) {
|
||||||
// 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++) {
|
for (int i = 0; i < filmRoot.getChildren().size(); i++) {
|
||||||
if (filmRoot.getChildren().get(i).getValue().getTitle().equals(element.getTitle())) {
|
if (filmRoot.getChildren().get(i).getValue().getTitle().equals(element.getTitle())) {
|
||||||
// if a root node exists, add element as child
|
// if a root node exists, add element as child
|
||||||
// System.out.println("Found a root node to add child");
|
// System.out.println("Found a root node to add child");
|
||||||
// System.out.println("Adding: " + element.getStreamUrl());
|
// System.out.println("Adding: " + element.getStreamUrl());
|
||||||
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
|
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(
|
||||||
element.getTitle(), element.getSeason(), element.getEpisode(), element.getFavorite(),
|
element.getStreamUrl(), element.getTitle(), element.getSeason(), element.getEpisode(),
|
||||||
element.getCached(), element.getImage()));
|
element.getFavorite(), element.getCached(), element.getImage()));
|
||||||
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
|
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
|
||||||
} else if (i == filmRoot.getChildren().size() - 1) {
|
} else if (filmRoot.getChildren().get(i).nextSibling() == null) {
|
||||||
// if no root node exists, create one and add element as child
|
// if no root node exists, create one and add element as child
|
||||||
// System.out.println("Create a root node to add child");
|
// System.out.println("Create a root node to add child");
|
||||||
// System.out.println("Adding: " + element.getStreamUrl());
|
// System.out.println("Adding: " + element.getStreamUrl());
|
||||||
// TODO get the last watched episode, the first one with currentTime != 0
|
// TODO set episode and season
|
||||||
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
|
// FIXME if the streamUrl hasen't been cached we get an exception
|
||||||
|
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(new FilmTabelDataType(
|
||||||
|
dbController.getLastWatchedEpisode(element.getTitle()),
|
||||||
element.getTitle(), "", "", element.getFavorite(), element.getCached(), element.getImage()));
|
element.getTitle(), "", "", element.getFavorite(), element.getCached(), element.getImage()));
|
||||||
filmRoot.getChildren().add(seriesRootNode);
|
filmRoot.getChildren().add(seriesRootNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(element)); // add data to root-node
|
// if season and episode are empty, we can assume the object is a film
|
||||||
|
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,6 +546,7 @@ public class DBController {
|
||||||
*/
|
*/
|
||||||
public void readCache(String streamUrl) {
|
public void readCache(String streamUrl) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM cache WHERE streamUrl=\"" + streamUrl + "\";");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM cache WHERE streamUrl=\"" + streamUrl + "\";");
|
||||||
ArrayList<Text> nameText = new ArrayList<Text>();
|
ArrayList<Text> nameText = new ArrayList<Text>();
|
||||||
|
@ -575,6 +576,7 @@ public class DBController {
|
||||||
responseText.add(new Text(rs.getString(j) + "\n"));
|
responseText.add(new Text(rs.getString(j) + "\n"));
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseText.add(new Text(rs.getString(19) + "\n"));
|
responseText.add(new Text(rs.getString(19) + "\n"));
|
||||||
im = new Image(new File(rs.getString(20)).toURI().toString());
|
im = new Image(new File(rs.getString(20)).toURI().toString());
|
||||||
|
|
||||||
|
@ -620,7 +622,7 @@ public class DBController {
|
||||||
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 getting the current time!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentTime;
|
return currentTime;
|
||||||
|
@ -673,6 +675,28 @@ public class DBController {
|
||||||
return nextFilm;
|
return nextFilm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getLastWatchedEpisode(String title) {
|
||||||
|
LOGGER.info("last watched episode of: " + title);
|
||||||
|
String lastEpisodeStreamUrl = "";
|
||||||
|
double lastCurrentTime = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Statement stmt = connection.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE title = \"" + title + "\";");
|
||||||
|
while (rs.next()) {
|
||||||
|
if (rs.getDouble("currentTime") > lastCurrentTime) {
|
||||||
|
lastCurrentTime = rs.getDouble("currentTime");
|
||||||
|
lastEpisodeStreamUrl = rs.getString("streamUrl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("Ups! error while getting the last watched episode!", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastEpisodeStreamUrl;
|
||||||
|
}
|
||||||
|
|
||||||
// removes the ending
|
// removes the ending
|
||||||
private String cutOffEnd(String str) {
|
private String cutOffEnd(String str) {
|
||||||
if (str == null) return null;
|
if (str == null) return null;
|
||||||
|
|
Loading…
Reference in New Issue