Browse Source

Merge pull request #10 from Seil0/dev

updated to 0.5.1 "plasma cow"
pull/25/head
Jannik 5 years ago committed by GitHub
parent
commit
6baa47b852
  1. 4
      .classpath
  2. 1
      .gitignore
  3. BIN
      DB_PATH
  4. 5
      README.md
  5. 1
      bin/.gitignore
  6. BIN
      bin/application/DBController.class
  7. BIN
      bin/application/Main.class
  8. 17
      bin/application/MainWindow.fxml
  9. BIN
      bin/application/MainWindowController$1.class
  10. BIN
      bin/application/MainWindowController$2.class
  11. BIN
      bin/application/MainWindowController$3.class
  12. BIN
      bin/application/MainWindowController$4.class
  13. BIN
      bin/application/MainWindowController$5.class
  14. BIN
      bin/application/MainWindowController$6.class
  15. BIN
      bin/application/MainWindowController$7.class
  16. BIN
      bin/application/MainWindowController.class
  17. BIN
      bin/application/apiQuery.class
  18. BIN
      bin/application/streamUiData.class
  19. BIN
      bin/application/tableData.class
  20. BIN
      bin/application/updater.class
  21. BIN
      bin/libraries/commons-io-2.5.jar
  22. BIN
      bin/libraries/commons-lang3-3.5.jar
  23. BIN
      bin/libraries/jfoenix-1.2.0.jar
  24. BIN
      bin/libraries/jfoenix-1.3.0.jar
  25. 1
      bin/recources/HomeFlix-Local_de_DE.properties
  26. 1
      bin/recources/HomeFlix-Local_en_US.properties
  27. 238
      src/application/DBController.java
  28. 110
      src/application/Main.java
  29. 17
      src/application/MainWindow.fxml
  30. 241
      src/application/MainWindowController.java
  31. 285
      src/application/apiQuery.java
  32. 52
      src/application/tableData.java
  33. 55
      src/application/updater.java
  34. BIN
      src/libraries/commons-io-2.5.jar
  35. BIN
      src/libraries/commons-lang3-3.5.jar
  36. BIN
      src/libraries/jfoenix-1.2.0.jar
  37. BIN
      src/libraries/jfoenix-1.3.0.jar
  38. 1
      src/recources/HomeFlix-Local_de_DE.properties
  39. 1
      src/recources/HomeFlix-Local_en_US.properties
  40. BIN
      updates/ProjectHomeFlix.jar
  41. 2
      updates/buildNumber.txt

4
.classpath

@ -4,8 +4,8 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="src/libraries/minimal-json-0.9.4.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-lang3-3.5.jar"/>
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.16.1.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.2.0.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.3.0.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-io-2.5.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored

@ -46,4 +46,5 @@ Network Trash Folder
Temporary Items
.apdisk
config.xml
.directory

BIN
DB_PATH

Binary file not shown.

5
README.md

@ -6,13 +6,12 @@ The dev branch is **only merged** into master when a **new release** is released
Librarys used in this Project:
JFoenix: https://github.com/jfoenixadmin/JFoenix
minimal-json: https://github.com/ralfstx/minimal-json
Commons Lang: https://commons.apache.org/proper/commons-lang/
minimal-json: https://github.com/ralfstx/minimal-json
sqlite-jdbc: https://github.com/xerial/sqlite-jdbc
## Installation
[wiki](https://github.com/Seil0/Project-HomeFlix/wiki)
Project HomeFlix © 2016-2017 Software Development Kellerkinder (SDK)
Project HomeFlix © 2016-2017 Kellerkinder ([Seil0](https://github.com/Seil0), [Windoofs](https://github.com/Windoofs))
www.kellerkinder.xyz

1
bin/.gitignore vendored

@ -0,0 +1 @@
/application/

BIN
bin/application/DBController.class

Binary file not shown.

BIN
bin/application/Main.class

Binary file not shown.

17
bin/application/MainWindow.fxml

@ -3,11 +3,11 @@
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXColorPicker?>
<?import com.jfoenix.controls.JFXSlider?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.JFXToggleButton?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.Image?>
@ -20,9 +20,12 @@
<AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="88.0" />
<JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" />
<TextFlow fx:id="textFlow" layoutX="496.0" layoutY="131.0" prefHeight="200.0" prefWidth="200.0" visible="false" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="220.0" AnchorPane.topAnchor="44.0" />
<ScrollPane fx:id="scrollPane" fitToWidth="true" layoutX="408.0" layoutY="44.0" prefHeight="544.0" prefWidth="320.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="408.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0">
<content>
<TextFlow fx:id="textFlow" accessibleRole="TEXT_AREA" maxHeight="544.0" maxWidth="320.0" visible="true" />
</content>
</ScrollPane>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="500.0" prefWidth="375.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="88.0" />
<JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
@ -31,7 +34,7 @@
<font>
<Font name="System Bold" size="14.0" />
</font></JFXButton>
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="44.0">
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="370.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="44.0">
<font>
<Font name="Arial" size="12.0" />
</font></JFXTextField>
@ -78,8 +81,8 @@
<AnchorPane fx:id="streamingSettingsAnchor" layoutX="138.0" layoutY="33.0" prefHeight="566.0" prefWidth="760.0" style="-fx-background-color: #FFFFFF;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children>
<JFXTextField fx:id="tfStreamingPath" layoutX="14.0" layoutY="14.0" onAction="#tfStreamingPathAction" prefWidth="250.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0" />
<JFXButton fx:id="streamingDirectoryBtn" layoutX="263.0" layoutY="2.0" onAction="#streamingDirectoryBtnAction" AnchorPane.leftAnchor="260.0" AnchorPane.topAnchor="5.0" />
<TableView fx:id="tableViewStreamingdata" layoutX="14.0" layoutY="44.0" prefHeight="200.0" prefWidth="300.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="40.0" />
<JFXButton fx:id="streamingDirectoryBtn" layoutX="263.0" layoutY="2.0" onAction="#streamingDirectoryBtnAction" prefHeight="25.0" prefWidth="115.0" AnchorPane.leftAnchor="260.0" AnchorPane.topAnchor="5.0" />
<TableView fx:id="tableViewStreamingdata" layoutX="14.0" layoutY="44.0" prefHeight="517.0" prefWidth="370.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="40.0" />
</children></AnchorPane>
<AnchorPane fx:id="settingsAnchor" layoutX="160.0" layoutY="44.0" prefHeight="566.0" prefWidth="760.0" style="-fx-background-color: #FFFFFF;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children>

BIN
bin/application/MainWindowController$1.class

Binary file not shown.

BIN
bin/application/MainWindowController$2.class

Binary file not shown.

BIN
bin/application/MainWindowController$3.class

Binary file not shown.

BIN
bin/application/MainWindowController$4.class

Binary file not shown.

BIN
bin/application/MainWindowController$5.class

Binary file not shown.

BIN
bin/application/MainWindowController$6.class

Binary file not shown.

BIN
bin/application/MainWindowController$7.class

Binary file not shown.

BIN
bin/application/MainWindowController.class

Binary file not shown.

BIN
bin/application/apiQuery.class

Binary file not shown.

BIN
bin/application/streamUiData.class

Binary file not shown.

BIN
bin/application/tableData.class

Binary file not shown.

BIN
bin/application/updater.class

Binary file not shown.

BIN
bin/libraries/commons-io-2.5.jar

Binary file not shown.

BIN
bin/libraries/commons-lang3-3.5.jar

Binary file not shown.

BIN
bin/libraries/jfoenix-1.2.0.jar

Binary file not shown.

BIN
bin/libraries/jfoenix-1.3.0.jar

Binary file not shown.

1
bin/recources/HomeFlix-Local_de_DE.properties

@ -8,6 +8,7 @@ openFolder = Ordner \u00F6ffnen
chooseFolder = Ordner ausw\u00E4hlen
fontSize = Schriftgr\u00F6\u00DFe:
checkUpdates = Auf Update pr\u00FCfen
checkingUpdates = Es wird nach Updates gesucht...
updateBtnavail = Update verf\u00FCgbar
updateBtnNotavail = Kein Update verf\u00FCgbar
autoUpdate = beim Start nach Updates suchen:

1
bin/recources/HomeFlix-Local_en_US.properties

@ -8,6 +8,7 @@ openFolder = open Folder
chooseFolder = choose Directory
fontSize = font size:
checkUpdates = check for updates
checkingUpdates = checking for updates...
updateBtnavail = update available
updateBtnNotavail = no update available
autoUpdate = check at startup for updates:

238
src/application/DBController.java

@ -1,7 +1,7 @@
/**
* @author Jannik
* DBController for Project HomeFlix
* connection is in manual commit!
* TODO arraylists not string -> streamUIData
*/
package application;
@ -23,17 +23,21 @@ import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonValue;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class DBController {
public DBController(MainWindowController m) {
public DBController(MainWindowController m, Main main) {
mainWindowController = m;
this.main = main;
}
private MainWindowController mainWindowController;
private Main main;
private String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; //path to database file
private Image favorite_black = new Image("recources/icons/ic_favorite_black_18dp_1x.png");
private Image favorite_border_black = new Image("recources/icons/ic_favorite_border_black_18dp_1x.png");
@ -57,15 +61,13 @@ public class DBController {
try {
// create a database connection
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
// Statement statement = connection.createStatement();
// statement.setQueryTimeout(30); // set timeout to 30 sec. TODO don't know what to do with this
connection.setAutoCommit(false); //AutoCommit to false -> manual commit is active
// fuelleDatenbank();
} catch (SQLException e) {
// if the error message is "out of memory", it probably means no database file is found
System.err.println(e.getMessage());
}
//close connection -> at the moment this kills the program
// finally {
// try {
// if (connection != null)
@ -85,8 +87,8 @@ public class DBController {
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, favIcon)");
stmt.executeUpdate("create table if not exists film_streaming (year, season, episode, rating, resolution, titel, streamUrl, favIcon)");
stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, favIcon, cached)");
stmt.executeUpdate("create table if not exists film_streaming (year, season, episode, rating, resolution, titel, streamUrl, favIcon, cached)");
stmt.close();
} catch (SQLException e1) {
e1.printStackTrace();
@ -144,13 +146,12 @@ public class DBController {
System.out.println("films in directory: "+filmsAll.size());
System.out.println("filme in db: "+filmsdbAll.size());
if(filmsdbAll.size() == 0){
System.out.println("creating entries ...");
try{
ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?)");
psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)");
ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?, ?)");
psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?, ?)");
if(mainWindowController.getPath().equals("") || mainWindowController.getPath() == null){
System.out.println("Kein Pfad angegeben"); //if path == null or ""
@ -161,7 +162,8 @@ public class DBController {
ps.setString(2, cutOffEnd(entries[j])); //name as String without ending 2. column
ps.setString(3,entries[j]); //path as String 3. column
ps.setString(4, "favorite_border_black");
ps.addBatch(); // add command to prepared statement
ps.setBoolean(5, false);
ps.addBatch(); // add command to prepared statement
}
}
@ -182,6 +184,7 @@ public class DBController {
psS.setString(6, item.asObject().getString("titel",""));
psS.setString(7, item.asObject().getString("streamUrl", ""));
psS.setString(8, "favorite_border_black");
psS.setBoolean(9, false);
psS.addBatch(); // add command to prepared statement
}
} catch (IOException e) {
@ -189,7 +192,7 @@ public class DBController {
}
}
}
ps.executeBatch(); //execute statement to write entries into table
ps.executeBatch(); //execute statement to write entries into table
psS.executeBatch();
connection.commit();
ps.close();
@ -203,15 +206,26 @@ public class DBController {
try {
try {
checkAddEntry();
checkAddEntry(); //check if added a new file
} catch (IOException e) {
e.printStackTrace();
} //check if added a new file
checkRemoveEntry(); //check if removed a file
}
checkRemoveEntry(); //check if removed a file
} catch (SQLException e) {
e.printStackTrace();
}
}
//start of cache-table
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate( "create table if not exists cache (streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer," //streamUrl is primary key
+" Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes, imdbID, Type, Poster, Response)");
stmt.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
//loading data from database to mainWindowController
@ -220,24 +234,24 @@ public class DBController {
try {
//load local Data
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY titel");
while (rs.next()) {
if(rs.getString(4).equals("favorite_black")){
mainWindowController.newData.add( new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black)));
mainWindowController.localFilms.add( new tableData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black),rs.getBoolean(5)));
}else{
mainWindowController.newData.add( new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_border_black)));
mainWindowController.localFilms.add( new tableData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_border_black),rs.getBoolean(5)));
}
}
stmt.close();
rs.close();
//load streaming Data TODO check if there are streaming data before loading -> maybe there is an issue now
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
//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;");
while (rs.next()) {
if(rs.getString(8).equals("favorite_black")){
mainWindowController.streamData.add(new streamUiData(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)));
mainWindowController.streamingFilms.add(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.streamData.add(new streamUiData(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)));
mainWindowController.streamingFilms.add(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();
@ -250,7 +264,7 @@ public class DBController {
}
//Refreshes the data in mainWindowController.newDaten and mainWindowController.streamData
//TODO 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
//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
void refresh(String name,int i) throws SQLException{
System.out.println("refresh ...");
Statement stmt;
@ -259,9 +273,9 @@ public class DBController {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" );
if(rs.getString(4).equals("favorite_black")){
mainWindowController.newData.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black)));
mainWindowController.localFilms.set(i, new tableData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black),rs.getBoolean(5)));
}else{
mainWindowController.newData.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_border_black)));
mainWindowController.localFilms.set(i, new tableData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_border_black),rs.getBoolean(5)));
}
stmt.close();
rs.close();
@ -270,9 +284,9 @@ public class DBController {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" );
if(rs.getString(8).equals("favorite_black")){
mainWindowController.streamData.set(i,new streamUiData(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)));
mainWindowController.streamingFilms.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.streamData.set(i,new streamUiData(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)));
mainWindowController.streamingFilms.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();
@ -282,7 +296,10 @@ public class DBController {
}
}
}
/**
* check if there are any entries that have been removed from the film-directory
* @throws SQLException
*/
private void checkRemoveEntry() throws SQLException{
System.out.println("checking for entrys to remove to DB ...");
Statement stmt = connection.createStatement();
@ -309,17 +326,25 @@ public class DBController {
}
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{ //TODO sort alphabetical
/**
* check if there are new films in the film-directory
* @throws SQLException
* @throws FileNotFoundException
* @throws IOException
* if lastName != filmsStreamData.get(b) then set i = 0, file changed
*/
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{
String lastName = "";
System.out.println("checking for entrys to add to DB ...");
String[] entries = new File(mainWindowController.getPath()).list();
Statement stmt = connection.createStatement();
PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)");;
PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?, ?)");
int i=0;
for(int a=0; a<filmsDir.size(); a++){
if(filmsdbLocal.contains(filmsDir.get(a))){
}else{
stmt.executeUpdate("insert into film_local values (0, '"+cutOffEnd(entries[a])+"', '"+entries[a]+"','favorite_border_black')");
stmt.executeUpdate("insert into film_local values (0, '"+cutOffEnd(entries[a])+"', '"+entries[a]+"','favorite_border_black',0)");
connection.commit();
stmt.close();
System.out.println("added \""+filmsDir.get(a)+"\" to databsae");
@ -327,16 +352,20 @@ public class DBController {
}
for(int b=0; b<filmsStreamURL.size(); b++){
if(filmsdbStreamURL.contains(filmsStreamURL.get(b))){
}else{
if(filmsdbStreamURL.contains(filmsStreamURL.get(b))) {
} else {
if(lastName != "" && lastName != filmsStreamData.get(b)) {
i = 0;
}
lastName = filmsStreamData.get(b);
JsonObject object = Json.parse(new FileReader(filmsStreamData.get(b))).asObject();
JsonArray items = object.get("entries").asArray();
System.out.println(items.size()+", "+i);
System.out.println(items.size()+", "+i+"; "+b);
String streamURL = items.get(i).asObject().getString("streamUrl","");
String titel = items.get(i).asObject().getString("titel","");
if(streamURL.equals(filmsStreamURL.get(b))){
System.out.println("hinzuf<EFBFBD>gen \""+titel+"\"");
System.out.println("hinzufügen \""+titel+"\"");
ps.setInt(1, items.get(i).asObject().getInt("year", 0));
ps.setInt(2, items.get(i).asObject().getInt("season", 0));
@ -346,9 +375,8 @@ public class DBController {
ps.setString(6, items.get(i).asObject().getString("titel",""));
ps.setString(7, items.get(i).asObject().getString("streamUrl", ""));
ps.setString(8, "favorite_border_black");
ps.setBoolean(9, false);
ps.addBatch(); // adds the entry
// stmt.executeUpdate("insert into film_streaming values ("+items.get(i).asObject().getInt("year", 0)+", "+items.get(i).asObject().getInt("season", 0)+", "+items.get(i).asObject().getInt("episode", 0)+", 0, '"+items.get(i).asObject().getString("resolution", ""+"', '"+items.get(i).asObject().getString("titel","")+"', '"+items.get(i).asObject().getString("streamUrl", "")+"')"));
}
i++;
}
@ -359,7 +387,7 @@ public class DBController {
}
void ausgeben(){
System.out.println("Eintraege ausgeben ... \n");
System.out.println("Outputting all entries ... \n");
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
@ -367,7 +395,8 @@ public class DBController {
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
System.out.println(rs.getString(4)+"\n");
System.out.println(rs.getString(4));
System.out.println(rs.getString(5)+"\n");
}
stmt.close();
rs.close();
@ -383,7 +412,8 @@ public class DBController {
System.out.println(rs.getString(5));
System.out.println(rs.getString(6));
System.out.println(rs.getString(7));
System.out.println(rs.getString(8)+"\n");
System.out.println(rs.getString(8));
System.out.println(rs.getString(9)+"\n");
}
stmt.close();
rs.close();
@ -394,7 +424,7 @@ public class DBController {
}
}
//gibt die Favorisierung eines bestimmten Films
//get favorite status
void getFavStatus(String name){
try{
Statement stmt = connection.createStatement();
@ -416,7 +446,7 @@ public class DBController {
}
}
//setzt die Defavorisierung eines bestimmten Films
//set rating=0 and favorite_border_black
void dislike(String name,String streamUrl){
System.out.println("defavorisieren ...");
try{
@ -438,7 +468,7 @@ public class DBController {
e1.printStackTrace();
}
}
//setzt die Favorisierung eines bestimmten Films
//set rating=1 and favorite_black
void like(String name,String streamUrl){
System.out.println("favorisieren ...");
try{
@ -461,6 +491,124 @@ public class DBController {
}
}
void setCached(String streamUrl) throws SQLException{
try{
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_local SET cached=1 WHERE streamUrl='"+streamUrl+"';");
connection.commit();
stmt.close();
}catch(SQLException e){
System.out.println("Ups! an error occured!");
e.printStackTrace();
}
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE film_streaming SET cached=1 WHERE streamUrl='"+streamUrl+"';");
connection.commit();
stmt.close();
} catch (SQLException e1) {
System.out.println("Ups! an error occured!");
e1.printStackTrace();
}
}
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 Type, String imdbVotes, String imdbID, String Poster, String Response) throws SQLException{
PreparedStatement ps = connection.prepareStatement("insert into cache values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
System.out.println("adding to cache: " + Title);
ps.setString(1,streamUrl);
ps.setString(2,Title);
ps.setString(3,Year);
ps.setString(4,Rated);
ps.setString(5,Released);
ps.setString(6,Runtime);
ps.setString(7,Genre);
ps.setString(8,Director);
ps.setString(9,Writer);
ps.setString(10,Actors);
ps.setString(11,Plot);
ps.setString(12,Language);
ps.setString(13,Country);
ps.setString(14,Awards);
ps.setString(15,Metascore);
ps.setString(16,imdbRating);
ps.setString(17,imdbVotes);
ps.setString(18,imdbID);
ps.setString(19,Type);
ps.setString(20,Poster);
ps.setString(21,Response);
ps.addBatch();
ps.executeBatch();
connection.commit();
ps.close();
System.out.println("done!");
}
void readCache(String streamUrl){
try{
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM cache WHERE streamUrl='"+streamUrl+"';");
ArrayList<Text> nameText = new ArrayList<Text>();
ArrayList<Text> responseText = new ArrayList<Text>();
String fontFamily = main.getFONT_FAMILY();
Image im;
int fontSize = (int) Math.round(mainWindowController.size);
int j=2;
nameText.add(0, new Text(mainWindowController.title+": "));
nameText.add(1, new Text(mainWindowController.year+": "));
nameText.add(2, new Text(mainWindowController.rating+": "));
nameText.add(3, new Text(mainWindowController.publishedOn+": "));
nameText.add(4, new Text(mainWindowController.duration+": "));
nameText.add(5, new Text(mainWindowController.genre+": "));
nameText.add(6, new Text(mainWindowController.director+": "));
nameText.add(7, new Text(mainWindowController.writer+": "));
nameText.add(8, new Text(mainWindowController.actors+": "));
nameText.add(9, new Text(mainWindowController.plot+": "));
nameText.add(10, new Text(mainWindowController.language+": "));
nameText.add(11, new Text(mainWindowController.country+": "));
nameText.add(12, new Text(mainWindowController.awards+": "));
nameText.add(13, new Text(mainWindowController.metascore+": "));
nameText.add(14, new Text(mainWindowController.imdbRating+": "));
nameText.add(15, new Text(mainWindowController.type+": "));
for(int i=0; i<15; i++){
responseText.add(new Text(rs.getString(j)+"\n"));
j++;
}
responseText.add(new Text(rs.getString(19)+"\n"));
im = new Image(new File(rs.getString(20)).toURI().toString());
stmt.close();
rs.close();
for(int i=0; i<nameText.size(); i++){
nameText.get(i).setFont(Font.font (fontFamily, FontWeight.BOLD, fontSize));
responseText.get(i).setFont(Font.font(fontFamily, fontSize));
}
mainWindowController.textFlow.getChildren().remove(0, mainWindowController.textFlow.getChildren().size());
for(int i=0;i<nameText.size(); i++){
mainWindowController.textFlow.getChildren().addAll(nameText.get(i),responseText.get(i));
}
try{
mainWindowController.image1.setImage(im);
}catch (Exception e){
mainWindowController.image1.setImage(new Image("recources/icons/close_black_2048x2048.png"));
e.printStackTrace();
}
mainWindowController.image1.setImage(im);
}catch (SQLException e) {
System.out.println("Ups! an error occured!");
e.printStackTrace();
}
}
//removes the ending
private String cutOffEnd (String str) {

110
src/application/Main.java

@ -19,6 +19,7 @@
* MA 02110-1301, USA.
*
*/
package application;
import java.io.File;
@ -40,24 +41,26 @@ import javafx.stage.Stage;
public class Main extends Application {
private Stage primaryStage;
Stage primaryStage;
private String path;
private String streamingPathWin = System.getProperty("user.home") + "\\Documents\\HomeFlix";
private String streamingPathLinux = System.getProperty("user.home") + "/HomeFlix";
private String color = "ee3523";
private String autoUpdate = "0";
private String mode = "local"; //local or streaming
String currentWorkingDirectory;
private String COLOR = "ee3523";
private String FONT_FAMILY = "System";
private String mode = "local"; //local or streaming TODO
private String local = System.getProperty("user.language")+"_"+System.getProperty("user.country");
private double size = 12;
private boolean AUTO_UPDATE = false;
private double FONT_SIZE = 17;
private ResourceBundle bundle;
private MainWindowController mainWindowController;
private File dirWin = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); //Windows: C:/Users/"User"/Documents/HomeFlix
private File dirLinux = new File(System.getProperty("user.home") + "/HomeFlix"); //Linux: /home/"User"/HomeFlix
private File fileWin = new File(dirWin + "/config.xml"); //Windows: C:/Users/"User"/Documents/HomeFlix/config.xml
private File fileLinux = new File(dirLinux + "/config.xml"); //Linux: /home/"User"/HomeFlix/config.xml
private File directory;
private File settingsFile;
private File posterCache;
private String dirWin = System.getProperty("user.home") + "/Documents/HomeFlix"; //Windows: C:/Users/"User"/Documents/HomeFlix
private String dirLinux = System.getProperty("user.home") + "/HomeFlix"; //Linux: /home/"User"/HomeFlix
@Override
public void start(Stage primaryStage) {
public void start(Stage primaryStage) throws IOException {
currentWorkingDirectory = new java.io.File( "." ).getCanonicalPath();
this.primaryStage = primaryStage;
mainWindow();
}
@ -74,41 +77,42 @@ public class Main extends Application {
primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/recources/Homeflix_Icon_64x64.png"))); //adds application icon
mainWindowController = loader.getController(); //Link of FXMLController and controller class
mainWindowController.setAutoUpdate(autoUpdate); //set auto-update
mainWindowController.setAutoUpdate(AUTO_UPDATE); //set auto-update
mainWindowController.setCurrentWorkingDirectory(currentWorkingDirectory);
mainWindowController.setMain(this); //call setMain
//Linux if directory exists -> check config.xml
if(System.getProperty("os.name").equals("Linux")){
if(dirLinux.exists() != true){
dirLinux.mkdir();
}else if(fileLinux.exists() != true){
mainWindowController.setPath(firstStart());
mainWindowController.setStreamingPath(streamingPathLinux);
mainWindowController.setColor(color);
mainWindowController.setSize(size);
mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setLocal(local);
mainWindowController.setMode(mode);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}
//windows
}else{
if(dirWin.exists() != true){
dirWin.mkdir();
}else if(fileWin.exists() != true){
mainWindowController.setPath(firstStart());
mainWindowController.setStreamingPath(streamingPathWin);
mainWindowController.setColor(color);
mainWindowController.setSize(size);
mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setLocal(local);
mainWindowController.setMode(mode);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes itself
}
/**Linux else Windows, check if directory & config exist
* Windows: config file: C:/Users/"User"/Documents/HomeFlix/config.xml
* directory: C:/Users/"User"/Documents/HomeFlix
* Linux: config file: /home/"User"/HomeFlix/config.xml
* directory: /home/"User"/HomeFlix
*/
if(System.getProperty("os.name").equals("Linux")) {
directory = new File(dirLinux);
settingsFile = new File(dirLinux + "/config.xml");
} else {
directory = new File(dirWin);
settingsFile = new File(dirWin + "/config.xml");
}
posterCache = new File(directory+"/posterCache");
if(!settingsFile.exists()){
directory.mkdir();
mainWindowController.setPath(firstStart());
mainWindowController.setStreamingPath(directory.getAbsolutePath());
mainWindowController.setColor(COLOR);
mainWindowController.setSize(FONT_SIZE);
mainWindowController.setAutoUpdate(AUTO_UPDATE);
mainWindowController.setLocal(local);
mainWindowController.setMode(mode);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again (preventing Bugs)
System.exit(0); //finishes it self
}
if(!posterCache.exists()) {
posterCache.mkdir();
}
mainWindowController.loadSettings();
@ -166,4 +170,20 @@ public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
public String getFONT_FAMILY() {
return FONT_FAMILY;
}
public void setFONT_FAMILY(String FONT_FAMILY) {
this.FONT_FAMILY = FONT_FAMILY;
}
public File getPosterCache() {
return posterCache;
}
public void setPosterCache(File posterCache) {
this.posterCache = posterCache;
}
}

17
src/application/MainWindow.fxml

@ -3,11 +3,11 @@
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXColorPicker?>
<?import com.jfoenix.controls.JFXSlider?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.JFXToggleButton?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.Image?>
@ -20,9 +20,12 @@
<AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="88.0" />
<JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" />
<TextFlow fx:id="textFlow" layoutX="496.0" layoutY="131.0" prefHeight="200.0" prefWidth="200.0" visible="false" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="220.0" AnchorPane.topAnchor="44.0" />
<ScrollPane fx:id="scrollPane" fitToWidth="true" layoutX="408.0" layoutY="44.0" prefHeight="544.0" prefWidth="320.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="408.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0">
<content>
<TextFlow fx:id="textFlow" accessibleRole="TEXT_AREA" maxHeight="544.0" maxWidth="320.0" visible="true" />
</content>
</ScrollPane>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="500.0" prefWidth="375.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="88.0" />
<JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
@ -31,7 +34,7 @@
<font>
<Font name="System Bold" size="14.0" />
</font></JFXButton>
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="44.0">
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="370.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="568.0" AnchorPane.topAnchor="44.0">
<font>
<Font name="Arial" size="12.0" />
</font></JFXTextField>
@ -78,8 +81,8 @@
<AnchorPane fx:id="streamingSettingsAnchor" layoutX="138.0" layoutY="33.0" prefHeight="566.0" prefWidth="760.0" style="-fx-background-color: #FFFFFF;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children>
<JFXTextField fx:id="tfStreamingPath" layoutX="14.0" layoutY="14.0" onAction="#tfStreamingPathAction" prefWidth="250.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0" />
<JFXButton fx:id="streamingDirectoryBtn" layoutX="263.0" layoutY="2.0" onAction="#streamingDirectoryBtnAction" AnchorPane.leftAnchor="260.0" AnchorPane.topAnchor="5.0" />
<TableView fx:id="tableViewStreamingdata" layoutX="14.0" layoutY="44.0" prefHeight="200.0" prefWidth="300.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="40.0" />
<JFXButton fx:id="streamingDirectoryBtn" layoutX="263.0" layoutY="2.0" onAction="#streamingDirectoryBtnAction" prefHeight="25.0" prefWidth="115.0" AnchorPane.leftAnchor="260.0" AnchorPane.topAnchor="5.0" />
<TableView fx:id="tableViewStreamingdata" layoutX="14.0" layoutY="44.0" prefHeight="517.0" prefWidth="370.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="40.0" />
</children></AnchorPane>
<AnchorPane fx:id="settingsAnchor" layoutX="160.0" layoutY="44.0" prefHeight="566.0" prefWidth="760.0" style="-fx-background-color: #FFFFFF;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children>

241
src/application/MainWindowController.java

@ -41,12 +41,9 @@ import java.util.ArrayList;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import org.apache.commons.lang3.SystemUtils;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXColorPicker;
import com.jfoenix.controls.JFXSlider;
import com.jfoenix.controls.JFXTextArea;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXToggleButton;
@ -99,17 +96,15 @@ public class MainWindowController {
@FXML
private VBox sideMenuVBox;
@FXML
private TreeTableView<streamUiData> treeTableViewfilm;
@FXML
private TableView<streamUiData> tableViewStreamingdata;
private TreeTableView<tableData> treeTableViewfilm;
@FXML
JFXTextArea ta1;
private TableView<tableData> tableViewStreamingdata;
@FXML
TextFlow textFlow;
@FXML
ScrollPane scrollPane;
@FXML
private JFXButton menubtn;
private JFXButton menubtn; //TODO switch to hamburger menu
@FXML
private JFXButton playbtn;
@FXML
@ -159,37 +154,37 @@ public class MainWindowController {
private ImageView imv1;
@FXML
TreeItem<streamUiData> root = new TreeItem<>(new streamUiData(1, 1, 1, 5.0,"1", "filme","1", imv1));
TreeItem<tableData> root = new TreeItem<>(new tableData(1, 1, 1, 5.0,"1", "filme","1", imv1, false));
@FXML
TreeTableColumn<streamUiData, ImageView> columnRating = new TreeTableColumn<>("Rating");
TreeTableColumn<tableData, ImageView> columnRating = new TreeTableColumn<>("Rating");
@FXML
TreeTableColumn<streamUiData, String> columnTitel = new TreeTableColumn<>("Titel");
TreeTableColumn<tableData, String> columnTitel = new TreeTableColumn<>("Titel");
@FXML
TreeTableColumn<streamUiData, String> columnStreamUrl = new TreeTableColumn<>("File Name");
TreeTableColumn<tableData, String> columnStreamUrl = new TreeTableColumn<>("File Name");
@FXML
TreeTableColumn<streamUiData, String> columnResolution = new TreeTableColumn<>("Resolution");
TreeTableColumn<tableData, String> columnResolution = new TreeTableColumn<>("Resolution");
@FXML
TreeTableColumn<streamUiData, Integer> columnYear = new TreeTableColumn<>("Year");
TreeTableColumn<tableData, Integer> columnYear = new TreeTableColumn<>("Year");
@FXML
TreeTableColumn<streamUiData, Integer> columnSeason = new TreeTableColumn<>("Season");
TreeTableColumn<tableData, Integer> columnSeason = new TreeTableColumn<>("Season");
@FXML
TreeTableColumn<streamUiData, Integer> columnEpisode = new TreeTableColumn<>("Episode");
TreeTableColumn<tableData, Integer> columnEpisode = new TreeTableColumn<>("Episode");
@FXML
private TreeItem<streamUiData> streamingRoot =new TreeItem<>(new streamUiData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1", imv1));
private TreeItem<tableData> streamingRoot =new TreeItem<>(new tableData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1", imv1, false));
@FXML
private TableColumn<streamUiData, String> dataNameColumn = new TableColumn<>("Datei Name");
private TableColumn<tableData, String> dataNameColumn = new TableColumn<>("Datei Name");
@FXML
private TableColumn<streamUiData, String> dataNameEndColumn = new TableColumn<>("Datei Name mit Endung");
private TableColumn<tableData, String> dataNameEndColumn = new TableColumn<>("Datei Name mit Endung");
private boolean menutrue = false; //saves the position of menubtn (opened or closed)
private boolean menutrue = false; //saves the position of menuBtn (opened or closed)
private boolean settingstrue = false;
private boolean streamingSettingsTrue = false;
private boolean autoUpdate = false;
static boolean firststart = false;
private int hashA = -2055934614;
private String version = "0.5.0";
private String buildNumber = "117";
private String version = "0.5.1";
private String buildNumber = "125";
private String versionName = "plasma cow";
private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt";
private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt";
@ -200,22 +195,21 @@ public class MainWindowController {
String errorUpdateD;
String errorUpdateV;
String noFilmFound;
private String errorPlay;
private String errorOpenStream;
private String errorMode;
private String errorLoad;
private String errorSave;
String noFilmFound;
private String infoText;
private String linuxBugText;
private String vlcNotInstalled;
private String aktBuildNumber;
private String currentWorkingDirectory;
private String path;
private String streamingPath;
private String color;
private String Name;
private String name;
private String datPath;
private String autoUpdate;
private String mode;
@SuppressWarnings("unused")
private String ratingSortType;
@ -236,7 +230,7 @@ public class MainWindowController {
String metascore;
String imdbRating;
String type;
private double size;
double size;
private int last;
private int selected;
private int next;
@ -244,11 +238,11 @@ public class MainWindowController {
private File selectedStreamingFolder;
ResourceBundle bundle;
private ObservableList<streamUiData> filterData = FXCollections.observableArrayList();
private ObservableList<String> locals = FXCollections.observableArrayList("english (en_US)", "deutsch (de_DE)");
ObservableList<streamUiData> newData = FXCollections.observableArrayList(); //TODO rename to localFilms
ObservableList<streamUiData> streamData = FXCollections.observableArrayList(); //TODO rename to streamingFilms
ObservableList<streamUiData> streamingData = FXCollections.observableArrayList();
private ObservableList<tableData> filterData = FXCollections.observableArrayList();
private ObservableList<String> locals = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)");
ObservableList<tableData> localFilms = FXCollections.observableArrayList();
ObservableList<tableData> streamingFilms = FXCollections.observableArrayList();
ObservableList<tableData> streamingData = FXCollections.observableArrayList();
private ImageView menu_icon_black = new ImageView(new Image("recources/icons/menu_icon_black.png"));
private ImageView menu_icon_white = new ImageView(new Image("recources/icons/menu_icon_white.png"));
private ImageView skip_previous_white = new ImageView(new Image("recources/icons/ic_skip_previous_white_18dp_1x.png"));
@ -263,6 +257,7 @@ public class MainWindowController {
private ContextMenu menu = new ContextMenu(like, dislike);
Properties props = new Properties();
private Main main;
private updater Updater;
private apiQuery ApiQuery;
DBController dbController;
@ -293,8 +288,9 @@ public class MainWindowController {
@FXML
private void playbtnclicked(){
if(SystemUtils.IS_OS_LINUX){
System.out.println("This is Linux");
System.out.println(System.getProperty("os.name"));
if(System.getProperty("os.name").contains("Linux")){
System.out.println("This is "+System.getProperty("os.name"));
String line;
String output = "";
Process p;
@ -320,6 +316,7 @@ public class MainWindowController {
alert.setHeaderText("");
alert.setTitle("Info");
alert.setContentText(linuxBugText);
alert.initOwner(main.primaryStage);
alert.showAndWait();
}else{
try {
@ -328,8 +325,8 @@ public class MainWindowController {
showErrorMsg(errorPlay,e);
}
}
}else if(SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_MAC_OSX){
System.out.println("This is Windows or Mac OSX");
}else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){
System.out.println("This is "+System.getProperty("os.name"));
if(mode.equals("local")){
try {
Desktop.getDesktop().open(new File(getPath()+"\\"+ datPath));
@ -338,7 +335,7 @@ public class MainWindowController {
}
}else if(mode.equals("streaming")){
try {
Desktop.getDesktop().browse(new URI(datPath)); //open the streaming Url in browser (TODO other option?)
Desktop.getDesktop().browse(new URI(datPath)); //open the streaming URL in browser (TODO other option?)
} catch (URISyntaxException | IOException e) {
showErrorMsg(errorOpenStream, (IOException) e);
}
@ -375,6 +372,7 @@ public class MainWindowController {
alert.setTitle("Info");
alert.setHeaderText("Project HomeFlix");
alert.setContentText(infoText);
alert.initOwner(main.primaryStage);
alert.showAndWait();
}
@ -472,21 +470,21 @@ public class MainWindowController {
@FXML
private void updateBtnAction(){
// Updater.update(buildURL, downloadLink, aktBuildNumber, buildNumber);
System.out.println(Updater.getState());
if(Updater.getState() == State.NEW){
Updater.start();
}else{
Updater.run();
}
}
@FXML
private void autoupdateBtnAction(){
if(autoUpdate.equals("0")){
setAutoUpdate("1");
if(autoUpdate){
setAutoUpdate(false);
}else{
setAutoUpdate("0");
setAutoUpdate(true);
}
saveSettings();
}
@ -516,11 +514,14 @@ public class MainWindowController {
}
//"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
*/
void setMain(Main main) {
Updater = new updater(this,buildURL, downloadLink, aktBuildNumber, buildNumber);
ApiQuery = new apiQuery(this);
dbController = new DBController(this);
this.main = main;
Updater = new updater(this,buildURL, downloadLink, buildNumber);
dbController = new DBController(this, this.main);
ApiQuery = new apiQuery(this, dbController, this.main);
}
//Initialize the tables (treeTableViewfilm and tableViewStreamingdata)
@ -532,7 +533,7 @@ public class MainWindowController {
columnTitel.setMaxWidth(260);
columnStreamUrl.setMaxWidth(0);
dataNameColumn.setPrefWidth(150);
dataNameEndColumn.setPrefWidth(170);
dataNameEndColumn.setPrefWidth(220);
columnRating.setStyle("-fx-alignment: CENTER;");
treeTableViewfilm.setRoot(root);
@ -540,7 +541,7 @@ public class MainWindowController {
treeTableViewfilm.setShowRoot(false);
//write content into cell
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titelProperty());
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());
@ -554,16 +555,30 @@ public class MainWindowController {
//Change-listener for TreeTable
treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){
// last = selected; //for auto-play
selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); //get selected item
last = selected - 1;
next = selected + 1;
Name = columnTitel.getCellData(selected); //get name of selected item
name = columnTitel.getCellData(selected); //get name of selected item
datPath = columnStreamUrl.getCellData(selected); //get file path of selected item
ta1.setText(""); //delete text in ta1
ApiQuery.startQuery(Name); // start api query
ta1.positionCaret(0); //set cursor position in ta1
if(mode.equals("local")){
if(localFilms.get(selected).getCached()==true){
System.out.println("loading from cache: "+name);
dbController.readCache(datPath);
}else{
ApiQuery.startQuery(name,datPath); // start api query
}
}else{
System.out.println(streamingFilms.size());
if(streamingFilms.get(selected).getCached()==true){
System.out.println("loading from cache: "+name);
dbController.readCache(datPath);
}else{
ApiQuery.startQuery(name,datPath); // start api query
}
}
}
});
@ -571,7 +586,7 @@ public class MainWindowController {
treeTableViewfilm.setContextMenu(menu);
//Streaming-Settings Table
dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titelProperty());
dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty());
dataNameEndColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty());
tableViewStreamingdata.getColumns().addAll(dataNameColumn, dataNameEndColumn);
@ -584,24 +599,24 @@ public class MainWindowController {
tfsearch.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,String oldValue, String newValue) {
ObservableList<streamUiData> helpData;
ObservableList<tableData> helpData;
filterData.removeAll(filterData);
root.getChildren().remove(0,root.getChildren().size());
if(mode.equals("local")){
helpData = newData;
helpData = localFilms;
}else{
helpData = streamData;
helpData = streamingFilms;
}
for(int i = 0; i < helpData.size(); i++){
if(helpData.get(i).getTitel().toLowerCase().contains(tfsearch.getText().toLowerCase())){
if(helpData.get(i).getTitle().toLowerCase().contains(tfsearch.getText().toLowerCase())){
filterData.add(helpData.get(i)); //add data from newDaten to filteredData where title contains search input
}
}
for(int i = 0; i < filterData.size(); i++){
root.getChildren().add(new TreeItem<streamUiData>(filterData.get(i))); //add filtered data to root node after search
root.getChildren().add(new TreeItem<tableData>(filterData.get(i))); //add filtered data to root node after search
}
if(tfsearch.getText().hashCode() == hashA){
setColor("000000");
@ -613,7 +628,7 @@ public class MainWindowController {
cbLocal.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) {
String local = cbLocal.getItems().get((int) new_value).toString();
local = local.substring(local.length()-6,local.length()-1);
local = local.substring(local.length()-6,local.length()-1); //reading only en_US from English (en_US)
setLocal(local);
setLocalUI();
saveSettings();
@ -624,7 +639,12 @@ public class MainWindowController {
@Override
public void changed(ObservableValue<? extends Number> ov,Number old_val, Number new_val) {
setSize(sliderFontSize.getValue());
ta1.setFont(Font.font("System", size));
if(name != null){
dbController.readCache(datPath);
}
// ta1.setFont(Font.font("System", size));
saveSettings();