|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
/** |
|
|
|
|
* Project-HomeFlix |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* Copyright 2016-2018 <@Seil0> |
|
|
|
|
* |
|
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
@ -19,7 +19,6 @@
|
|
|
|
|
* MA 02110-1301, USA. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
package kellerkinder.HomeFlix.application; |
|
|
|
|
|
|
|
|
|
import java.awt.Desktop; |
|
|
|
@ -33,19 +32,17 @@ import java.io.IOException;
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
import java.io.OutputStream; |
|
|
|
|
import java.io.PrintWriter; |
|
|
|
|
import java.io.StringWriter; |
|
|
|
|
import java.io.Writer; |
|
|
|
|
import java.math.BigInteger; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.net.URLConnection; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
import java.util.ResourceBundle; |
|
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
|
import org.kellerkinder.Alerts.JFXInfoAlert; |
|
|
|
|
|
|
|
|
|
import com.cemu_UI.uiElements.JFXInfoDialog; |
|
|
|
|
import com.eclipsesource.json.Json; |
|
|
|
|
import com.eclipsesource.json.JsonArray; |
|
|
|
|
import com.eclipsesource.json.JsonObject; |
|
|
|
@ -65,8 +62,6 @@ import javafx.collections.ObservableList;
|
|
|
|
|
import javafx.event.ActionEvent; |
|
|
|
|
import javafx.event.EventHandler; |
|
|
|
|
import javafx.fxml.FXML; |
|
|
|
|
import javafx.scene.control.Alert; |
|
|
|
|
import javafx.scene.control.Alert.AlertType; |
|
|
|
|
import javafx.scene.control.ChoiceBox; |
|
|
|
|
import javafx.scene.control.ContextMenu; |
|
|
|
|
import javafx.scene.control.Label; |
|
|
|
@ -74,7 +69,6 @@ import javafx.scene.control.MenuItem;
|
|
|
|
|
import javafx.scene.control.ScrollPane; |
|
|
|
|
import javafx.scene.control.TableColumn; |
|
|
|
|
import javafx.scene.control.TableView; |
|
|
|
|
import javafx.scene.control.TextArea; |
|
|
|
|
import javafx.scene.control.TreeItem; |
|
|
|
|
import javafx.scene.control.TreeTableColumn; |
|
|
|
|
import javafx.scene.control.TreeTableColumn.SortType; |
|
|
|
@ -83,9 +77,7 @@ import javafx.scene.image.Image;
|
|
|
|
|
import javafx.scene.image.ImageView; |
|
|
|
|
import javafx.scene.input.MouseEvent; |
|
|
|
|
import javafx.scene.layout.AnchorPane; |
|
|
|
|
import javafx.scene.layout.GridPane; |
|
|
|
|
import javafx.scene.layout.HBox; |
|
|
|
|
import javafx.scene.layout.Priority; |
|
|
|
|
import javafx.scene.layout.VBox; |
|
|
|
|
import javafx.scene.paint.Color; |
|
|
|
|
import javafx.scene.text.Font; |
|
|
|
@ -97,16 +89,18 @@ import kellerkinder.HomeFlix.controller.DBController;
|
|
|
|
|
import kellerkinder.HomeFlix.controller.OMDbAPIController; |
|
|
|
|
import kellerkinder.HomeFlix.controller.UpdateController; |
|
|
|
|
import kellerkinder.HomeFlix.datatypes.SourceDataType; |
|
|
|
|
import kellerkinder.HomeFlix.player.Player; |
|
|
|
|
import kellerkinder.HomeFlix.datatypes.FilmTabelDataType; |
|
|
|
|
|
|
|
|
|
public class MainWindowController { |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private AnchorPane mainAnchorPane; |
|
|
|
|
@FXML |
|
|
|
|
private AnchorPane tableModeAnchorPane; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private ScrollPane settingsScrollPane; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private ScrollPane textScrollPane; |
|
|
|
|
|
|
|
|
@ -127,82 +121,65 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton playbtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton openfolderbtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton returnBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton forwardBtn; |
|
|
|
|
@FXML |
|
|
|
|
private JFXButton aboutBtn; |
|
|
|
|
@FXML |
|
|
|
|
private JFXButton settingsBtn; |
|
|
|
|
@FXML |
|
|
|
|
private JFXButton updateBtn; |
|
|
|
|
@FXML |
|
|
|
|
private JFXButton addDirectoryBtn; |
|
|
|
|
@FXML |
|
|
|
|
private JFXButton addStreamSourceBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton aboutBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton settingsBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton debugBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
public JFXButton updateBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton addDirectoryBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXButton addStreamSourceBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXHamburger menuHam; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXToggleButton autoUpdateToggleBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXTextField searchTextField; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
public JFXColorPicker colorPicker; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
public ChoiceBox<String> languageChoisBox = new ChoiceBox<>(); |
|
|
|
|
private JFXHamburger menuHam; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
public ChoiceBox<String> branchChoisBox = new ChoiceBox<>(); |
|
|
|
|
private JFXToggleButton autoUpdateToggleBtn; |
|
|
|
|
@FXML |
|
|
|
|
private JFXToggleButton autoplayToggleBtn; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
public JFXSlider fontsizeSlider; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label homeflixSettingsLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label mainColorLbl; |
|
|
|
|
|
|
|
|
|
private JFXTextField searchTextField; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXColorPicker colorPicker; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private ChoiceBox<String> languageChoisBox = new ChoiceBox<>(); |
|
|
|
|
@FXML |
|
|
|
|
private ChoiceBox<String> branchChoisBox = new ChoiceBox<>(); |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private JFXSlider fontsizeSlider; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label homeflixSettingsLbl; |
|
|
|
|
@FXML |
|
|
|
|
private Label mainColorLbl; |
|
|
|
|
@FXML |
|
|
|
|
private Label fontsizeLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label languageLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label languageLbl; |
|
|
|
|
@FXML |
|
|
|
|
private Label updateLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label branchLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label sourcesLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private Label versionLbl; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
@FXML |
|
|
|
|
private ImageView posterImageView; |
|
|
|
|
private ImageView imv1; |
|
|
|
|
private ImageView imv1; |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private TreeItem<FilmTabelDataType> filmRoot = new TreeItem<>(new FilmTabelDataType("", "", "", "", false, false, imv1)); |
|
|
|
@ -216,46 +193,44 @@ public class MainWindowController {
|
|
|
|
|
private TreeTableColumn<FilmTabelDataType, String> columnEpisode = new TreeTableColumn<>("Episode"); |
|
|
|
|
@FXML |
|
|
|
|
private TreeTableColumn<FilmTabelDataType, ImageView> columnFavorite = new TreeTableColumn<>("Favorite"); |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private TreeItem<SourceDataType> sourceRoot =new TreeItem<>(new SourceDataType("", "")); |
|
|
|
|
@FXML |
|
|
|
|
private TableColumn<SourceDataType, String> sourceColumn; |
|
|
|
|
@FXML |
|
|
|
|
private TableColumn<SourceDataType, String> modeColumn; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private TreeItem<SourceDataType> sourceRoot = new TreeItem<>(new SourceDataType("", "")); |
|
|
|
|
@FXML |
|
|
|
|
private TableColumn<SourceDataType, String> sourceColumn; |
|
|
|
|
@FXML |
|
|
|
|
private TableColumn<SourceDataType, String> modeColumn; |
|
|
|
|
|
|
|
|
|
private boolean menuTrue = false; |
|
|
|
|
private boolean settingsTrue = false; |
|
|
|
|
private boolean autoUpdate = false; |
|
|
|
|
private boolean useBeta = false; |
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName()); |
|
|
|
|
private boolean autoplay = false; |
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName()); |
|
|
|
|
private int hashA = -647380320; |
|
|
|
|
|
|
|
|
|
private String version = "0.6.0"; |
|
|
|
|
private String buildNumber = "141"; |
|
|
|
|
private String versionName = "plasma vampire"; |
|
|
|
|
|
|
|
|
|
private final String version = "0.7.0"; |
|
|
|
|
private final String buildNumber = "151"; |
|
|
|
|
private final String versionName = "toothless dragon"; |
|
|
|
|
private String dialogBtnStyle; |
|
|
|
|
private String color; |
|
|
|
|
private String title; |
|
|
|
|
private String streamUrl; |
|
|
|
|
private String ratingSortType; |
|
|
|
|
private String local; |
|
|
|
|
private String omdbAPIKey; |
|
|
|
|
|
|
|
|
|
// text strings
|
|
|
|
|
private String errorPlay; |
|
|
|
|
private String errorLoad; |
|
|
|
|
private String errorSave; |
|
|
|
|
private String infoText; |
|
|
|
|
private String vlcNotInstalled; |
|
|
|
|
|
|
|
|
|
public double size; |
|
|
|
|
private double fontSize; |
|
|
|
|
private int last; |
|
|
|
|
private int indexTable; |
|
|
|
|
private int indexList; |
|
|
|
|
private int next; |
|
|
|
|
private ResourceBundle bundle; |
|
|
|
|
|
|
|
|
|
private FilmTabelDataType currentTableFilm = new FilmTabelDataType("", "", "", "", false, false, null); |
|
|
|
|
|
|
|
|
|
private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); |
|
|
|
|
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta"); |
|
|
|
|
private ObservableList<FilmTabelDataType> filterData = FXCollections.observableArrayList(); |
|
|
|
@ -267,9 +242,8 @@ public class MainWindowController {
|
|
|
|
|
private ImageView skip_next_black = new ImageView(new Image("icons/ic_skip_next_black_18dp_1x.png")); |
|
|
|
|
private ImageView play_arrow_white = new ImageView(new Image("icons/ic_play_arrow_white_18dp_1x.png")); |
|
|
|
|
private ImageView play_arrow_black = new ImageView(new Image("icons/ic_play_arrow_black_18dp_1x.png")); |
|
|
|
|
private DirectoryChooser directoryChooser = new DirectoryChooser(); |
|
|
|
|
private MenuItem like = new MenuItem("like"); |
|
|
|
|
private MenuItem dislike = new MenuItem("dislike"); //TODO one option (like or dislike)
|
|
|
|
|
private MenuItem like = new MenuItem("like"); |
|
|
|
|
private MenuItem dislike = new MenuItem("dislike"); // TODO one option (like or dislike)
|
|
|
|
|
private ContextMenu menu = new ContextMenu(like, dislike); |
|
|
|
|
private Properties props = new Properties(); |
|
|
|
|
|
|
|
|
@ -290,12 +264,14 @@ public class MainWindowController {
|
|
|
|
|
omdbAPIController = new OMDbAPIController(this, dbController, this.main); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// call all initialize methods
|
|
|
|
|
void init() { |
|
|
|
|
LOGGER.info("Initializing Project-HomeFlix build " + buildNumber); |
|
|
|
|
loadSettings(); |
|
|
|
|
checkAutoUpdate(); |
|
|
|
|
initTabel(); |
|
|
|
|
initActions(); |
|
|
|
|
initUI(); |
|
|
|
|
initActions(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Initialize the tables (treeTableViewfilm and sourcesTable)
|
|
|
|
@ -326,18 +302,18 @@ public class MainWindowController {
|
|
|
|
|
filmsTreeTable.getColumns().add(columnFavorite); |
|
|
|
|
filmsTreeTable.getColumns().add(columnSeason); |
|
|
|
|
filmsTreeTable.getColumns().add(columnEpisode); |
|
|
|
|
filmsTreeTable.getColumns().get(0).setVisible(false); //hide columnStreamUrl (important)
|
|
|
|
|
|
|
|
|
|
// context menu for treeTableViewfilm
|
|
|
|
|
filmsTreeTable.getColumns().get(0).setVisible(false); // hide columnStreamUrl (important)
|
|
|
|
|
|
|
|
|
|
// context menu for treeTableViewfilm
|
|
|
|
|
filmsTreeTable.setContextMenu(menu); |
|
|
|
|
|
|
|
|
|
// sourcesTreeTable
|
|
|
|
|
sourceColumn.setCellValueFactory(cellData -> cellData.getValue().pathProperty()); |
|
|
|
|
modeColumn.setCellValueFactory(cellData -> cellData.getValue().modeProperty()); |
|
|
|
|
sourcesTable.setItems(sourcesList); |
|
|
|
|
|
|
|
|
|
// sourcesTreeTable
|
|
|
|
|
sourceColumn.setCellValueFactory(cellData -> cellData.getValue().pathProperty()); |
|
|
|
|
modeColumn.setCellValueFactory(cellData -> cellData.getValue().modeProperty()); |
|
|
|
|
sourcesTable.setItems(sourcesList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Initializing the actions
|
|
|
|
|
|
|
|
|
|
// Initializing the actions
|
|
|
|
|
private void initActions() { |
|
|
|
|
|
|
|
|
|
HamburgerBackArrowBasicTransition burgerTask = new HamburgerBackArrowBasicTransition(menuHam); |
|
|
|
@ -364,7 +340,7 @@ public class MainWindowController {
|
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { |
|
|
|
|
ObservableList<FilmTabelDataType> helpData; |
|
|
|
|
filterData.removeAll(filterData); |
|
|
|
|
filterData.clear(); |
|
|
|
|
filmRoot.getChildren().removeAll(filmRoot.getChildren()); |
|
|
|
|
|
|
|
|
|
helpData = filmsList; |
|
|
|
@ -412,9 +388,9 @@ public class MainWindowController {
|
|
|
|
|
fontsizeSlider.valueProperty().addListener(new ChangeListener<Number>() { |
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { |
|
|
|
|
setSize(fontsizeSlider.getValue()); |
|
|
|
|
if (title != null) { |
|
|
|
|
dbController.readCache(streamUrl); |
|
|
|
|
setFontSize(fontsizeSlider.getValue()); |
|
|
|
|
if (!getCurrentTitle().isEmpty()) { |
|
|
|
|
dbController.readCache(getCurrentStreamUrl()); |
|
|
|
|
} |
|
|
|
|
// ta1.setFont(Font.font("System", size));
|
|
|
|
|
saveSettings(); |
|
|
|
@ -424,8 +400,8 @@ public class MainWindowController {
|
|
|
|
|
like.setOnAction(new EventHandler<ActionEvent>() { |
|
|
|
|
@Override |
|
|
|
|
public void handle(ActionEvent event) { |
|
|
|
|
dbController.like(streamUrl); |
|
|
|
|
dbController.refresh(streamUrl, indexList); |
|
|
|
|
dbController.like(getCurrentStreamUrl()); |
|
|
|
|
dbController.refresh(getCurrentStreamUrl(), indexList); |
|
|
|
|
refreshTable(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -433,59 +409,41 @@ public class MainWindowController {
|
|
|
|
|
dislike.setOnAction(new EventHandler<ActionEvent>() { |
|
|
|
|
@Override |
|
|
|
|
public void handle(ActionEvent event) { |
|
|
|
|
dbController.dislike(streamUrl); |
|
|
|
|
dbController.refresh(streamUrl, indexList); |
|
|
|
|
dbController.dislike(getCurrentStreamUrl()); |
|
|
|
|
dbController.refresh(getCurrentStreamUrl(), indexList); |
|
|
|
|
refreshTable(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* FIXME fix bug when sort by ASCENDING, wrong order |
|
|
|
|
* FIXME when sorting, series are expanded |
|
|
|
|
*/ |
|
|
|
|
columnFavorite.sortTypeProperty().addListener(new ChangeListener<SortType>() { |
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) { |
|
|
|
|
LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2); |
|
|
|
|
ArrayList<Integer> fav_true = new ArrayList<Integer>(); |
|
|
|
|
ArrayList<Integer> fav_false = new ArrayList<Integer>(); |
|
|
|
|
ObservableList<FilmTabelDataType> helpData; |
|
|
|
|
filterData.removeAll(filterData); |
|
|
|
|
// treeTableViewfilm.getSelectionModel().clearSelection(selected);
|
|
|
|
|
filmRoot.getChildren().removeAll(filmRoot.getChildren()); |
|
|
|
|
|
|
|
|
|
helpData = filmsList; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < helpData.size(); i++) { |
|
|
|
|
if (helpData.get(i).getFavorite() == true) { |
|
|
|
|
fav_true.add(i); |
|
|
|
|
} else { |
|
|
|
|
fav_false.add(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (paramT2.toString().equals("DESCENDING")) { |
|
|
|
|
LOGGER.info("Absteigend"); // Debug, delete?
|
|
|
|
|
for (int i = 0; i < fav_true.size(); i++) { |
|
|
|
|
filterData.add(helpData.get(fav_true.get(i))); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < fav_false.size(); i++) { |
|
|
|
|
filterData.add(helpData.get(fav_false.get(i))); |
|
|
|
|
filmRoot.getChildren().clear(); |
|
|
|
|
filterData.clear(); |
|
|
|
|
|
|
|
|
|
if (paramT2.equals(SortType.DESCENDING)) { |
|
|
|
|
for (FilmTabelDataType film : filmsList) { |
|
|
|
|
if (film.getFavorite()) { |
|
|
|
|
filterData.add(0, film); |
|
|
|
|
} else { |
|
|
|
|
filterData.add(film); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
for (int i = 0; i < fav_false.size(); i++) { |
|
|
|
|
filterData.add(helpData.get(fav_false.get(i))); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < fav_true.size(); i++) { |
|
|
|
|
filterData.add(helpData.get(fav_true.get(i))); |
|
|
|
|
// System.out.println("ascending");
|
|
|
|
|
for (FilmTabelDataType film : filmsList) { |
|
|
|
|
if (!film.getFavorite()) { |
|
|
|
|
filterData.add(0, film); |
|
|
|
|
} else { |
|
|
|
|
filterData.add(film); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LOGGER.info(filterData.size()); // Debug, delete?
|
|
|
|
|
for (int i = 0; i < filterData.size(); i++) { |
|
|
|
|
// LOGGER.info(filterData.get(i).getTitle()+"; "+filterData.get(i).getRating()); // Debugging
|
|
|
|
|
// add filtered data to root node after search
|
|
|
|
|
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(filterData.get(i))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
addDataUI(filterData); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -493,22 +451,25 @@ public class MainWindowController {
|
|
|
|
|
filmsTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() { |
|
|
|
|
@Override |
|
|
|
|
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) { |
|
|
|
|
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected item
|
|
|
|
|
last = indexTable - 1; |
|
|
|
|
next = indexTable + 1; |
|
|
|
|
title = columnTitle.getCellData(indexTable); // get name of selected item
|
|
|
|
|
streamUrl = columnStreamUrl.getCellData(indexTable); // get file path of selected item
|
|
|
|
|
if (filmsTreeTable.getSelectionModel().getSelectedItem() == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (FilmTabelDataType helpData : filmsList) { |
|
|
|
|
if (helpData.getStreamUrl().equals(streamUrl)) { |
|
|
|
|
indexList = filmsList.indexOf(helpData); |
|
|
|
|
currentTableFilm = filmsTreeTable.getSelectionModel().getSelectedItem().getValue(); // set the current film object
|
|
|
|
|
indexTable = filmsTreeTable.getSelectionModel().getSelectedIndex(); // get selected items table index
|
|
|
|
|
for (FilmTabelDataType film : filmsList) { |
|
|
|
|
if (film.equals(currentTableFilm)) { |
|
|
|
|
indexList = filmsList.indexOf(film); // get selected items list index
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (filmsList.get(indexList).getCached()) { |
|
|
|
|
LOGGER.info("loading from cache: " + title); |
|
|
|
|
dbController.readCache(streamUrl); |
|
|
|
|
} else { |
|
|
|
|
last = indexTable - 1; |
|
|
|
|
next = indexTable + 1; |
|
|
|
|
|
|
|
|
|
if (currentTableFilm.getCached() || dbController.searchCache(getCurrentStreamUrl())) { |
|
|
|
|
LOGGER.info("loading from cache: " + getCurrentTitle()); |
|
|
|
|
dbController.readCache(getCurrentStreamUrl()); |
|
|
|
|
} else { |
|
|
|
|
omdbAPIController = new OMDbAPIController(mainWindowController, dbController, main); |
|
|
|
|
Thread omdbAPIThread = new Thread(omdbAPIController); |
|
|
|
|
omdbAPIThread.setName("OMDbAPI"); |
|
|
|
@ -520,15 +481,13 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
// initialize UI elements
|
|
|
|
|
private void initUI() { |
|
|
|
|
debugBtn.setDisable(true); // debugging button for tests
|
|
|
|
|
debugBtn.setVisible(false); |
|
|
|
|
|
|
|
|
|
versionLbl.setText("Version: " + version + " (Build: " + buildNumber + ")"); |
|
|
|
|
fontsizeSlider.setValue(getSize()); |
|
|
|
|
fontsizeSlider.setValue(getFontSize()); |
|
|
|
|
colorPicker.setValue(Color.valueOf(getColor())); |
|
|
|
|
|
|
|
|
|
updateBtn.setFont(Font.font("System", 12)); |
|
|
|
|
autoUpdateToggleBtn.setSelected(isAutoUpdate()); |
|
|
|
|
autoplayToggleBtn.setSelected(isAutoplay()); |
|
|
|
|
languageChoisBox.setItems(languages); |
|
|
|
|
branchChoisBox.setItems(branches); |
|
|
|
|
|
|
|
|
@ -544,48 +503,67 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void playbtnclicked() { |
|
|
|
|
// TODO rework when #19 is coming
|
|
|
|
|
|
|
|
|
|
if (System.getProperty("os.name").contains("Linux")) { |
|
|
|
|
String line; |
|
|
|
|
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; |
|
|
|
|
if (currentTableFilm.getStreamUrl().contains("_rootNode")) { |
|
|
|
|
LOGGER.info("rootNode found, getting last watched episode"); |
|
|
|
|
currentTableFilm = dbController.getLastWatchedEpisode(currentTableFilm.getTitle()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isSupportedFormat(currentTableFilm)) { |
|
|
|
|
new Player(mainWindowController); |
|
|
|
|
} else { |
|
|
|
|
LOGGER.error("using fallback player!"); |
|
|
|
|
if (System.getProperty("os.name").contains("Linux")) { |
|
|
|
|
String line; |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
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 { |
|
|
|
|
if (output.contains("which: no vlc") || output == "") { |
|
|
|
|
JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info", vlcNotInstalled, dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
vlcInfoAlert.showAndWait(); |
|
|
|
|
} else { |
|
|
|
|
try { |
|
|
|
|
new ProcessBuilder("vlc", getCurrentStreamUrl()).start(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
LOGGER.warn("An error has occurred while opening the file!", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if (System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")) { |
|
|
|
|
try { |
|
|
|
|
Runtime.getRuntime().exec(new String[] { "vlc", streamUrl }); // TODO switch to ProcessBuilder
|
|
|
|
|
Desktop.getDesktop().open(new File(getCurrentStreamUrl())); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
showErrorMsg(errorPlay, e); |
|
|
|
|
LOGGER.warn("An error has occurred while opening the file!", e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
LOGGER.error(System.getProperty("os.name") + ", OS is not supported, please contact a developer! "); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} 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! "); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 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 |
|
|
|
|
* @return true if so, false if not |
|
|
|
|
*/ |
|
|
|
|
private boolean isSupportedFormat(FilmTabelDataType film) { |
|
|
|
|
String mimeType = URLConnection.guessContentTypeFromName(film.getStreamUrl()); |
|
|
|
|
return mimeType != null && (mimeType.contains("mp4") || mimeType.contains("vp6")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void openfolderbtnclicked() { |
|
|
|
|
String dest = new File(streamUrl).getParentFile().getAbsolutePath(); |
|
|
|
|
String dest = new File(getCurrentStreamUrl()).getParentFile().getAbsolutePath(); |
|
|
|
|
if (!System.getProperty("os.name").contains("Linux")) { |
|
|
|
|
try { |
|
|
|
|
Desktop.getDesktop().open(new File(dest)); |
|
|
|
@ -609,8 +587,8 @@ public class MainWindowController {
|
|
|
|
|
private void aboutBtnAction() { |
|
|
|
|
String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (Build: " + buildNumber + ") \"" |
|
|
|
|
+ versionName + "\" \n" + infoText; |
|
|
|
|
JFXInfoDialog aboutDialog = new JFXInfoDialog("Project HomeFlix", bodyText, dialogBtnStyle, 350, 200, main.getPane()); |
|
|
|
|
aboutDialog.show(); |
|
|
|
|
JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, dialogBtnStyle, main.getPrimaryStage()); |
|
|
|
|
infoAlert.showAndWait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
@ -625,17 +603,13 @@ public class MainWindowController {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void debugBtnclicked(){ |
|
|
|
|
//for testing
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void addDirectoryBtnAction(){ |
|
|
|
|
File selectedFolder = directoryChooser.showDialog(null); |
|
|
|
|
DirectoryChooser directoryChooser = new DirectoryChooser(); |
|
|
|
|
directoryChooser.setTitle(bundle.getString("addDirectory")); |
|
|
|
|
File selectedFolder = directoryChooser.showDialog(main.getPrimaryStage()); |
|
|
|
|
if (selectedFolder != null && selectedFolder.exists()) { |
|
|
|
|
addSource(selectedFolder.getPath(), "local"); |
|
|
|
|
dbController.refreshDataBase(); |
|
|
|
|
mainWindowController.addSource(selectedFolder.getPath(), "local"); |
|
|
|
|
} else { |
|
|
|
|
LOGGER.error("The selected folder dosen't exist!"); |
|
|
|
|
} |
|
|
|
@ -644,7 +618,7 @@ public class MainWindowController {
|
|
|
|
|
@FXML |
|
|
|
|
private void addStreamSourceBtnAction(){ |
|
|
|
|
FileChooser fileChooser = new FileChooser(); |
|
|
|
|
fileChooser.setTitle("Open Resource File"); |
|
|
|
|
fileChooser.setTitle("addStreamSource"); |
|
|
|
|
File selectedFile = fileChooser.showOpenDialog(main.getPrimaryStage()); |
|
|
|
|
if (selectedFile != null && selectedFile.exists()) { |
|
|
|
|
addSource(selectedFile.getPath(), "stream"); |
|
|
|
@ -670,7 +644,7 @@ public class MainWindowController {
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void autoUpdateToggleBtnAction(){ |
|
|
|
|
if (autoUpdate) { |
|
|
|
|
if (isAutoUpdate()) { |
|
|
|
|
setAutoUpdate(false); |
|
|
|
|
} else { |
|
|
|
|
setAutoUpdate(true); |
|
|
|
@ -678,6 +652,16 @@ public class MainWindowController {
|
|
|
|
|
saveSettings(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
private void autoplayToggleBtnAction(){ |
|
|
|
|
if (isAutoplay()) { |
|
|
|
|
setAutoplay(false); |
|
|
|
|
} else { |
|
|
|
|
setAutoplay(true); |
|
|
|
|
} |
|
|
|
|
saveSettings(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// refresh the selected child of the root node
|
|
|
|
|
private void refreshTable() { |
|
|
|
|
filmRoot.getChildren().get(indexTable).setValue(filmsList.get(indexList)); |
|
|
|
@ -686,32 +670,32 @@ public class MainWindowController {
|
|
|
|
|
/** |
|
|
|
|
* add data from films-list to films-table |
|
|
|
|
*/ |
|
|
|
|
public void addDataUI() { |
|