parent
8dcb737e4d
commit
bef90522ca
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,6 @@
|
|||
/**
|
||||
* DBController for Project HomeFlix
|
||||
* connection is in manual commit!
|
||||
* TODO arraylists not string -> streamUIData
|
||||
*/
|
||||
|
||||
package application;
|
||||
|
@ -57,15 +56,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 +82,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 +141,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,6 +157,7 @@ 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.setBoolean(5, false);
|
||||
ps.addBatch(); // add command to prepared statement
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +179,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) {
|
||||
|
@ -203,15 +201,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
|
||||
} 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
|
||||
|
@ -223,9 +232,9 @@ public class DBController {
|
|||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
|
||||
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();
|
||||
|
@ -235,9 +244,9 @@ public class DBController {
|
|||
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
|
||||
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(5)));
|
||||
}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(5)));
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
|
@ -259,9 +268,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 +279,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(5)));
|
||||
}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(5)));
|
||||
}
|
||||
stmt.close();
|
||||
rs.close();
|
||||
|
@ -313,13 +322,13 @@ public class DBController {
|
|||
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");
|
||||
|
@ -346,9 +355,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 +367,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 +375,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 +392,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 +404,7 @@ public class DBController {
|
|||
}
|
||||
}
|
||||
|
||||
//gibt die Favorisierung eines bestimmten Films
|
||||
//get favorite status
|
||||
void getFavStatus(String name){
|
||||
try{
|
||||
Statement stmt = connection.createStatement();
|
||||
|
@ -416,7 +426,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 +448,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 +471,91 @@ 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 imdbVotes, String imdbID, String Type, String Poster, String Response) throws SQLException{
|
||||
PreparedStatement ps = connection.prepareStatement("insert into cache values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
|
||||
System.out.println("adding to cache...");
|
||||
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+"';");
|
||||
|
||||
mainWindowController.ta1.appendText(mainWindowController.title+": "+rs.getString(2)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.year+": "+ rs.getString(3)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.rating+": "+rs.getString(4)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.publishedOn+": "+rs.getString(5)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.duration+": "+rs.getString(6)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.genre+": "+rs.getString(7)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.director+": "+rs.getString(8)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.writer+": "+rs.getString(9)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.actors+": "+rs.getString(10)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.plot+": "+rs.getString(11)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.language+": "+rs.getString(12)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.country+": "+rs.getString(13)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.awards+": "+rs.getString(14)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.metascore+": "+rs.getString(15)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.imdbRating+": "+rs.getString(16)+"\n");
|
||||
mainWindowController.ta1.appendText(mainWindowController.type+": "+rs.getString(19)+"\n");
|
||||
|
||||
stmt.close();
|
||||
rs.close();
|
||||
}catch (SQLException e) {
|
||||
System.out.println("Ups! an error occured!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//removes the ending
|
||||
private String cutOffEnd (String str) {
|
||||
|
||||
|
|
|
@ -99,9 +99,9 @@ public class MainWindowController {
|
|||
@FXML
|
||||
private VBox sideMenuVBox;
|
||||
@FXML
|
||||
private TreeTableView<streamUiData> treeTableViewfilm;
|
||||
private TreeTableView<tableData> treeTableViewfilm;
|
||||
@FXML
|
||||
private TableView<streamUiData> tableViewStreamingdata;
|
||||
private TableView<tableData> tableViewStreamingdata;
|
||||
@FXML
|
||||
JFXTextArea ta1;
|
||||
@FXML
|
||||
|
@ -159,28 +159,28 @@ 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)
|
||||
|
@ -189,7 +189,7 @@ public class MainWindowController {
|
|||
static boolean firststart = false;
|
||||
private int hashA = -2055934614;
|
||||
private String version = "0.5.0";
|
||||
private String buildNumber = "117";
|
||||
private String buildNumber = "119";
|
||||
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";
|
||||
|
@ -213,7 +213,7 @@ public class MainWindowController {
|
|||
private String path;
|
||||
private String streamingPath;
|
||||
private String color;
|
||||
private String Name;
|
||||
private String name;
|
||||
private String datPath;
|
||||
private String autoUpdate;
|
||||
private String mode;
|
||||
|
@ -244,11 +244,11 @@ public class MainWindowController {
|
|||
private File selectedStreamingFolder;
|
||||
ResourceBundle bundle;
|
||||
|
||||
private ObservableList<streamUiData> filterData = FXCollections.observableArrayList();
|
||||
private ObservableList<tableData> 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();
|
||||
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"));
|
||||
|
@ -338,7 +338,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);
|
||||
}
|
||||
|
@ -519,8 +519,8 @@ public class MainWindowController {
|
|||
//"Main" Method called in Main.java main() when starting
|
||||
void setMain(Main main) {
|
||||
Updater = new updater(this,buildURL, downloadLink, aktBuildNumber, buildNumber);
|
||||
ApiQuery = new apiQuery(this);
|
||||
dbController = new DBController(this);
|
||||
ApiQuery = new apiQuery(this, dbController);
|
||||
}
|
||||
|
||||
//Initialize the tables (treeTableViewfilm and tableViewStreamingdata)
|
||||
|
@ -559,10 +559,25 @@ public class MainWindowController {
|
|||
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
|
||||
|
||||
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{
|
||||
if(streamingFilms.get(selected).getCached()==true){
|
||||
System.out.println("loading from cache: "+name);
|
||||
dbController.readCache(datPath);
|
||||
}else{
|
||||
ApiQuery.startQuery(name,datPath); // start api query
|
||||
}
|
||||
}
|
||||
ta1.positionCaret(0); //set cursor position in ta1
|
||||
}
|
||||
});
|
||||
|
@ -584,14 +599,14 @@ 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++){
|
||||
|
@ -601,7 +616,7 @@ public class MainWindowController {
|
|||
}
|
||||
|
||||
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");
|
||||
|
@ -633,13 +648,13 @@ public class MainWindowController {
|
|||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
if(mode.equals("streaming")){
|
||||
dbController.like(Name,streamData.get(selected).getStreamUrl());
|
||||
dbController.like(name,streamingFilms.get(selected).getStreamUrl());
|
||||
}else{
|
||||
dbController.like(Name,newData.get(selected).getStreamUrl());
|
||||
dbController.like(name,localFilms.get(selected).getStreamUrl());
|
||||
}
|
||||
dbController.getFavStatus(Name);
|
||||
dbController.getFavStatus(name);
|
||||
try {
|
||||
dbController.refresh(Name, selected);
|
||||
dbController.refresh(name, selected);
|
||||
} catch (SQLException e) {
|
||||
Alert alert = new Alert(AlertType.ERROR);
|
||||
alert.setTitle("Error");
|
||||
|
@ -655,13 +670,13 @@ public class MainWindowController {
|
|||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
if(mode.equals("streaming")){
|
||||
dbController.dislike(Name,streamData.get(selected).getStreamUrl());
|
||||
dbController.dislike(name,streamingFilms.get(selected).getStreamUrl());
|
||||
}else{
|
||||
dbController.dislike(Name,newData.get(selected).getStreamUrl());
|
||||
dbController.dislike(name,localFilms.get(selected).getStreamUrl());
|
||||
}
|
||||
dbController.getFavStatus(Name);
|
||||
dbController.getFavStatus(name);
|
||||
try {
|
||||
dbController.refresh(Name, selected);
|
||||
dbController.refresh(name, selected);
|
||||
} catch (SQLException e) {
|
||||
Alert alert = new Alert(AlertType.ERROR);
|
||||
alert.setTitle("Error");
|
||||
|
@ -682,14 +697,14 @@ public class MainWindowController {
|
|||
System.out.println("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
|
||||
ArrayList<Integer> fav_true = new ArrayList<Integer>();
|
||||
ArrayList<Integer> fav_false = new ArrayList<Integer>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -720,7 +735,7 @@ public class MainWindowController {
|
|||
System.out.println(filterData.size());
|
||||
for(int i = 0; i < filterData.size(); i++){
|
||||
// System.out.println(filterData.get(i).getTitel()+"; "+filterData.get(i).getRating());
|
||||
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
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -754,16 +769,16 @@ public class MainWindowController {
|
|||
|
||||
private void refreshTable(){
|
||||
if(mode.equals("local")){
|
||||
root.getChildren().set(selected, new TreeItem<streamUiData>(newData.get(selected)));
|
||||
root.getChildren().set(selected, new TreeItem<tableData>(localFilms.get(selected)));
|
||||
}else if(mode.equals("streaming")){
|
||||
root.getChildren().set(selected, new TreeItem<streamUiData>(streamData.get(selected)));
|
||||
root.getChildren().set(selected, new TreeItem<tableData>(streamingFilms.get(selected)));
|
||||
}
|
||||
}
|
||||
|
||||
void addDataUI(){
|
||||
if(mode.equals("local")){
|
||||
for(int i = 0; i < newData.size(); i++){
|
||||
root.getChildren().add(new TreeItem<streamUiData>(newData.get(i))); //add data to root-node
|
||||
for(int i = 0; i < localFilms.size(); i++){
|
||||
root.getChildren().add(new TreeItem<tableData>(localFilms.get(i))); //add data to root-node
|
||||
}
|
||||
columnRating.setMaxWidth(90);
|
||||
columnTitel.setMaxWidth(290);
|
||||
|
@ -772,8 +787,8 @@ public class MainWindowController {
|
|||
treeTableViewfilm.getColumns().get(5).setVisible(false);
|
||||
treeTableViewfilm.getColumns().get(6).setVisible(false);
|
||||
}else if(mode.equals("streaming")){
|
||||
for(int i = 0; i < streamData.size(); i++){
|
||||
root.getChildren().add(new TreeItem<streamUiData>(streamData.get(i))); //add data to root-node
|
||||
for(int i = 0; i < streamingFilms.size(); i++){
|
||||
root.getChildren().add(new TreeItem<tableData>(streamingFilms.get(i))); //add data to root-node
|
||||
}
|
||||
columnTitel.setMaxWidth(150);
|
||||
columnResolution.setMaxWidth(65);
|
||||
|
@ -790,18 +805,18 @@ public class MainWindowController {
|
|||
|
||||
void loadStreamingSettings(){
|
||||
if(getStreamingPath().equals("")||getStreamingPath().equals(null)){
|
||||
System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist
|
||||
System.out.println("Kein Pfad angegeben"); //if path equals "" or null
|
||||
}else{
|
||||
String[] entries = new File(getStreamingPath()).list();
|
||||
for(int i = 0; i < entries.length; i++){
|
||||
if(entries[i].endsWith(".json")){
|
||||
String titel = ohneEndung(entries[i]);
|
||||
String data = entries[i];
|
||||
streamingData.add(new streamUiData(1,1,1,5.0,"1",titel ,data, imv1));
|
||||
streamingData.add(new tableData(1,1,1,5.0,"1",titel ,data, imv1, false));
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < streamingData.size(); i++){
|
||||
streamingRoot.getChildren().add( new TreeItem<streamUiData>(streamingData.get(i))); //fügt daten zur Rootnode hinzu
|
||||
streamingRoot.getChildren().add( new TreeItem<tableData>(streamingData.get(i))); //adds data to root-node
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/**
|
||||
* apiQuery for Project HomeFlix
|
||||
* sends a query to the omdb api
|
||||
*
|
||||
* TODO build in a caching function
|
||||
*/
|
||||
package application;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
@ -22,19 +21,21 @@ import javafx.scene.text.Font;
|
|||
import javafx.scene.text.FontWeight;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
@SuppressWarnings("unused") //TODO
|
||||
public class apiQuery{
|
||||
|
||||
public apiQuery(MainWindowController m){
|
||||
public apiQuery(MainWindowController m, DBController db){
|
||||
mainWindowController=m;
|
||||
dbController=db;
|
||||
}
|
||||
|
||||
private MainWindowController mainWindowController;
|
||||
private DBController dbController;
|
||||
private Image im;
|
||||
private int fontSize = 20;
|
||||
private String fontFamily = "System";
|
||||
|
||||
@SuppressWarnings("deprecation") //TODO
|
||||
void startQuery(String input){
|
||||
void startQuery(String titel, String streamUrl){
|
||||
URL url = null;
|
||||
Scanner sc = null;
|
||||
String apiurl = "https://www.omdbapi.com/?"; //API URL
|
||||
|
@ -42,13 +43,13 @@ public class apiQuery{
|
|||
String dataurl = null;
|
||||
String retdata = null;
|
||||
InputStream is = null;
|
||||
DataInputStream dis = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
try {
|
||||
|
||||
//get film title
|
||||
sc = new Scanner(System.in);
|
||||
moviename = input;
|
||||
moviename = titel;
|
||||
|
||||
// in case of no or "" Film title
|
||||
if (moviename == null || moviename.equals("")) {
|
||||
|
@ -66,10 +67,10 @@ public class apiQuery{
|
|||
|
||||
url = new URL(dataurl);
|
||||
is = url.openStream();
|
||||
dis = new DataInputStream(is);
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
|
||||
// lesen der Daten aus dem Antwort Stream
|
||||
while ((retdata = dis.readLine()) != null) {
|
||||
while ((retdata = br.readLine()) != null) {
|
||||
//retdata in json object parsen und anschließend das json Objekt "zerschneiden"
|
||||
System.out.println(retdata);
|
||||
JsonObject object = Json.parse(retdata).asObject();
|
||||
|
@ -89,15 +90,18 @@ public class apiQuery{
|
|||
|
||||
String metascoreV = object.getString("Metascore", "");
|
||||
String imdbRatingV = object.getString("imdbRating", "");
|
||||
@SuppressWarnings("unused")
|
||||
String imdbVotesV = object.getString("imdbVotes", "");
|
||||
@SuppressWarnings("unused")
|
||||
String imdbIDV = object.getString("imdbID", "");
|
||||
String typeV = object.getString("Type", "");
|
||||
|
||||
String posterURL = object.getString("Poster", "");
|
||||
String response = object.getString("Response", "");
|
||||
|
||||
dbController.addCache( streamUrl, titelV, yearV, ratedV, releasedV, runtimeV, genreV, directorV, writerV, actorsV, plotV, languageV, countryV,
|
||||
awardsV, metascoreV, imdbRatingV, imdbVotesV, imdbIDV, typeV, posterURL, response);
|
||||
dbController.setCached(streamUrl);
|
||||
|
||||
|
||||
// Text titelR = new Text (object.getString("Title", "")+"\n");
|
||||
// titelR.setFont(Font.font (fontFamily, fontSize));
|
||||
// Text yearR = new Text (object.getString("Year", "")+"\n");
|
||||
|
@ -221,8 +225,8 @@ public class apiQuery{
|
|||
} finally {
|
||||
//closes datainputStream, InputStream,Scanner if not already done
|
||||
try {
|
||||
if (dis != null) {
|
||||
dis.close();
|
||||
if (br != null) {
|
||||
br.close();
|
||||
}
|
||||
|
||||
if (is != null) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package application;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
@ -9,8 +11,7 @@ import javafx.beans.property.SimpleStringProperty;
|
|||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
public class streamUiData {
|
||||
|
||||
public class tableData {
|
||||
private final IntegerProperty year = new SimpleIntegerProperty();
|
||||
private final IntegerProperty season = new SimpleIntegerProperty();
|
||||
private final IntegerProperty episode = new SimpleIntegerProperty();
|
||||
|
@ -19,9 +20,10 @@ public class streamUiData {
|
|||
private final StringProperty titel = new SimpleStringProperty();
|
||||
private final StringProperty streamUrl = new SimpleStringProperty();
|
||||
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
|
||||
private final BooleanProperty cached = new SimpleBooleanProperty();
|
||||
|
||||
//uiData ist der Typ der Daten in der TreeTabelView
|
||||
public streamUiData (final int year, final int season, final int episode, final double rating, final String resolution, final String titel, final String streamUrl, final ImageView image) {
|
||||
//tableData is the data-type of tree-table-view
|
||||
public tableData (final int year, final int season, final int episode, final double rating, final String resolution, final String titel, final String streamUrl, final ImageView image, final boolean cached) {
|
||||
this.year.set(year);
|
||||
this.season.set(season);
|
||||
this.episode.set(episode);
|
||||
|
@ -30,6 +32,7 @@ public class streamUiData {
|
|||
this.titel.set(titel);
|
||||
this.streamUrl.set(streamUrl);
|
||||
this.image.set(image);
|
||||
this.cached.set(cached);
|
||||
}
|
||||
|
||||
public IntegerProperty yearProperty(){
|
||||
|
@ -64,6 +67,10 @@ public class streamUiData {
|
|||
return image;
|
||||
}
|
||||
|
||||
public BooleanProperty cachedProperty(){
|
||||
return cached;
|
||||
}
|
||||
|
||||
|
||||
public final int getYear() {
|
||||
return yearProperty().get();
|
||||
|
@ -97,6 +104,10 @@ public class streamUiData {
|
|||
return imageProperty().get();
|
||||
}
|
||||
|
||||
public final boolean getCached(){
|
||||
return cachedProperty().get();
|
||||
}
|
||||
|
||||
|
||||
public final void setYear(int year) {
|
||||
yearProperty().set(year);
|
||||
|
@ -129,4 +140,8 @@ public class streamUiData {
|
|||
public final void setImage(ImageView image) {
|
||||
imageProperty().set(image);
|
||||
}
|
||||
|
||||
public final void setCached(boolean cached){
|
||||
cachedProperty().set(cached);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue