minor fixes

This commit is contained in:
Jannik 2018-03-05 23:03:05 +01:00
parent f27c3810ff
commit 835f2eab77
4 changed files with 55 additions and 55 deletions

View File

@ -215,7 +215,7 @@ public class MainWindowController {
@FXML @FXML
TreeTableColumn<FilmTabelDataType, ImageView> columnRating = new TreeTableColumn<>("Rating"); TreeTableColumn<FilmTabelDataType, ImageView> columnRating = new TreeTableColumn<>("Rating");
@FXML @FXML
TreeTableColumn<FilmTabelDataType, String> columnTitel = new TreeTableColumn<>("Titel"); TreeTableColumn<FilmTabelDataType, String> columnTitle = new TreeTableColumn<>("Title");
@FXML @FXML
TreeTableColumn<FilmTabelDataType, String> columnStreamUrl = new TreeTableColumn<>("File Name"); TreeTableColumn<FilmTabelDataType, String> columnStreamUrl = new TreeTableColumn<>("File Name");
@FXML @FXML
@ -317,14 +317,14 @@ public class MainWindowController {
treeTableViewfilm.setShowRoot(false); treeTableViewfilm.setShowRoot(false);
// write content into cell // write content into cell
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty()); columnTitle.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty());
columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty()); columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty()); columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty());
columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject()); columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject());
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject()); columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
// add columns to treeTableViewfilm // add columns to treeTableViewfilm
treeTableViewfilm.getColumns().add(columnTitel); treeTableViewfilm.getColumns().add(columnTitle);
treeTableViewfilm.getColumns().add(columnRating); treeTableViewfilm.getColumns().add(columnRating);
treeTableViewfilm.getColumns().add(columnStreamUrl); treeTableViewfilm.getColumns().add(columnStreamUrl);
treeTableViewfilm.getColumns().add(columnSeason); treeTableViewfilm.getColumns().add(columnSeason);
@ -506,7 +506,7 @@ public class MainWindowController {
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;
title = columnTitel.getCellData(selected); // get name of selected item title = columnTitle.getCellData(selected); // get name of selected item
streamUrl = columnStreamUrl.getCellData(selected); // get file path of selected item streamUrl = columnStreamUrl.getCellData(selected); // get file path of selected item
if (mode.equals("local")) { if (mode.equals("local")) {
@ -732,21 +732,21 @@ public class MainWindowController {
} }
// TODO rework // TODO rework
public void addDataUI(){ public void addDataUI() {
if(mode.equals("local")){ if (mode.equals("local")) {
for(int i = 0; i < localFilms.size(); i++){ for (int i = 0; i < localFilms.size(); i++) {
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(localFilms.get(i))); //add data to root-node filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(localFilms.get(i))); // add data to root-node
} }
columnRating.setMaxWidth(85); columnRating.setMaxWidth(85);
columnTitel.setMaxWidth(290); columnTitle.setMaxWidth(290);
treeTableViewfilm.getColumns().get(3).setVisible(false); treeTableViewfilm.getColumns().get(3).setVisible(false);
treeTableViewfilm.getColumns().get(4).setVisible(false); treeTableViewfilm.getColumns().get(4).setVisible(false);
}else if(mode.equals("streaming")){ } else {
for(int i = 0; i < streamingFilms.size(); i++){ for (int i = 0; i < streamingFilms.size(); i++) {
filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(streamingFilms.get(i))); //add data to root-node filmRoot.getChildren().add(new TreeItem<FilmTabelDataType>(streamingFilms.get(i))); // add data to root-node
} }
columnTitel.setMaxWidth(215); columnTitle.setMaxWidth(215);
columnRating.setMaxWidth(60); columnRating.setMaxWidth(60);
columnSeason.setMaxWidth(55); columnSeason.setMaxWidth(55);
columnEpisode.setMaxWidth(64); columnEpisode.setMaxWidth(64);
@ -755,11 +755,13 @@ public class MainWindowController {
} }
} }
// add a source to the sources table on the settings pane
public void addSourceToTable(String path, String mode) { public void addSourceToTable(String path, String mode) {
sourcesList.add(new SourceDataType(path, mode)); sourcesList.add(new SourceDataType(path, mode));
streamingRoot.getChildren().add(new TreeItem<SourceDataType>(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node streamingRoot.getChildren().add(new TreeItem<SourceDataType>(sourcesList.get(sourcesList.size() - 1))); // adds data to root-node
} }
// add a source to the newsources list
public void addSource(String path, String mode) { public void addSource(String path, String mode) {
JsonObject source = null; JsonObject source = null;
JsonArray newsources = null; JsonArray newsources = null;
@ -879,7 +881,7 @@ public class MainWindowController {
languageLbl.setText(getBundle().getString("languageLbl")); languageLbl.setText(getBundle().getString("languageLbl"));
autoUpdateToggleBtn.setText(getBundle().getString("autoUpdate")); autoUpdateToggleBtn.setText(getBundle().getString("autoUpdate"));
branchLbl.setText(getBundle().getString("branchLbl")); branchLbl.setText(getBundle().getString("branchLbl"));
columnTitel.setText(getBundle().getString("columnName")); columnTitle.setText(getBundle().getString("columnName"));
columnRating.setText(getBundle().getString("columnRating")); columnRating.setText(getBundle().getString("columnRating"));
columnStreamUrl.setText(getBundle().getString("columnStreamUrl")); columnStreamUrl.setText(getBundle().getString("columnStreamUrl"));
columnSeason.setText(getBundle().getString("columnSeason")); columnSeason.setText(getBundle().getString("columnSeason"));

View File

@ -100,8 +100,8 @@ public class DBController {
private void createDatabase() { private void createDatabase() {
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, cached)"); stmt.executeUpdate("create table if not exists film_local (rating, title, streamUrl, cached)");
stmt.executeUpdate("create table if not exists film_streaming (season, episode, rating, titel, streamUrl, cached)"); stmt.executeUpdate("create table if not exists film_streaming (season, episode, rating, title, streamUrl, cached)");
stmt.executeUpdate("create table if not exists cache (" stmt.executeUpdate("create table if not exists cache ("
+ "streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer," + "streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer,"
+ " Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes," + " Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes,"
@ -119,14 +119,14 @@ public class DBController {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
while (rs.next()) { while (rs.next()) {
filmsdbDir.add(rs.getString("titel")); filmsdbDir.add(rs.getString("title"));
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
rs = stmt.executeQuery("SELECT * FROM film_streaming;"); rs = stmt.executeQuery("SELECT * FROM film_streaming;");
while (rs.next()) { while (rs.next()) {
filmsdbAll.add(rs.getString("titel")); filmsdbAll.add(rs.getString("title"));
filmsdbStreamURL.add(rs.getString("streamUrl")); filmsdbStreamURL.add(rs.getString("streamUrl"));
} }
stmt.close(); stmt.close();
@ -169,10 +169,10 @@ public class DBController {
JsonObject object = Json.parse(new FileReader(path)).asObject(); JsonObject object = Json.parse(new FileReader(path)).asObject();
JsonArray items = object.get("entries").asArray(); JsonArray items = object.get("entries").asArray();
for (JsonValue item : items) { for (JsonValue item : items) {
filmsAll.add(item.asObject().getString("titel", "")); filmsAll.add(item.asObject().getString("title", ""));
filmsStreamURL.add(item.asObject().getString("streamUrl", "")); filmsStreamURL.add(item.asObject().getString("streamUrl", ""));
// TODO check if all this is needed, maybe only use one table! // TODO check if all this is needed, maybe only use one table!
// System.out.println(item.asObject().getString("titel", "")); // System.out.println(item.asObject().getString("title", ""));
// System.out.println(item.asObject().getString("streamUrl", "")); // System.out.println(item.asObject().getString("streamUrl", ""));
} }
LOGGER.info("added films from: " + path); LOGGER.info("added films from: " + path);
@ -192,29 +192,29 @@ public class DBController {
try { try {
//load local Data //load local Data
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY titel"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY title");
while (rs.next()) { while (rs.next()) {
if (rs.getInt("rating") == 1) { if (rs.getInt("rating") == 1) {
mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("titel"), mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("title"),
rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached")));
} else { } else {
mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("titel"), mainWindowController.getLocalFilms().add(new FilmTabelDataType(1, 1, rs.getDouble("rating"), rs.getString("title"),
rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached")));
} }
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
//load streaming Data FIXME check if there are streaming data before loading -> maybe there is an issue now //load streaming Data
rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY titel;"); rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY title;");
while (rs.next()) { while (rs.next()) {
if (rs.getInt("rating") == 1) { if (rs.getInt("rating") == 1) {
mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"), mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"),
rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"), rs.getInt("episode"), rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"),
new ImageView(favorite_black), rs.getBoolean("cached"))); new ImageView(favorite_black), rs.getBoolean("cached")));
} else { } else {
mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"), mainWindowController.getStreamingFilms().add(new FilmTabelDataType(rs.getInt("season"),
rs.getInt("episode"),rs.getDouble("rating"), rs.getString("titel"),rs.getString("streamUrl"), rs.getInt("episode"),rs.getDouble("rating"), rs.getString("title"),rs.getString("streamUrl"),
new ImageView(favorite_border_black), rs.getBoolean("cached"))); new ImageView(favorite_border_black), rs.getBoolean("cached")));
} }
} }
@ -243,21 +243,21 @@ public class DBController {
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE streamUrl = \"" + streamUrl + "\";"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE streamUrl = \"" + streamUrl + "\";");
if (rs.getInt("rating") == 1) { if (rs.getInt("rating") == 1) {
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"), mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"),
rs.getString("titel"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached"))); rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_black), rs.getBoolean("cached")));
} else { } else {
mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"), mainWindowController.getLocalFilms().set(index, new FilmTabelDataType(1, 1, rs.getDouble("rating"),
rs.getString("titel"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached"))); rs.getString("title"), rs.getString("streamUrl"), new ImageView(favorite_border_black), rs.getBoolean("cached")));
} }
rs.close(); rs.close();
} else { } else {
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE streamUrl = \"" + streamUrl + "\";"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE streamUrl = \"" + streamUrl + "\";");
if (rs.getInt("rating") == 1) { if (rs.getInt("rating") == 1) {
mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"), mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"),
rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"), rs.getInt("episode"), rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"),
new ImageView(favorite_black), rs.getBoolean("cached"))); new ImageView(favorite_black), rs.getBoolean("cached")));
} else { } else {
mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"), mainWindowController.getStreamingFilms().set(index, new FilmTabelDataType(rs.getInt("season"),
rs.getInt("episode"), rs.getDouble("rating"), rs.getString("titel"), rs.getString("streamUrl"), rs.getInt("episode"), rs.getDouble("rating"), rs.getString("title"), rs.getString("streamUrl"),
new ImageView(favorite_border_black), rs.getBoolean("cached"))); new ImageView(favorite_border_black), rs.getBoolean("cached")));
} }
rs.close(); rs.close();
@ -313,7 +313,7 @@ public class DBController {
for (String entry : filmsdbDir) { for (String entry : filmsdbDir) {
if (!filmsAll.contains(cutOffEnd(entry))) { if (!filmsAll.contains(cutOffEnd(entry))) {
stmt.executeUpdate("delete from film_local where titel = \"" + entry + "\""); stmt.executeUpdate("delete from film_local where title = \"" + entry + "\"");
connection.commit(); connection.commit();
LOGGER.info("removed \"" + entry + "\" from database"); LOGGER.info("removed \"" + entry + "\" from database");
} }
@ -341,7 +341,7 @@ public class DBController {
*/ */
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException { private void checkAddEntry() throws SQLException, FileNotFoundException, IOException {
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 (?, ?, ?, ?, ?, ?)");
LOGGER.info("checking for entrys to add to DB ..."); LOGGER.info("checking for entrys to add to DB ...");
// source is a single source of the sources list // source is a single source of the sources list
@ -351,7 +351,7 @@ public class DBController {
for (String entry : new File(source.getPath()).list()) { for (String entry : new File(source.getPath()).list()) {
if (!filmsdbAll.contains(cutOffEnd(entry))) { if (!filmsdbAll.contains(cutOffEnd(entry))) {
stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entry) + "\", \"" stmt.executeUpdate("insert into film_local values (0, \"" + cutOffEnd(entry) + "\", \""
+ source.getPath() + "/" + entry + "\",\"favorite_border_black\",0)"); + source.getPath() + "/" + entry + "\",0)");
connection.commit(); connection.commit();
stmt.close(); stmt.close();
LOGGER.info("added \"" + entry + "\" to database"); LOGGER.info("added \"" + entry + "\" to database");
@ -366,21 +366,19 @@ public class DBController {
// for each item, check if it's the needed // for each item, check if it's the needed
for (JsonValue item : items) { for (JsonValue item : items) {
String streamUrl = item.asObject().getString("streamUrl", ""); String streamUrl = item.asObject().getString("streamUrl", "");
String titel = item.asObject().getString("titel", ""); String title = item.asObject().getString("title", "");
// if it's the needed add it to the database // if it's the needed add it to the database
if (streamUrl.equals(entry)) { if (streamUrl.equals(entry)) {
ps.setInt(1, item.asObject().getInt("year", 0)); ps.setInt(1, item.asObject().getInt("season", 0));
ps.setInt(2, item.asObject().getInt("season", 0)); ps.setInt(2, item.asObject().getInt("episode", 0));
ps.setInt(3, item.asObject().getInt("episode", 0)); ps.setInt(3, 0);
ps.setInt(4, 0); ps.setString(4, title);
ps.setString(5, item.asObject().getString("resolution", "")); ps.setString(5, streamUrl);
ps.setString(6, titel); ps.setBoolean(6, false);
ps.setString(7, streamUrl);
ps.setBoolean(8, false);
ps.addBatch(); // adds the entry ps.addBatch(); // adds the entry
LOGGER.info("added \"" + titel + "\" to database"); LOGGER.info("added \"" + title + "\" to database");
filmsAll.add(cutOffEnd(titel)); filmsAll.add(cutOffEnd(title));
} }
} }
} }
@ -400,7 +398,7 @@ 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()) {
System.out.println(rs.getString("rating")); System.out.println(rs.getString("rating"));
System.out.println(rs.getString("titel")); System.out.println(rs.getString("title"));
System.out.println(rs.getString("streamUrl")); System.out.println(rs.getString("streamUrl"));
System.out.println(rs.getString("cached") + "\n"); System.out.println(rs.getString("cached") + "\n");
} }
@ -414,7 +412,7 @@ public class DBController {
System.out.println(rs.getString("season")); System.out.println(rs.getString("season"));
System.out.println(rs.getString("episode")); System.out.println(rs.getString("episode"));
System.out.println(rs.getString("rating")); System.out.println(rs.getString("rating"));
System.out.println(rs.getString("titel")); System.out.println(rs.getString("title"));
System.out.println(rs.getString("streamUrl")); System.out.println(rs.getString("streamUrl"));
System.out.println(rs.getString("cached") + "\n"); System.out.println(rs.getString("cached") + "\n");
} }

View File

@ -70,7 +70,7 @@ public class apiQuery{
/** /**
* apiQuery for Project HomeFlix, sends a query to the omdb api * apiQuery for Project HomeFlix, sends a query to the omdb api
*/ */
public void startQuery(String titel, String streamUrl){ public void startQuery(String title, String streamUrl){
URL queryURL = null; URL queryURL = null;
Scanner sc = null; Scanner sc = null;
String moviename = null; String moviename = null;
@ -89,7 +89,7 @@ public class apiQuery{
//get film title //get film title
sc = new Scanner(System.in); sc = new Scanner(System.in);
moviename = titel; moviename = title;
// in case of no or "" Film title // in case of no or "" Film title
if (moviename == null || moviename.equals("")) { if (moviename == null || moviename.equals("")) {
@ -139,11 +139,11 @@ public class apiQuery{
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 198, 297); BufferedImage resizeImagePNG = resizeImage(originalImage, type, 198, 297);
if (System.getProperty("os.name").equals("Linux")) { if (System.getProperty("os.name").equals("Linux")) {
posterPath = posterCache+"/"+titel+".png"; posterPath = posterCache+"/"+title+".png";
ImageIO.write(resizeImagePNG, "png", new File(posterCache+"/"+titel+".png")); //change path where you want it saved ImageIO.write(resizeImagePNG, "png", new File(posterCache+"/"+title+".png")); //change path where you want it saved
} else { } else {
ImageIO.write(resizeImagePNG, "png", new File(posterCache+"\\"+titel+".png")); //change path where you want it saved ImageIO.write(resizeImagePNG, "png", new File(posterCache+"\\"+title+".png")); //change path where you want it saved
posterPath = posterCache+"\\"+titel+".png"; posterPath = posterCache+"\\"+title+".png";
} }
LOGGER.info("adding poster to cache: "+posterPath); LOGGER.info("adding poster to cache: "+posterPath);

View File

@ -46,7 +46,7 @@ public class FilmTabelDataType {
* @param season season if it's a series * @param season season if it's a series
* @param episode episode if it's a series * @param episode episode if it's a series
* @param rating indicator for favorites, used for sorting the items * @param rating indicator for favorites, used for sorting the items
* @param titel title of the film * @param title title of the film
* @param streamUrl the concrete path to the file or the URL * @param streamUrl the concrete path to the file or the URL
* @param cached indicator for caching status * @param cached indicator for caching status
*/ */