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
This commit is contained in:
Jannik 2018-05-09 22:40:14 +02:00
parent 402a004ef6
commit 46efa77fce
2 changed files with 14 additions and 4 deletions

View File

@ -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"));

View File

@ -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