Browse Source

omdb fixes

* if there is no episode for a series in the omdb, use the regular series description
* show episode and season only if needed
pull/5/head
Jannik 4 years ago
parent
commit
46efa77fce
  1. 8
      src/main/java/kellerkinder/HomeFlix/controller/DBController.java
  2. 10
      src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java

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

@ -592,8 +592,12 @@ public class DBController {
textFlow.addAll(nameText.get(1), new Text(rs.getString("Year") + "\n"));
textFlow.addAll(nameText.get(2), new Text(rs.getString("Rated") + "\n"));
textFlow.addAll(nameText.get(3), new Text(rs.getString("Released") + "\n"));
textFlow.addAll(nameText.get(4), new Text(rs.getString("Season") + "\n"));
textFlow.addAll(nameText.get(5), new Text(rs.getString("Episode") + "\n"));
if (rs.getString("Episode").length() > 0) {
textFlow.addAll(nameText.get(4), new Text(rs.getString("Season") + "\n"));
textFlow.addAll(nameText.get(5), new Text(rs.getString("Episode") + "\n"));
}
textFlow.addAll(nameText.get(6), new Text(rs.getString("Runtime") + "\n"));
textFlow.addAll(nameText.get(7), new Text(rs.getString("Genre") + "\n"));
textFlow.addAll(nameText.get(8), new Text(rs.getString("Director") + "\n"));

10
src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java

@ -47,6 +47,7 @@ public class OMDbAPIController implements Runnable {
private DBController dbController;
private Main main;
private String URL = "https://www.omdbapi.com/?apikey=";
private boolean useEpisode = true;
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
/**
@ -74,6 +75,11 @@ public class OMDbAPIController implements Runnable {
String title = searchByTitle(mainWindowController.getCurrentTitle());
if (title.length() > 0) {
object = getByTitle(title);
if(object.getString("Error", "").contains("Series or episode not found!")) {
useEpisode = false;
object = getByTitle(title);
}
} else {
return;
}
@ -133,7 +139,7 @@ public class OMDbAPIController implements Runnable {
String output = null;
URL apiUrl;
try {
if (mainWindowController.getCurrentTableFilm().getSeason().length() > 0) {
if (mainWindowController.getCurrentTableFilm().getSeason().length() > 0 && useEpisode) {
apiUrl = new URL(URL + mainWindowController.getOmdbAPIKey() + "&t="
+ title.replace(" ", "%20")
+ "&Season=" + mainWindowController.getCurrentTableFilm().getSeason()
@ -157,7 +163,7 @@ public class OMDbAPIController implements Runnable {
return Json.parse(output).asObject();
}
/** TODO if responser == false & isSereis, query without series
/**
* search for a movie/series title
* @param title the movie/series title
* @return the correct title if found

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