parent
b5035825a5
commit
9aa36fc622
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.
|
@ -126,7 +126,7 @@ public class Main extends Application {
|
||||||
private String firstStart(){
|
private String firstStart(){
|
||||||
Alert alert = new Alert(AlertType.CONFIRMATION); //neuer alert mit filechooser
|
Alert alert = new Alert(AlertType.CONFIRMATION); //neuer alert mit filechooser
|
||||||
alert.setTitle("Project HomeFlix");
|
alert.setTitle("Project HomeFlix");
|
||||||
alert.setHeaderText("Es ist kein Stammverzeichniss für Filme angegeben!");
|
alert.setHeaderText("Es ist kein Stammverzeichniss für Filme angegeben!"); //TODO translate
|
||||||
alert.setContentText("Stammverzeichniss angeben?");
|
alert.setContentText("Stammverzeichniss angeben?");
|
||||||
|
|
||||||
Optional<ButtonType> result = alert.showAndWait();
|
Optional<ButtonType> result = alert.showAndWait();
|
||||||
|
|
|
@ -23,7 +23,6 @@ package application;
|
||||||
|
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -37,13 +36,9 @@ import java.io.StringWriter;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.channels.Channels;
|
|
||||||
import java.nio.channels.ReadableByteChannel;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
|
|
||||||
|
@ -107,8 +102,7 @@ public class MainWindowController {
|
||||||
private TreeTableView<streamUiData> treeTableViewfilm;
|
private TreeTableView<streamUiData> treeTableViewfilm;
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<streamUiData> tableViewStreamingdata;
|
private TableView<streamUiData> tableViewStreamingdata;
|
||||||
@FXML
|
@FXML JFXTextArea ta1;
|
||||||
private JFXTextArea ta1;
|
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton menubtn;
|
private JFXButton menubtn;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -130,7 +124,7 @@ public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton debugBtn;
|
private JFXButton debugBtn;
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton updateBtn;
|
public JFXButton updateBtn;
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton directoryBtn;
|
private JFXButton directoryBtn;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -157,8 +151,7 @@ public class MainWindowController {
|
||||||
private Label sizelbl;
|
private Label sizelbl;
|
||||||
@FXML
|
@FXML
|
||||||
private Label aulbl;
|
private Label aulbl;
|
||||||
@FXML
|
@FXML ImageView image1;
|
||||||
private ImageView image1;
|
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -190,23 +183,22 @@ public class MainWindowController {
|
||||||
private boolean settingstrue = false;
|
private boolean settingstrue = false;
|
||||||
private boolean streamingSettingsTrue = false;
|
private boolean streamingSettingsTrue = false;
|
||||||
private String version = "0.4.0";
|
private String version = "0.4.0";
|
||||||
private String buildNumber = "103";
|
private String buildNumber = "104";
|
||||||
private String versionName = "glowing bucket";
|
private String versionName = "glowing bucket";
|
||||||
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";
|
||||||
private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix");
|
private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix");
|
||||||
private File file = new File(dir + "/config.xml");
|
private File file = new File(dir + "/config.xml");
|
||||||
|
|
||||||
private String updateDataURL;
|
String errorUpdateD;
|
||||||
private String errorUpdateD;
|
String errorUpdateV;
|
||||||
private String errorUpdateV;
|
|
||||||
private String errorPlay;
|
private String errorPlay;
|
||||||
private String errorOpenStream;
|
private String errorOpenStream;
|
||||||
private String errorMode;
|
private String errorMode;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String errorLoad;
|
private String errorLoad;
|
||||||
private String errorSave;
|
private String errorSave;
|
||||||
private String noFilmFound;
|
String noFilmFound;
|
||||||
private String infoText;
|
private String infoText;
|
||||||
private String linuxBugText;
|
private String linuxBugText;
|
||||||
private String vlcNotInstalled;
|
private String vlcNotInstalled;
|
||||||
|
@ -218,22 +210,22 @@ public class MainWindowController {
|
||||||
private String datPath;
|
private String datPath;
|
||||||
private String autoUpdate;
|
private String autoUpdate;
|
||||||
private String mode;
|
private String mode;
|
||||||
private String title;
|
String title;
|
||||||
private String year;
|
String year;
|
||||||
private String rating;
|
String rating;
|
||||||
private String publishedOn;
|
String publishedOn;
|
||||||
private String duration;
|
String duration;
|
||||||
private String genre;
|
String genre;
|
||||||
private String director;
|
String director;
|
||||||
private String writer;
|
String writer;
|
||||||
private String actors;
|
String actors;
|
||||||
private String plot;
|
String plot;
|
||||||
private String language;
|
String language;
|
||||||
private String country;
|
String country;
|
||||||
private String awards;
|
String awards;
|
||||||
private String metascore;
|
String metascore;
|
||||||
private String imdbRating;
|
String imdbRating;
|
||||||
private String type;
|
String type;
|
||||||
private double size;
|
private double size;
|
||||||
private int last;
|
private int last;
|
||||||
private int selected;
|
private int selected;
|
||||||
|
@ -241,7 +233,7 @@ public class MainWindowController {
|
||||||
private int local;
|
private int local;
|
||||||
private File selectedFolder;
|
private File selectedFolder;
|
||||||
private File selectedStreamingFolder;
|
private File selectedStreamingFolder;
|
||||||
private ResourceBundle bundle;
|
ResourceBundle bundle;
|
||||||
|
|
||||||
private ObservableList<streamUiData> newDaten = FXCollections.observableArrayList();
|
private ObservableList<streamUiData> newDaten = FXCollections.observableArrayList();
|
||||||
private ObservableList<streamUiData> filterData = FXCollections.observableArrayList();
|
private ObservableList<streamUiData> filterData = FXCollections.observableArrayList();
|
||||||
|
@ -259,6 +251,9 @@ public class MainWindowController {
|
||||||
private DirectoryChooser directoryChooser = new DirectoryChooser();
|
private DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
||||||
|
private updater Updater;
|
||||||
|
private apiQuery ApiQuery;
|
||||||
|
|
||||||
//wenn menubtn clicked
|
//wenn menubtn clicked
|
||||||
/**
|
/**
|
||||||
* TODO change value of Text-color change
|
* TODO change value of Text-color change
|
||||||
|
@ -466,7 +461,7 @@ public class MainWindowController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void updateBtnAction(){
|
private void updateBtnAction(){
|
||||||
update();
|
Updater.update(buildURL, downloadLink, aktBuildNumber, buildNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -511,6 +506,9 @@ public class MainWindowController {
|
||||||
initTabel();
|
initTabel();
|
||||||
initActions();
|
initActions();
|
||||||
|
|
||||||
|
Updater = new updater(this);
|
||||||
|
ApiQuery = new apiQuery(this);
|
||||||
|
|
||||||
System.out.println("Mode: "+mode);
|
System.out.println("Mode: "+mode);
|
||||||
|
|
||||||
debugBtn.setDisable(true); //debugging btn for tests
|
debugBtn.setDisable(true); //debugging btn for tests
|
||||||
|
@ -526,7 +524,7 @@ public class MainWindowController {
|
||||||
|
|
||||||
if(autoUpdate.equals("1")){
|
if(autoUpdate.equals("1")){
|
||||||
autoupdateBtn.setSelected(true);
|
autoupdateBtn.setSelected(true);
|
||||||
update();
|
Updater.update(buildURL, downloadLink, aktBuildNumber, buildNumber);
|
||||||
}else{
|
}else{
|
||||||
autoupdateBtn.setSelected(false);
|
autoupdateBtn.setSelected(false);
|
||||||
}
|
}
|
||||||
|
@ -587,9 +585,8 @@ public class MainWindowController {
|
||||||
Name = columnTitel.getCellData(selected); // holt Namen des Aktuelle Items aus der ColumnName
|
Name = columnTitel.getCellData(selected); // holt Namen des Aktuelle Items aus der ColumnName
|
||||||
datPath = columnStreamUrl.getCellData(selected); // holt den aktuellen Datei Pfad aus der ColumnDatName
|
datPath = columnStreamUrl.getCellData(selected); // holt den aktuellen Datei Pfad aus der ColumnDatName
|
||||||
ta1.setText(""); // löscht Text in ta1
|
ta1.setText(""); // löscht Text in ta1
|
||||||
apiAbfrage(Name); // startet die api abfrage
|
ApiQuery.startQuery(Name); // startet die api abfrage
|
||||||
ta1.positionCaret(0); // setzt die startposition des Cursors in
|
ta1.positionCaret(0); // setzt die startposition des Cursors in ta1
|
||||||
// ta1
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -644,52 +641,8 @@ public class MainWindowController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//prüft auf Update und fürht es gegebenenfalls aus
|
|
||||||
private void update(){
|
|
||||||
|
|
||||||
System.out.println("check for updates ...");
|
|
||||||
try {
|
|
||||||
URL url = new URL(buildURL); //URL der Datei mit aktueller Versionsnummer
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
|
||||||
aktBuildNumber = in.readLine(); //schreibt inputstream in String
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
showErrorMsg(errorUpdateV, e1);
|
|
||||||
}
|
|
||||||
System.out.println("Build: "+buildNumber+", Update: "+aktBuildNumber);
|
|
||||||
|
|
||||||
|
|
||||||
//vergleicht die Versionsnummern, bei aktversion > version wird ein Update durchgrf�hrt
|
|
||||||
int iversion = Integer.parseInt(buildNumber.replace(".", ""));
|
|
||||||
int iaktVersion = Integer.parseInt(aktBuildNumber.replace(".", ""));
|
|
||||||
|
|
||||||
if(iversion >= iaktVersion){
|
|
||||||
updateBtn.setText(bundle.getString("updateBtnNotavail"));
|
|
||||||
System.out.println("no update available");
|
|
||||||
}else{
|
|
||||||
updateBtn.setText(bundle.getString("updateBtnavail"));
|
|
||||||
System.out.println("update available");
|
|
||||||
try {
|
|
||||||
URL website;
|
|
||||||
URL downloadURL = new URL(downloadLink);
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(downloadURL.openStream()));
|
|
||||||
updateDataURL = in.readLine();
|
|
||||||
website = new URL(updateDataURL); //Update URL
|
|
||||||
ReadableByteChannel rbc = Channels.newChannel(website.openStream()); //open new Stream/Channel
|
|
||||||
FileOutputStream fos = new FileOutputStream("ProjectHomeFlix.jar"); //nea fileoutputstram for ProjectHomeFLix.jar
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); //gets file from 0 to max size
|
|
||||||
fos.close(); //close fos (extrem wichtig!)
|
|
||||||
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again
|
|
||||||
System.exit(0); //finishes itself
|
|
||||||
} catch (IOException e) {
|
|
||||||
//in case there is an error
|
|
||||||
showErrorMsg(errorUpdateD, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//lädt die Daten im angegeben Ordner in newDaten
|
//lädt die Daten im angegeben Ordner in newDaten
|
||||||
public void loadData(){
|
void loadData(){
|
||||||
//load local Data
|
//load local Data
|
||||||
if(getPath().equals("")||getPath().equals(null)){
|
if(getPath().equals("")||getPath().equals(null)){
|
||||||
System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist
|
System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist
|
||||||
|
@ -737,7 +690,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDataUI(){
|
void addDataUI(){
|
||||||
if(mode.equals("local")){
|
if(mode.equals("local")){
|
||||||
for(int i = 0; i < newDaten.size(); i++){
|
for(int i = 0; i < newDaten.size(); i++){
|
||||||
root.getChildren().add(new TreeItem<streamUiData>(newDaten.get(i))); //fügt daten zur Rootnode hinzu
|
root.getChildren().add(new TreeItem<streamUiData>(newDaten.get(i))); //fügt daten zur Rootnode hinzu
|
||||||
|
@ -765,7 +718,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public 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"); //falls der Pfad null oder "" ist
|
||||||
}else{
|
}else{
|
||||||
|
@ -791,7 +744,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
//setzt die Farben für die UI-Elemente
|
//setzt die Farben für die UI-Elemente
|
||||||
public void applyColor(){
|
void applyColor(){
|
||||||
String style = "-fx-background-color: #"+getColor()+";";
|
String style = "-fx-background-color: #"+getColor()+";";
|
||||||
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
|
String btnStyleBlack = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
|
||||||
String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: WHITE;";
|
String btnStyleWhite = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: WHITE;";
|
||||||
|
@ -937,7 +890,7 @@ public class MainWindowController {
|
||||||
type = bundle.getString("type");
|
type = bundle.getString("type");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorMsg(String msg, IOException exception){
|
public void showErrorMsg(String msg, IOException exception){
|
||||||
Alert alert = new Alert(AlertType.ERROR);
|
Alert alert = new Alert(AlertType.ERROR);
|
||||||
alert.setTitle("Error");
|
alert.setTitle("Error");
|
||||||
alert.setHeaderText("");
|
alert.setHeaderText("");
|
||||||
|
@ -1072,119 +1025,4 @@ public class MainWindowController {
|
||||||
public String getMode(){
|
public String getMode(){
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//API-Query
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void apiAbfrage(String input){
|
|
||||||
URL url = null;
|
|
||||||
Scanner sc = null;
|
|
||||||
String apiurl = "https://www.omdbapi.com/?"; //API URL
|
|
||||||
String moviename = null;
|
|
||||||
String dataurl = null;
|
|
||||||
String retdata = null;
|
|
||||||
InputStream is = null;
|
|
||||||
DataInputStream dis = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
//get film title
|
|
||||||
sc = new Scanner(System.in);
|
|
||||||
moviename = input;
|
|
||||||
|
|
||||||
// in case of no or "" Film title
|
|
||||||
if (moviename == null || moviename.equals("")) {
|
|
||||||
System.out.println("No movie found");
|
|
||||||
}
|
|
||||||
|
|
||||||
//remove unwanted blank
|
|
||||||
moviename = moviename.trim();
|
|
||||||
|
|
||||||
//replace blank with + for api-query
|
|
||||||
moviename = moviename.replace(" ", "+");
|
|
||||||
|
|
||||||
//URL wird zusammengestellt abfragetypen: http,json,xml (muss json sein um späteres trennen zu ermöglichen)
|
|
||||||
dataurl = apiurl + "t=" + moviename + "&plot=full&r=json";
|
|
||||||
|
|
||||||
url = new URL(dataurl);
|
|
||||||
is = url.openStream();
|
|
||||||
dis = new DataInputStream(is);
|
|
||||||
|
|
||||||
// lesen der Daten aus dem Antwort Stream
|
|
||||||
while ((retdata = dis.readLine()) != null) {
|
|
||||||
//retdata in json object parsen und anschließend das json Objekt "zerschneiden"
|
|
||||||
System.out.println(retdata);
|
|
||||||
JsonObject object = Json.parse(retdata).asObject();
|
|
||||||
String titelV = object.getString("Title", "");
|
|
||||||
String yearV = object.getString("Year", "");
|
|
||||||
String ratedV = object.getString("Rated", "");
|
|
||||||
String releasedV = object.getString("Released", "");
|
|
||||||
String runtimeV = object.getString("Runtime", "");
|
|
||||||
String genreV = object.getString("Genre", "");
|
|
||||||
String directorV = object.getString("Director", "");
|
|
||||||
String writerV = object.getString("Writer", "");
|
|
||||||
String actorsV = object.getString("Actors", "");
|
|
||||||
String plotV = object.getString("Plot", "");
|
|
||||||
String languageV = object.getString("Language", "");
|
|
||||||
String countryV = object.getString("Country", "");
|
|
||||||
String awardsV = object.getString("Awards", "");
|
|
||||||
String posterURL = object.getString("Poster", "");
|
|
||||||
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 response = object.getString("Response", "");
|
|
||||||
|
|
||||||
|
|
||||||
if(response.equals("False")){
|
|
||||||
ta1.appendText(noFilmFound);
|
|
||||||
Image im2 = new Image("recources/icons/close_black_2048x2048.png");
|
|
||||||
image1.setImage(im2);
|
|
||||||
}else{
|
|
||||||
//ausgabe des Textes in ta1 in jeweils neuer Zeile //TODOformatting
|
|
||||||
ta1.appendText(title+": "+titelV+"\n");
|
|
||||||
ta1.appendText(year+": "+ yearV+"\n");
|
|
||||||
ta1.appendText(rating+": "+ratedV+"\n");
|
|
||||||
ta1.appendText(publishedOn+": "+releasedV+"\n");
|
|
||||||
ta1.appendText(duration+": "+runtimeV+"\n");
|
|
||||||
ta1.appendText(genre+": "+genreV+"\n");
|
|
||||||
ta1.appendText(director+": "+directorV+"\n");
|
|
||||||
ta1.appendText(writer+": "+writerV+"\n");
|
|
||||||
ta1.appendText(actors+": "+actorsV+"\n");
|
|
||||||
ta1.appendText(plot+": "+plotV+"\n");
|
|
||||||
ta1.appendText(language+": "+languageV+"\n");
|
|
||||||
ta1.appendText(country+": "+countryV+"\n");
|
|
||||||
ta1.appendText(awards+": "+awardsV+"\n");
|
|
||||||
ta1.appendText(metascore+": "+metascoreV+"\n");
|
|
||||||
ta1.appendText(imdbRating+": "+imdbRatingV+"\n");
|
|
||||||
ta1.appendText(type+": "+typeV+"\n");
|
|
||||||
|
|
||||||
Image im1 = new Image(posterURL);
|
|
||||||
image1.setImage(im1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println(e);
|
|
||||||
} finally {
|
|
||||||
//closes datainputStream, InputStream,Scanner if not already done
|
|
||||||
try {
|
|
||||||
if (dis != null) {
|
|
||||||
dis.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is != null) {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sc != null) {
|
|
||||||
sc.close();
|
|
||||||
}
|
|
||||||
} catch (Exception e2) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
/**
|
||||||
|
* 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.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import com.eclipsesource.json.Json;
|
||||||
|
import com.eclipsesource.json.JsonObject;
|
||||||
|
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
|
||||||
|
public class apiQuery {
|
||||||
|
|
||||||
|
public apiQuery(MainWindowController m){
|
||||||
|
mainWindowController=m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MainWindowController mainWindowController;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
void startQuery(String input){
|
||||||
|
URL url = null;
|
||||||
|
Scanner sc = null;
|
||||||
|
String apiurl = "https://www.omdbapi.com/?"; //API URL
|
||||||
|
String moviename = null;
|
||||||
|
String dataurl = null;
|
||||||
|
String retdata = null;
|
||||||
|
InputStream is = null;
|
||||||
|
DataInputStream dis = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
//get film title
|
||||||
|
sc = new Scanner(System.in);
|
||||||
|
moviename = input;
|
||||||
|
|
||||||
|
// in case of no or "" Film title
|
||||||
|
if (moviename == null || moviename.equals("")) {
|
||||||
|
System.out.println("No movie found");
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove unwanted blank
|
||||||
|
moviename = moviename.trim();
|
||||||
|
|
||||||
|
//replace blank with + for api-query
|
||||||
|
moviename = moviename.replace(" ", "+");
|
||||||
|
|
||||||
|
//URL wird zusammengestellt abfragetypen: http,json,xml (muss json sein um späteres trennen zu ermöglichen)
|
||||||
|
dataurl = apiurl + "t=" + moviename + "&plot=full&r=json";
|
||||||
|
|
||||||
|
url = new URL(dataurl);
|
||||||
|
is = url.openStream();
|
||||||
|
dis = new DataInputStream(is);
|
||||||
|
|
||||||
|
// lesen der Daten aus dem Antwort Stream
|
||||||
|
while ((retdata = dis.readLine()) != null) {
|
||||||
|
//retdata in json object parsen und anschließend das json Objekt "zerschneiden"
|
||||||
|
System.out.println(retdata);
|
||||||
|
JsonObject object = Json.parse(retdata).asObject();
|
||||||
|
String titelV = object.getString("Title", "");
|
||||||
|
String yearV = object.getString("Year", "");
|
||||||
|
String ratedV = object.getString("Rated", "");
|
||||||
|
String releasedV = object.getString("Released", "");
|
||||||
|
String runtimeV = object.getString("Runtime", "");
|
||||||
|
String genreV = object.getString("Genre", "");
|
||||||
|
String directorV = object.getString("Director", "");
|
||||||
|
String writerV = object.getString("Writer", "");
|
||||||
|
String actorsV = object.getString("Actors", "");
|
||||||
|
String plotV = object.getString("Plot", "");
|
||||||
|
String languageV = object.getString("Language", "");
|
||||||
|
String countryV = object.getString("Country", "");
|
||||||
|
String awardsV = object.getString("Awards", "");
|
||||||
|
String posterURL = object.getString("Poster", "");
|
||||||
|
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 response = object.getString("Response", "");
|
||||||
|
|
||||||
|
|
||||||
|
if(response.equals("False")){
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.noFilmFound);
|
||||||
|
Image im2 = new Image("recources/icons/close_black_2048x2048.png");
|
||||||
|
mainWindowController.image1.setImage(im2);
|
||||||
|
}else{
|
||||||
|
//ausgabe des Textes in ta1 in jeweils neuer Zeile //TODOformatting
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.title+": "+titelV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.year+": "+ yearV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.rating+": "+ratedV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.publishedOn+": "+releasedV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.duration+": "+runtimeV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.genre+": "+genreV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.director+": "+directorV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.writer+": "+writerV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.actors+": "+actorsV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.plot+": "+plotV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.language+": "+languageV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.country+": "+countryV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.awards+": "+awardsV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.metascore+": "+metascoreV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.imdbRating+": "+imdbRatingV+"\n");
|
||||||
|
mainWindowController.ta1.appendText(mainWindowController.type+": "+typeV+"\n");
|
||||||
|
|
||||||
|
Image im1 = new Image(posterURL);
|
||||||
|
mainWindowController.image1.setImage(im1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e);
|
||||||
|
} finally {
|
||||||
|
//closes datainputStream, InputStream,Scanner if not already done
|
||||||
|
try {
|
||||||
|
if (dis != null) {
|
||||||
|
dis.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is != null) {
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sc != null) {
|
||||||
|
sc.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
package application;
|
|
||||||
|
|
||||||
import javafx.beans.property.DoubleProperty;
|
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
import javafx.beans.property.StringProperty;
|
|
||||||
|
|
||||||
public class uiData {
|
|
||||||
|
|
||||||
private DoubleProperty filmBewertung = new SimpleDoubleProperty();
|
|
||||||
private StringProperty filmName = new SimpleStringProperty();
|
|
||||||
private StringProperty dataName = new SimpleStringProperty();
|
|
||||||
|
|
||||||
//uiData ist der Typ der Daten in der TreeTabelView
|
|
||||||
public uiData (final Double filmBewertung, final String filmName, final String dataName) {
|
|
||||||
this.filmBewertung.set(filmBewertung);
|
|
||||||
this.filmName.set(filmName);
|
|
||||||
this.dataName.set(dataName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double getFilmBewertung() {
|
|
||||||
return filmBewertung.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilmName() {
|
|
||||||
return filmName.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDataName() {
|
|
||||||
return dataName.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setFilmBewertung(Double filmBewertung) {
|
|
||||||
this.filmBewertung.set(filmBewertung);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFilmName(String filmName) {
|
|
||||||
this.filmName.set(filmName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataName(StringProperty dataName) {
|
|
||||||
this.dataName = dataName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DoubleProperty FilmBewertungProperty(){
|
|
||||||
return filmBewertung;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringProperty FilmNameProperty(){
|
|
||||||
return filmName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringProperty DataNameProperty(){
|
|
||||||
return dataName;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* updater for Project HomeFlix
|
||||||
|
* checks for Updates and downloads it in case there is one
|
||||||
|
*/
|
||||||
|
package application;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.channels.Channels;
|
||||||
|
import java.nio.channels.ReadableByteChannel;
|
||||||
|
|
||||||
|
public class updater {
|
||||||
|
|
||||||
|
public updater(MainWindowController m){
|
||||||
|
mainWindowController=m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MainWindowController mainWindowController;
|
||||||
|
|
||||||
|
void update(String buildURL,String downloadLink,String aktBuildNumber,String buildNumber){
|
||||||
|
System.out.println("check for updates ...");
|
||||||
|
try {
|
||||||
|
URL url = new URL(buildURL); //URL der Datei mit aktueller Versionsnummer
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||||
|
aktBuildNumber = in.readLine(); //schreibt inputstream in String
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
mainWindowController.showErrorMsg(mainWindowController.errorUpdateV, e1);
|
||||||
|
}
|
||||||
|
System.out.println("Build: "+buildNumber+", Update: "+aktBuildNumber);
|
||||||
|
|
||||||
|
//vergleicht die Versionsnummern, bei aktversion > version wird ein Update durchgrf<EFBFBD>hrt
|
||||||
|
int iversion = Integer.parseInt(buildNumber);
|
||||||
|
int iaktVersion = Integer.parseInt(aktBuildNumber.replace(".", ""));
|
||||||
|
|
||||||
|
if(iversion >= iaktVersion){
|
||||||
|
mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnNotavail"));
|
||||||
|
System.out.println("no update available");
|
||||||
|
}else{
|
||||||
|
mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnavail"));
|
||||||
|
System.out.println("update available");
|
||||||
|
try {
|
||||||
|
URL website;
|
||||||
|
URL downloadURL = new URL(downloadLink);
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(downloadURL.openStream()));
|
||||||
|
String updateDataURL = in.readLine();
|
||||||
|
website = new URL(updateDataURL); //Update URL
|
||||||
|
ReadableByteChannel rbc = Channels.newChannel(website.openStream()); //open new Stream/Channel
|
||||||
|
FileOutputStream fos = new FileOutputStream("ProjectHomeFlix.jar"); //nea fileoutputstram for ProjectHomeFLix.jar
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); //gets file from 0 to max size
|
||||||
|
fos.close(); //close fos (extrem wichtig!)
|
||||||
|
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again
|
||||||
|
System.exit(0); //finishes itself
|
||||||
|
} catch (IOException e) {
|
||||||
|
//in case there is an error
|
||||||
|
mainWindowController.showErrorMsg(mainWindowController.errorUpdateD, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue