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
|
* DBController for Project HomeFlix
|
||||||
* connection is in manual commit!
|
* connection is in manual commit!
|
||||||
* TODO arraylists not string -> streamUIData
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package application;
|
package application;
|
||||||
|
@ -57,15 +56,13 @@ public class DBController {
|
||||||
try {
|
try {
|
||||||
// create a database connection
|
// create a database connection
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
|
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
|
connection.setAutoCommit(false); //AutoCommit to false -> manual commit is active
|
||||||
// fuelleDatenbank();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// if the error message is "out of memory", it probably means no database file is found
|
// if the error message is "out of memory", it probably means no database file is found
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//close connection -> at the moment this kills the program
|
||||||
// finally {
|
// finally {
|
||||||
// try {
|
// try {
|
||||||
// if (connection != null)
|
// if (connection != null)
|
||||||
|
@ -85,8 +82,8 @@ public class DBController {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
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_local (rating, titel, streamUrl, favIcon, cached)");
|
||||||
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_streaming (year, season, episode, rating, resolution, titel, streamUrl, favIcon, cached)");
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
@ -144,13 +141,12 @@ public class DBController {
|
||||||
System.out.println("films in directory: "+filmsAll.size());
|
System.out.println("films in directory: "+filmsAll.size());
|
||||||
System.out.println("filme in db: "+filmsdbAll.size());
|
System.out.println("filme in db: "+filmsdbAll.size());
|
||||||
|
|
||||||
|
|
||||||
if(filmsdbAll.size() == 0){
|
if(filmsdbAll.size() == 0){
|
||||||
System.out.println("creating entries ...");
|
System.out.println("creating entries ...");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?)");
|
ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?, ?)");
|
||||||
psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)");
|
psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
if(mainWindowController.getPath().equals("") || mainWindowController.getPath() == null){
|
if(mainWindowController.getPath().equals("") || mainWindowController.getPath() == null){
|
||||||
System.out.println("Kein Pfad angegeben"); //if path == null or ""
|
System.out.println("Kein Pfad angegeben"); //if path == null or ""
|
||||||
|
@ -161,7 +157,8 @@ public class DBController {
|
||||||
ps.setString(2, cutOffEnd(entries[j])); //name as String without ending 2. column
|
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(3,entries[j]); //path as String 3. column
|
||||||
ps.setString(4, "favorite_border_black");
|
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 +179,7 @@ public class DBController {
|
||||||
psS.setString(6, item.asObject().getString("titel",""));
|
psS.setString(6, item.asObject().getString("titel",""));
|
||||||
psS.setString(7, item.asObject().getString("streamUrl", ""));
|
psS.setString(7, item.asObject().getString("streamUrl", ""));
|
||||||
psS.setString(8, "favorite_border_black");
|
psS.setString(8, "favorite_border_black");
|
||||||
|
psS.setBoolean(9, false);
|
||||||
psS.addBatch(); // add command to prepared statement
|
psS.addBatch(); // add command to prepared statement
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -189,7 +187,7 @@ public class DBController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ps.executeBatch(); //execute statement to write entries into table
|
ps.executeBatch(); //execute statement to write entries into table
|
||||||
psS.executeBatch();
|
psS.executeBatch();
|
||||||
connection.commit();
|
connection.commit();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
@ -203,15 +201,26 @@ public class DBController {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
checkAddEntry();
|
checkAddEntry(); //check if added a new file
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} //check if added a new file
|
}
|
||||||
checkRemoveEntry(); //check if removed a file
|
checkRemoveEntry(); //check if removed a file
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
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
|
//loading data from database to mainWindowController
|
||||||
|
@ -223,9 +232,9 @@ public class DBController {
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
if(rs.getString(4).equals("favorite_black")){
|
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{
|
}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();
|
stmt.close();
|
||||||
|
@ -235,9 +244,9 @@ public class DBController {
|
||||||
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
|
rs = stmt.executeQuery("SELECT * FROM film_streaming;");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
if(rs.getString(8).equals("favorite_black")){
|
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{
|
}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();
|
stmt.close();
|
||||||
|
@ -259,9 +268,9 @@ public class DBController {
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" );
|
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" );
|
||||||
if(rs.getString(4).equals("favorite_black")){
|
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{
|
}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();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -270,9 +279,9 @@ public class DBController {
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" );
|
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" );
|
||||||
if(rs.getString(8).equals("favorite_black")){
|
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{
|
}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();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -313,13 +322,13 @@ public class DBController {
|
||||||
System.out.println("checking for entrys to add to DB ...");
|
System.out.println("checking for entrys to add to DB ...");
|
||||||
String[] entries = new File(mainWindowController.getPath()).list();
|
String[] entries = new File(mainWindowController.getPath()).list();
|
||||||
Statement stmt = connection.createStatement();
|
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;
|
int i=0;
|
||||||
|
|
||||||
for(int a=0; a<filmsDir.size(); a++){
|
for(int a=0; a<filmsDir.size(); a++){
|
||||||
if(filmsdbLocal.contains(filmsDir.get(a))){
|
if(filmsdbLocal.contains(filmsDir.get(a))){
|
||||||
}else{
|
}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();
|
connection.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
System.out.println("added \""+filmsDir.get(a)+"\" to databsae");
|
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(6, items.get(i).asObject().getString("titel",""));
|
||||||
ps.setString(7, items.get(i).asObject().getString("streamUrl", ""));
|
ps.setString(7, items.get(i).asObject().getString("streamUrl", ""));
|
||||||
ps.setString(8, "favorite_border_black");
|
ps.setString(8, "favorite_border_black");
|
||||||
|
ps.setBoolean(9, false);
|
||||||
ps.addBatch(); // adds the entry
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +367,7 @@ public class DBController {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ausgeben(){
|
void ausgeben(){
|
||||||
System.out.println("Eintraege ausgeben ... \n");
|
System.out.println("Outputting all entries ... \n");
|
||||||
try {
|
try {
|
||||||
Statement stmt = connection.createStatement();
|
Statement stmt = connection.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
|
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(1));
|
||||||
System.out.println(rs.getString(2));
|
System.out.println(rs.getString(2));
|
||||||
System.out.println(rs.getString(3));
|
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();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -383,7 +392,8 @@ public class DBController {
|
||||||
System.out.println(rs.getString(5));
|
System.out.println(rs.getString(5));
|
||||||
System.out.println(rs.getString(6));
|
System.out.println(rs.getString(6));
|
||||||
System.out.println(rs.getString(7));
|
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();
|
stmt.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -394,7 +404,7 @@ public class DBController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//gibt die Favorisierung eines bestimmten Films
|
//get favorite status
|
||||||
void getFavStatus(String name){
|
void getFavStatus(String name){
|
||||||
try{
|
try{
|
||||||
Statement stmt = connection.createStatement();
|
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){
|
void dislike(String name,String streamUrl){
|
||||||
System.out.println("defavorisieren ...");
|
System.out.println("defavorisieren ...");
|
||||||
try{
|
try{
|
||||||
|
@ -438,7 +448,7 @@ public class DBController {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//setzt die Favorisierung eines bestimmten Films
|
//set rating=1 and favorite_black
|
||||||
void like(String name,String streamUrl){
|
void like(String name,String streamUrl){
|
||||||
System.out.println("favorisieren ...");
|
System.out.println("favorisieren ...");
|
||||||
try{
|
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
|
//removes the ending
|
||||||
private String cutOffEnd (String str) {
|
private String cutOffEnd (String str) {
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,9 @@ public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
private VBox sideMenuVBox;
|
private VBox sideMenuVBox;
|
||||||
@FXML
|
@FXML
|
||||||
private TreeTableView<streamUiData> treeTableViewfilm;
|
private TreeTableView<tableData> treeTableViewfilm;
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<streamUiData> tableViewStreamingdata;
|
private TableView<tableData> tableViewStreamingdata;
|
||||||
@FXML
|
@FXML
|
||||||
JFXTextArea ta1;
|
JFXTextArea ta1;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -159,28 +159,28 @@ public class MainWindowController {
|
||||||
private ImageView imv1;
|
private ImageView imv1;
|
||||||
|
|
||||||
@FXML
|
@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
|
@FXML
|
||||||
TreeTableColumn<streamUiData, ImageView> columnRating = new TreeTableColumn<>("Rating");
|
TreeTableColumn<tableData, ImageView> columnRating = new TreeTableColumn<>("Rating");
|
||||||
@FXML
|
@FXML
|
||||||
TreeTableColumn<streamUiData, String> columnTitel = new TreeTableColumn<>("Titel");
|
TreeTableColumn<tableData, String> columnTitel = new TreeTableColumn<>("Titel");
|
||||||
@FXML
|
@FXML
|
||||||
TreeTableColumn<streamUiData, String> columnStreamUrl = new TreeTableColumn<>("File Name");
|
TreeTableColumn<tableData, String> columnStreamUrl = new TreeTableColumn<>("File Name");
|
||||||
@FXML
|
@FXML
|
||||||
TreeTableColumn<streamUiData, String> columnResolution = new TreeTableColumn<>("Resolution");
|
TreeTableColumn<tableData, String> columnResolution = new TreeTableColumn<>("Resolution");
|
||||||
@FXML
|
@FXML
|
||||||
TreeTableColumn<streamUiData, Integer> columnYear = new TreeTableColumn<>("Year");
|
TreeTableColumn<tableData, Integer> columnYear = new TreeTableColumn<>("Year");
|
||||||
@FXML
|
@FXML
|
||||||
TreeTableColumn<streamUiData, Integer> columnSeason = new TreeTableColumn<>("Season");
|
TreeTableColumn<tableData, Integer> columnSeason = new TreeTableColumn<>("Season");
|
||||||
@FXML
|
@FXML
|
||||||
TreeTableColumn<streamUiData, Integer> columnEpisode = new TreeTableColumn<>("Episode");
|
TreeTableColumn<tableData, Integer> columnEpisode = new TreeTableColumn<>("Episode");
|
||||||
|
|
||||||
@FXML
|
@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
|
@FXML
|
||||||
private TableColumn<streamUiData, String> dataNameColumn = new TableColumn<>("Datei Name");
|
private TableColumn<tableData, String> dataNameColumn = new TableColumn<>("Datei Name");
|
||||||
@FXML
|
@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)
|
||||||
|
@ -189,7 +189,7 @@ public class MainWindowController {
|
||||||
static boolean firststart = false;
|
static boolean firststart = false;
|
||||||
private int hashA = -2055934614;
|
private int hashA = -2055934614;
|
||||||
private String version = "0.5.0";
|
private String version = "0.5.0";
|
||||||
private String buildNumber = "117";
|
private String buildNumber = "119";
|
||||||
private String versionName = "plasma cow";
|
private String versionName = "plasma cow";
|
||||||
private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt";
|
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";
|
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 path;
|
||||||
private String streamingPath;
|
private String streamingPath;
|
||||||
private String color;
|
private String color;
|
||||||
private String Name;
|
private String name;
|
||||||
private String datPath;
|
private String datPath;
|
||||||
private String autoUpdate;
|
private String autoUpdate;
|
||||||
private String mode;
|
private String mode;
|
||||||
|
@ -244,11 +244,11 @@ public class MainWindowController {
|
||||||
private File selectedStreamingFolder;
|
private File selectedStreamingFolder;
|
||||||
ResourceBundle bundle;
|
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)");
|
private ObservableList<String> locals = FXCollections.observableArrayList("english (en_US)", "deutsch (de_DE)");
|
||||||
ObservableList<streamUiData> newData = FXCollections.observableArrayList(); //TODO rename to localFilms
|
ObservableList<tableData> localFilms = FXCollections.observableArrayList();
|
||||||
ObservableList<streamUiData> streamData = FXCollections.observableArrayList(); //TODO rename to streamingFilms
|
ObservableList<tableData> streamingFilms = FXCollections.observableArrayList();
|
||||||
ObservableList<streamUiData> streamingData = 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_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 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"));
|
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")){
|
}else if(mode.equals("streaming")){
|
||||||
try {
|
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) {
|
} catch (URISyntaxException | IOException e) {
|
||||||
showErrorMsg(errorOpenStream, (IOException) e);
|
showErrorMsg(errorOpenStream, (IOException) e);
|
||||||
}
|
}
|
||||||
|
@ -519,8 +519,8 @@ public class MainWindowController {
|
||||||
//"Main" Method called in Main.java main() when starting
|
//"Main" Method called in Main.java main() when starting
|
||||||
void setMain(Main main) {
|
void setMain(Main main) {
|
||||||
Updater = new updater(this,buildURL, downloadLink, aktBuildNumber, buildNumber);
|
Updater = new updater(this,buildURL, downloadLink, aktBuildNumber, buildNumber);
|
||||||
ApiQuery = new apiQuery(this);
|
|
||||||
dbController = new DBController(this);
|
dbController = new DBController(this);
|
||||||
|
ApiQuery = new apiQuery(this, dbController);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the tables (treeTableViewfilm and tableViewStreamingdata)
|
//Initialize the tables (treeTableViewfilm and tableViewStreamingdata)
|
||||||
|
@ -554,15 +554,30 @@ public class MainWindowController {
|
||||||
//Change-listener for TreeTable
|
//Change-listener for TreeTable
|
||||||
treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
|
treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
|
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){
|
||||||
// last = selected; //for auto-play
|
// last = selected; //for auto-play
|
||||||
selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); //get selected item
|
selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); //get selected item
|
||||||
last = selected - 1;
|
last = selected - 1;
|
||||||
next = selected + 1;
|
next = selected + 1;
|
||||||
Name = columnTitel.getCellData(selected); //get name of selected item
|
name = columnTitel.getCellData(selected); //get name of selected item
|
||||||
datPath = columnStreamUrl.getCellData(selected); //get file path of selected item
|
datPath = columnStreamUrl.getCellData(selected); //get file path of selected item
|
||||||
ta1.setText(""); //delete text in ta1
|
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
|
ta1.positionCaret(0); //set cursor position in ta1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -584,14 +599,14 @@ public class MainWindowController {
|
||||||
tfsearch.textProperty().addListener(new ChangeListener<String>() {
|
tfsearch.textProperty().addListener(new ChangeListener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends String> observable,String oldValue, String newValue) {
|
public void changed(ObservableValue<? extends String> observable,String oldValue, String newValue) {
|
||||||
ObservableList<streamUiData> helpData;
|
ObservableList<tableData> helpData;
|
||||||
filterData.removeAll(filterData);
|
filterData.removeAll(filterData);
|
||||||
root.getChildren().remove(0,root.getChildren().size());
|
root.getChildren().remove(0,root.getChildren().size());
|
||||||
|
|
||||||
if(mode.equals("local")){
|
if(mode.equals("local")){
|
||||||
helpData = newData;
|
helpData = localFilms;
|
||||||
}else{
|
}else{
|
||||||
helpData = streamData;
|
helpData = streamingFilms;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < helpData.size(); i++){
|
for(int i = 0; i < helpData.size(); i++){
|
||||||
|
@ -601,7 +616,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < filterData.size(); i++){
|
for(int i = 0; i < filterData.size(); i++){
|
||||||
root.getChildren().add(new TreeItem<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){
|
if(tfsearch.getText().hashCode() == hashA){
|
||||||
setColor("000000");
|
setColor("000000");
|
||||||
|
@ -633,13 +648,13 @@ public class MainWindowController {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
if(mode.equals("streaming")){
|
if(mode.equals("streaming")){
|
||||||
dbController.like(Name,streamData.get(selected).getStreamUrl());
|
dbController.like(name,streamingFilms.get(selected).getStreamUrl());
|
||||||
}else{
|
}else{
|
||||||
dbController.like(Name,newData.get(selected).getStreamUrl());
|
dbController.like(name,localFilms.get(selected).getStreamUrl());
|
||||||
}
|
}
|
||||||
dbController.getFavStatus(Name);
|
dbController.getFavStatus(name);
|
||||||
try {
|
try {
|
||||||
dbController.refresh(Name, selected);
|
dbController.refresh(name, selected);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Alert alert = new Alert(AlertType.ERROR);
|
Alert alert = new Alert(AlertType.ERROR);
|
||||||
alert.setTitle("Error");
|
alert.setTitle("Error");
|
||||||
|
@ -655,13 +670,13 @@ public class MainWindowController {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
if(mode.equals("streaming")){
|
if(mode.equals("streaming")){
|
||||||
dbController.dislike(Name,streamData.get(selected).getStreamUrl());
|
dbController.dislike(name,streamingFilms.get(selected).getStreamUrl());
|
||||||
}else{
|
}else{
|
||||||
dbController.dislike(Name,newData.get(selected).getStreamUrl());
|
dbController.dislike(name,localFilms.get(selected).getStreamUrl());
|
||||||
}
|
}
|
||||||
dbController.getFavStatus(Name);
|
dbController.getFavStatus(name);
|
||||||
try {
|
try {
|
||||||
dbController.refresh(Name, selected);
|
dbController.refresh(name, selected);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Alert alert = new Alert(AlertType.ERROR);
|
Alert alert = new Alert(AlertType.ERROR);
|
||||||
alert.setTitle("Error");
|
alert.setTitle("Error");
|
||||||
|
@ -682,14 +697,14 @@ public class MainWindowController {
|
||||||
System.out.println("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
|
System.out.println("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
|
||||||
ArrayList<Integer> fav_true = new ArrayList<Integer>();
|
ArrayList<Integer> fav_true = new ArrayList<Integer>();
|
||||||
ArrayList<Integer> fav_false = new ArrayList<Integer>();
|
ArrayList<Integer> fav_false = new ArrayList<Integer>();
|
||||||
ObservableList<streamUiData> helpData;
|
ObservableList<tableData> helpData;
|
||||||
filterData.removeAll(filterData);
|
filterData.removeAll(filterData);
|
||||||
root.getChildren().remove(0,root.getChildren().size());
|
root.getChildren().remove(0,root.getChildren().size());
|
||||||
|
|
||||||
if(mode.equals("local")){
|
if(mode.equals("local")){
|
||||||
helpData = newData;
|
helpData = localFilms;
|
||||||
}else{
|
}else{
|
||||||
helpData = streamData;
|
helpData = streamingFilms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -720,7 +735,7 @@ public class MainWindowController {
|
||||||
System.out.println(filterData.size());
|
System.out.println(filterData.size());
|
||||||
for(int i = 0; i < filterData.size(); i++){
|
for(int i = 0; i < filterData.size(); i++){
|
||||||
// System.out.println(filterData.get(i).getTitel()+"; "+filterData.get(i).getRating());
|
// 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(){
|
private void refreshTable(){
|
||||||
if(mode.equals("local")){
|
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")){
|
}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(){
|
void addDataUI(){
|
||||||
if(mode.equals("local")){
|
if(mode.equals("local")){
|
||||||
for(int i = 0; i < newData.size(); i++){
|
for(int i = 0; i < localFilms.size(); i++){
|
||||||
root.getChildren().add(new TreeItem<streamUiData>(newData.get(i))); //add data to root-node
|
root.getChildren().add(new TreeItem<tableData>(localFilms.get(i))); //add data to root-node
|
||||||
}
|
}
|
||||||
columnRating.setMaxWidth(90);
|
columnRating.setMaxWidth(90);
|
||||||
columnTitel.setMaxWidth(290);
|
columnTitel.setMaxWidth(290);
|
||||||
|
@ -772,8 +787,8 @@ public class MainWindowController {
|
||||||
treeTableViewfilm.getColumns().get(5).setVisible(false);
|
treeTableViewfilm.getColumns().get(5).setVisible(false);
|
||||||
treeTableViewfilm.getColumns().get(6).setVisible(false);
|
treeTableViewfilm.getColumns().get(6).setVisible(false);
|
||||||
}else if(mode.equals("streaming")){
|
}else if(mode.equals("streaming")){
|
||||||
for(int i = 0; i < streamData.size(); i++){
|
for(int i = 0; i < streamingFilms.size(); i++){
|
||||||
root.getChildren().add(new TreeItem<streamUiData>(streamData.get(i))); //add data to root-node
|
root.getChildren().add(new TreeItem<tableData>(streamingFilms.get(i))); //add data to root-node
|
||||||
}
|
}
|
||||||
columnTitel.setMaxWidth(150);
|
columnTitel.setMaxWidth(150);
|
||||||
columnResolution.setMaxWidth(65);
|
columnResolution.setMaxWidth(65);
|
||||||
|
@ -790,18 +805,18 @@ public class MainWindowController {
|
||||||
|
|
||||||
void loadStreamingSettings(){
|
void loadStreamingSettings(){
|
||||||
if(getStreamingPath().equals("")||getStreamingPath().equals(null)){
|
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{
|
}else{
|
||||||
String[] entries = new File(getStreamingPath()).list();
|
String[] entries = new File(getStreamingPath()).list();
|
||||||
for(int i = 0; i < entries.length; i++){
|
for(int i = 0; i < entries.length; i++){
|
||||||
if(entries[i].endsWith(".json")){
|
if(entries[i].endsWith(".json")){
|
||||||
String titel = ohneEndung(entries[i]);
|
String titel = ohneEndung(entries[i]);
|
||||||
String data = 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++){
|
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
|
* apiQuery for Project HomeFlix
|
||||||
* sends a query to the omdb api
|
* sends a query to the omdb api
|
||||||
*
|
|
||||||
* TODO build in a caching function
|
|
||||||
*/
|
*/
|
||||||
package application;
|
package application;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
@ -22,19 +21,21 @@ import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.FontWeight;
|
import javafx.scene.text.FontWeight;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused") //TODO
|
||||||
public class apiQuery{
|
public class apiQuery{
|
||||||
|
|
||||||
public apiQuery(MainWindowController m){
|
public apiQuery(MainWindowController m, DBController db){
|
||||||
mainWindowController=m;
|
mainWindowController=m;
|
||||||
|
dbController=db;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MainWindowController mainWindowController;
|
private MainWindowController mainWindowController;
|
||||||
|
private DBController dbController;
|
||||||
private Image im;
|
private Image im;
|
||||||
private int fontSize = 20;
|
private int fontSize = 20;
|
||||||
private String fontFamily = "System";
|
private String fontFamily = "System";
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") //TODO
|
void startQuery(String titel, String streamUrl){
|
||||||
void startQuery(String input){
|
|
||||||
URL url = null;
|
URL url = null;
|
||||||
Scanner sc = null;
|
Scanner sc = null;
|
||||||
String apiurl = "https://www.omdbapi.com/?"; //API URL
|
String apiurl = "https://www.omdbapi.com/?"; //API URL
|
||||||
|
@ -42,13 +43,13 @@ public class apiQuery{
|
||||||
String dataurl = null;
|
String dataurl = null;
|
||||||
String retdata = null;
|
String retdata = null;
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
DataInputStream dis = null;
|
BufferedReader br = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//get film title
|
//get film title
|
||||||
sc = new Scanner(System.in);
|
sc = new Scanner(System.in);
|
||||||
moviename = input;
|
moviename = titel;
|
||||||
|
|
||||||
// in case of no or "" Film title
|
// in case of no or "" Film title
|
||||||
if (moviename == null || moviename.equals("")) {
|
if (moviename == null || moviename.equals("")) {
|
||||||
|
@ -66,10 +67,10 @@ public class apiQuery{
|
||||||
|
|
||||||
url = new URL(dataurl);
|
url = new URL(dataurl);
|
||||||
is = url.openStream();
|
is = url.openStream();
|
||||||
dis = new DataInputStream(is);
|
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||||
|
|
||||||
// lesen der Daten aus dem Antwort Stream
|
// 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"
|
//retdata in json object parsen und anschließend das json Objekt "zerschneiden"
|
||||||
System.out.println(retdata);
|
System.out.println(retdata);
|
||||||
JsonObject object = Json.parse(retdata).asObject();
|
JsonObject object = Json.parse(retdata).asObject();
|
||||||
|
@ -89,15 +90,18 @@ public class apiQuery{
|
||||||
|
|
||||||
String metascoreV = object.getString("Metascore", "");
|
String metascoreV = object.getString("Metascore", "");
|
||||||
String imdbRatingV = object.getString("imdbRating", "");
|
String imdbRatingV = object.getString("imdbRating", "");
|
||||||
@SuppressWarnings("unused")
|
|
||||||
String imdbVotesV = object.getString("imdbVotes", "");
|
String imdbVotesV = object.getString("imdbVotes", "");
|
||||||
@SuppressWarnings("unused")
|
|
||||||
String imdbIDV = object.getString("imdbID", "");
|
String imdbIDV = object.getString("imdbID", "");
|
||||||
String typeV = object.getString("Type", "");
|
String typeV = object.getString("Type", "");
|
||||||
|
|
||||||
String posterURL = object.getString("Poster", "");
|
String posterURL = object.getString("Poster", "");
|
||||||
String response = object.getString("Response", "");
|
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");
|
// Text titelR = new Text (object.getString("Title", "")+"\n");
|
||||||
// titelR.setFont(Font.font (fontFamily, fontSize));
|
// titelR.setFont(Font.font (fontFamily, fontSize));
|
||||||
// Text yearR = new Text (object.getString("Year", "")+"\n");
|
// Text yearR = new Text (object.getString("Year", "")+"\n");
|
||||||
|
@ -221,8 +225,8 @@ public class apiQuery{
|
||||||
} finally {
|
} finally {
|
||||||
//closes datainputStream, InputStream,Scanner if not already done
|
//closes datainputStream, InputStream,Scanner if not already done
|
||||||
try {
|
try {
|
||||||
if (dis != null) {
|
if (br != null) {
|
||||||
dis.close();
|
br.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package application;
|
package application;
|
||||||
|
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
import javafx.beans.property.DoubleProperty;
|
import javafx.beans.property.DoubleProperty;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
@ -9,8 +11,7 @@ import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
|
||||||
public class streamUiData {
|
public class tableData {
|
||||||
|
|
||||||
private final IntegerProperty year = new SimpleIntegerProperty();
|
private final IntegerProperty year = new SimpleIntegerProperty();
|
||||||
private final IntegerProperty season = new SimpleIntegerProperty();
|
private final IntegerProperty season = new SimpleIntegerProperty();
|
||||||
private final IntegerProperty episode = new SimpleIntegerProperty();
|
private final IntegerProperty episode = new SimpleIntegerProperty();
|
||||||
|
@ -19,9 +20,10 @@ public class streamUiData {
|
||||||
private final StringProperty titel = new SimpleStringProperty();
|
private final StringProperty titel = new SimpleStringProperty();
|
||||||
private final StringProperty streamUrl = new SimpleStringProperty();
|
private final StringProperty streamUrl = new SimpleStringProperty();
|
||||||
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
|
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
|
||||||
|
private final BooleanProperty cached = new SimpleBooleanProperty();
|
||||||
|
|
||||||
//uiData ist der Typ der Daten in der TreeTabelView
|
//tableData is the data-type of tree-table-view
|
||||||
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) {
|
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.year.set(year);
|
||||||
this.season.set(season);
|
this.season.set(season);
|
||||||
this.episode.set(episode);
|
this.episode.set(episode);
|
||||||
|
@ -30,6 +32,7 @@ public class streamUiData {
|
||||||
this.titel.set(titel);
|
this.titel.set(titel);
|
||||||
this.streamUrl.set(streamUrl);
|
this.streamUrl.set(streamUrl);
|
||||||
this.image.set(image);
|
this.image.set(image);
|
||||||
|
this.cached.set(cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntegerProperty yearProperty(){
|
public IntegerProperty yearProperty(){
|
||||||
|
@ -64,6 +67,10 @@ public class streamUiData {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BooleanProperty cachedProperty(){
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public final int getYear() {
|
public final int getYear() {
|
||||||
return yearProperty().get();
|
return yearProperty().get();
|
||||||
|
@ -96,6 +103,10 @@ public class streamUiData {
|
||||||
public final ImageView getImage() {
|
public final ImageView getImage() {
|
||||||
return imageProperty().get();
|
return imageProperty().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean getCached(){
|
||||||
|
return cachedProperty().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void setYear(int year) {
|
public final void setYear(int year) {
|
||||||
|
@ -129,4 +140,8 @@ public class streamUiData {
|
||||||
public final void setImage(ImageView image) {
|
public final void setImage(ImageView image) {
|
||||||
imageProperty().set(image);
|
imageProperty().set(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void setCached(boolean cached){
|
||||||
|
cachedProperty().set(cached);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue