Browse Source

changed season & episode to string

* changed season & episode to string, if the entry is not part of a series those columns are empty
* changed rating to boolean
* renamed rating to favorite
* updated translations
pull/22/head
Jannik 4 years ago
parent
commit
b4176d0dfa
  1. 39
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java
  2. 33
      src/main/java/kellerkinder/HomeFlix/controller/DBController.java
  3. 49
      src/main/java/kellerkinder/HomeFlix/datatypes/FilmTabelDataType.java
  4. 5
      src/main/resources/locals/HomeFlix-Local_de_DE.properties
  5. 5
      src/main/resources/locals/HomeFlix-Local_en_US.properties

39
src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java

@ -205,17 +205,17 @@ public class MainWindowController {
private ImageView imv1;
@FXML
private TreeItem<FilmTabelDataType> filmRoot = new TreeItem<>(new FilmTabelDataType("", "", 0, 0, 0, false, imv1));
private TreeItem<FilmTabelDataType> filmRoot = new TreeItem<>(new FilmTabelDataType("", "", "", "", false, false, imv1));
@FXML
private TreeTableColumn<FilmTabelDataType, String> columnStreamUrl = new TreeTableColumn<>("File Name");
@FXML
private TreeTableColumn<FilmTabelDataType, String> columnTitle = new TreeTableColumn<>("Title");
@FXML
private TreeTableColumn<FilmTabelDataType, Integer> columnSeason = new TreeTableColumn<>("Season");
private TreeTableColumn<FilmTabelDataType, String> columnSeason = new TreeTableColumn<>("Season");
@FXML
private TreeTableColumn<FilmTabelDataType, Integer> columnEpisode = new TreeTableColumn<>("Episode");
private TreeTableColumn<FilmTabelDataType, String> columnEpisode = new TreeTableColumn<>("Episode");
@FXML
private TreeTableColumn<FilmTabelDataType, ImageView> columnRating = new TreeTableColumn<>("Rating");
private TreeTableColumn<FilmTabelDataType, ImageView> columnFavorite = new TreeTableColumn<>("Favorite");
@FXML
private TreeItem<SourceDataType> sourceRoot =new TreeItem<>(new SourceDataType("", ""));
@ -304,10 +304,10 @@ public class MainWindowController {
// film Table
columnStreamUrl.setMaxWidth(0);
columnTitle.setMaxWidth(215);
columnRating.setMaxWidth(60);
columnFavorite.setMaxWidth(60);
columnSeason.setMaxWidth(55);
columnEpisode.setMaxWidth(64);
columnRating.setStyle("-fx-alignment: CENTER;");
columnFavorite.setStyle("-fx-alignment: CENTER;");
filmsTreeTable.setRoot(filmRoot);
filmsTreeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
@ -316,14 +316,14 @@ public class MainWindowController {
// write content into cell
columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty());
columnTitle.setCellValueFactory(cellData -> cellData.getValue().getValue().titleProperty());
columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject());
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty());
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty());
columnFavorite.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
// add columns to treeTableViewfilm
filmsTreeTable.getColumns().add(columnStreamUrl);
filmsTreeTable.getColumns().add(columnTitle);
filmsTreeTable.getColumns().add(columnRating);
filmsTreeTable.getColumns().add(columnFavorite);
filmsTreeTable.getColumns().add(columnSeason);
filmsTreeTable.getColumns().add(columnEpisode);
filmsTreeTable.getColumns().get(0).setVisible(false); //hide columnStreamUrl (important)
@ -442,7 +442,7 @@ public class MainWindowController {
/**
* FIXME fix bug when sort by ASCENDING, wrong order
*/
columnRating.sortTypeProperty().addListener(new ChangeListener<SortType>() {
columnFavorite.sortTypeProperty().addListener(new ChangeListener<SortType>() {
@Override
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) {
LOGGER.info("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
@ -456,7 +456,7 @@ public class MainWindowController {
helpData = filmsList;
for (int i = 0; i < helpData.size(); i++) {
if (helpData.get(i).getRating() == 1.0) {
if (helpData.get(i).getFavorite() == true) {
fav_true.add(i);
} else {
fav_false.add(i);
@ -688,7 +688,9 @@ public class MainWindowController {
public void addDataUI() {
for (FilmTabelDataType element : filmsList) {
if (element.getSeason() != 0) {
// only if the entry contains a season and a episode it's a valid series
if (!element.getSeason().isEmpty() && !element.getEpisode().isEmpty()) {
// System.out.println("Found Series: " + element.getTitle());
// check if there is a series node to add the item
for (int i = 0; i < filmRoot.getChildren().size(); i++) {
@ -696,14 +698,14 @@ public class MainWindowController {
// System.out.println("Found a root node to add child");
// System.out.println("Adding: " + element.getStreamUrl());
TreeItem<FilmTabelDataType> episodeNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
element.getTitle(), element.getSeason(), element.getEpisode(), element.getRating(),
element.getTitle(), element.getSeason(), element.getEpisode(), element.getFavorite(),
element.getCached(), element.getImage()));
filmRoot.getChildren().get(i).getChildren().add(episodeNode);
} else if (i == filmRoot.getChildren().size() - 1) {
// System.out.println("Create a root node to add child");
// System.out.println("Adding: " + element.getStreamUrl());
TreeItem<FilmTabelDataType> seriesRootNode = new TreeItem<>(new FilmTabelDataType(element.getStreamUrl(),
element.getTitle(), 0, 0, element.getRating(), element.getCached(), element.getImage()));
element.getTitle(), "", "", element.getFavorite(), element.getCached(), element.getImage()));
filmRoot.getChildren().add(seriesRootNode);
}
}
@ -831,10 +833,11 @@ public class MainWindowController {
languageLbl.setText(getBundle().getString("languageLbl"));
autoUpdateToggleBtn.setText(getBundle().getString("autoUpdate"));
branchLbl.setText(getBundle().getString("branchLbl"));
columnTitle.setText(getBundle().getString("columnName"));
columnRating.setText(getBundle().getString("columnRating"));
columnStreamUrl.setText(getBundle().getString("columnStreamUrl"));
columnTitle.setText(getBundle().getString("columnName"));
columnSeason.setText(getBundle().getString("columnSeason"));
columnEpisode.setText(getBundle().getString("columnEpisode"));
columnFavorite.setText(getBundle().getString("columnFavorite"));
errorPlay = getBundle().getString("errorPlay");
errorLoad = getBundle().getString("errorLoad");
errorSave = getBundle().getString("errorSave");
@ -884,7 +887,7 @@ public class MainWindowController {
props.setProperty("useBeta", String.valueOf(isUseBeta()));
props.setProperty("size", getSize().toString());
props.setProperty("local", getLocal());
props.setProperty("ratingSortType", columnRating.getSortType().toString());
props.setProperty("ratingSortType", columnFavorite.getSortType().toString());
OutputStream outputStream = new FileOutputStream(main.getConfigFile()); // new output-stream
props.storeToXML(outputStream, "Project HomeFlix settings"); // writes new .xml

33
src/main/java/kellerkinder/HomeFlix/controller/DBController.java

@ -99,7 +99,7 @@ public class DBController {
private void createDatabase() {
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("create table if not exists films (streamUrl, title, season, episode, rating, cached)");
stmt.executeUpdate("create table if not exists films (streamUrl, title, season, episode, favorite, cached)");
stmt.executeUpdate("create table if not exists cache ("
+ "streamUrl, Title, Year, Rated, Released, Runtime, Genre, Director, Writer,"
+ " Actors, Plot, Language, Country, Awards, Metascore, imdbRating, imdbVotes,"
@ -189,13 +189,14 @@ public class DBController {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM films ORDER BY title");
while (rs.next()) {
if (rs.getInt("rating") == 1) {
// System.out.println(rs.getString("title") + "Season:" + rs.getString("season") + ":");
if (rs.getBoolean("favorite") == true) {
mainWindowController.getFilmsList().add(new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
rs.getString("title"), rs.getString("season"), rs.getString("episode") ,rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_black)));
} else {
mainWindowController.getFilmsList().add(new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
rs.getString("title"), rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
}
}
@ -220,13 +221,13 @@ public class DBController {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE streamUrl = \"" + streamUrl + "\";");
if (rs.getInt("rating") == 1) {
if (rs.getBoolean("favorite") == true) {
mainWindowController.getFilmsList().set(indexList, new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getInt("season"), rs.getInt("episode") ,rs.getDouble("rating"),
rs.getString("title"), rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_black)));
} else {
mainWindowController.getFilmsList().set(indexList, new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getInt("season"), rs.getInt("episode"), rs.getDouble("rating"),
rs.getString("title"), rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_border_black)));
}
@ -316,7 +317,7 @@ public class DBController {
if (!filmsdbStreamURL.contains(file.getPath())) {
stmt.executeUpdate("insert into films values ("
+ "'" + file.getPath() + "',"
+ "'" + cutOffEnd(file.getName()) + "', 0, 0, 0, 0)");
+ "'" + cutOffEnd(file.getName()) + "', '', '', 0, 0)");
connection.commit();
stmt.close();
LOGGER.info("Added \"" + file.getName() + "\" to database");
@ -333,7 +334,7 @@ public class DBController {
LOGGER.info("Added \"" + file.getName() + "\", Episode: " + episode.getName() + " to database");
stmt.executeUpdate("insert into films values ("
+ "'" + episode.getPath() + "',"
+ "'" + cutOffEnd(file.getName()) + "',"+ sn + "," + ep + ", 0, 0)");
+ "'" + cutOffEnd(file.getName()) + "','" + sn + "','" + ep + "', 0, 0)");
connection.commit();
stmt.close();
filmsStreamURL.add(episode.getPath());
@ -361,8 +362,8 @@ public class DBController {
if (streamUrl.equals(entry)) {
ps.setString(1, streamUrl);
ps.setString(2, title);
ps.setInt(3, item.asObject().getInt("season", 0));
ps.setInt(4, item.asObject().getInt("episode", 0));
ps.setString(3, item.asObject().getString("season", ""));
ps.setString(4, item.asObject().getString("episode", ""));
ps.setInt(5, 0);
ps.setBoolean(6, false);
ps.addBatch(); // adds the entry
@ -401,15 +402,14 @@ public class DBController {
}
/**
* update the database entry for the given film, rating = 0
* @param name of the film
* update the database entry for the given film, favorite = 0
* @param streamUrl URL of the film
*/
public void dislike(String streamUrl) {
LOGGER.info("dislike " + streamUrl);
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE films SET rating=0 WHERE streamUrl=\"" + streamUrl + "\";");
stmt.executeUpdate("UPDATE films SET favorite=0 WHERE streamUrl=\"" + streamUrl + "\";");
connection.commit();
stmt.close();
} catch (SQLException e) {
@ -418,15 +418,14 @@ public class DBController {
}
/**
* update the database entry for the given film, rating = 1
* @param name of the film
* update the database entry for the given film, favorite = 1
* @param streamUrl URL of the film
*/
public void like(String streamUrl) {
LOGGER.info("like " + streamUrl);
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE films SET rating=1 WHERE streamUrl=\"" + streamUrl + "\";");
stmt.executeUpdate("UPDATE films SET favorite=1 WHERE streamUrl=\"" + streamUrl + "\";");
connection.commit();
stmt.close();
} catch (SQLException e) {

49
src/main/java/kellerkinder/HomeFlix/datatypes/FilmTabelDataType.java

@ -22,42 +22,39 @@
package kellerkinder.HomeFlix.datatypes;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.image.ImageView;
public class FilmTabelDataType {
private final IntegerProperty season = new SimpleIntegerProperty();
private final IntegerProperty episode = new SimpleIntegerProperty();
private final DoubleProperty rating = new SimpleDoubleProperty();
private final StringProperty title = new SimpleStringProperty();
private final StringProperty streamUrl = new SimpleStringProperty();
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
private final StringProperty title = new SimpleStringProperty();
private final StringProperty season = new SimpleStringProperty();
private final StringProperty episode = new SimpleStringProperty();
private final BooleanProperty favorite = new SimpleBooleanProperty();
private final BooleanProperty cached = new SimpleBooleanProperty();
private final SimpleObjectProperty<ImageView> image = new SimpleObjectProperty<>();
/** TODO rating boolean
/**
* tableData is the data-type of tree-table-view
* @param streamUrl the concrete path to the file or the URL
* @param title title of the film
* @param season season if it's a series
* @param episode episode if it's a series
* @param rating indicator for favorites, used for sorting the items
* @param favorite indicator for favorites, used for sorting the items
* @param cached indicator for caching status
* @param image favorite icon
*/
public FilmTabelDataType(final String streamUrl, final String title, final int season, final int episode,
final double rating, final boolean cached, final ImageView image) {
public FilmTabelDataType(final String streamUrl, final String title, final String season, final String episode,
final boolean favorite, final boolean cached, final ImageView image) {
this.streamUrl.set(streamUrl);
this.title.set(title);
this.season.set(season);
this.episode.set(episode);
this.rating.set(rating);
this.favorite.set(favorite);
this.cached.set(cached);
this.image.set(image);
}
@ -70,16 +67,16 @@ public class FilmTabelDataType {
return title;
}
public IntegerProperty seasonProperty(){
public StringProperty seasonProperty(){
return season;
}
public IntegerProperty episodeProperty(){
public StringProperty episodeProperty(){
return episode;
}
public DoubleProperty ratingProperty(){
return rating;
public BooleanProperty favoriteProperty(){
return favorite;
}
public BooleanProperty cachedProperty(){
@ -99,16 +96,16 @@ public class FilmTabelDataType {
return titleProperty().get();
}
public final int getSeason() {
public final String getSeason() {
return seasonProperty().get();
}
public final int getEpisode() {
public final String getEpisode() {
return episodeProperty().get();
}
public final double getRating() {
return ratingProperty().get();
public final boolean getFavorite() {
return favoriteProperty().get();
}
public final boolean getCached(){
@ -128,16 +125,16 @@ public class FilmTabelDataType {
titleProperty().set(title);
}
public final void setSeason(int season) {
public final void setSeason(String season) {
seasonProperty().set(season);
}
public final void setEpisode(int season) {
public final void setEpisode(String season) {
episodeProperty().set(season);
}
public final void setRating(int rating) {
ratingProperty().set(rating);
public final void setFavorite(boolean favorite) {
favoriteProperty().set(favorite);
}
public final void setCached(boolean cached){

5
src/main/resources/locals/HomeFlix-Local_de_DE.properties

@ -23,10 +23,11 @@ autoUpdate = beim Start nach Updates suchen:
branchLbl = Updatezweig
#column translations
columnName = Name
columnRating = Bewertung
columnStreamUrl = Datei Name
columnName = Name
columnSeason = Staffel
columnEpisode = Episode
columnFavorite = Favorit
#error translations
errorUpdateV = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not check update version (nvc)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz

5
src/main/resources/locals/HomeFlix-Local_en_US.properties

@ -23,10 +23,11 @@ autoUpdate = check at startup for updates:
branchLbl = Branch
#column translations
columnName = Name
columnRating = Rating
columnStreamUrl = File Name
columnName = Name
columnSeason = Season
columnEpisode = Episode
columnFavorite = Favorite
#error translations
errorUpdateV = An error has occurred during update! \nError: could not check update version (nvc) \nTo get help, visit www.kellerkinder.xyz \nor contcat support@kellerkinder.xyz

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close