Browse Source

small omdbAPI query fixes

pull/12/head
Jannik 4 years ago
parent
commit
29c6b30168
  1. 2
      src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java
  2. 4
      src/main/java/kellerkinder/HomeFlix/controller/DBController.java
  3. 31
      src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java

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

@ -826,8 +826,6 @@ public class MainWindowController {
Runnable OMDbAPIWorker = new OMDbAPIController(main, dbController, entry, omdbAPIKey, false);
executor.execute(OMDbAPIWorker);
// TODO for entries not available show homeflix logo and set cached
}
executor.shutdown();

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

@ -389,7 +389,7 @@ public class DBController {
try {
PreparedStatement ps = connection.prepareStatement("insert into cache values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
LOGGER.info("adding to cache: " + omdbResponse.getTitle());
LOGGER.info("adding cache for: " + streamUrl);
ps.setString(1,streamUrl);
ps.setString(2,omdbResponse.getTitle());
ps.setString(3,omdbResponse.getYear());
@ -550,6 +550,8 @@ public class DBController {
} catch (SQLException e) {
LOGGER.error("An error occured, while getting all NOT cached entries", e);
}
LOGGER.info("There are {} entries not Chached!", notCachedEntries.size());
return notCachedEntries;
}

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

@ -73,13 +73,19 @@ public class OMDbAPIController implements Runnable {
LOGGER.info("Querying omdbAPI ...");
JsonObject object;
object = getByTitle(currentTableFilm.getTitle());
if (object == null) return;
if (object == null) {
LOGGER.error("Fatal error while querying omdbAPI!");
return;
}
// if the answer contains "not found!" try to search by title
if (object.getString("Error", "").contains("not found!")) {
String title = searchByTitle(currentTableFilm.getTitle());
if (title.length() > 0) {
// we have at least on answer, get info by title now
object = getByTitle(title);
// if we still have nothing found, get info by title without episode
if(object.getString("Error", "").contains("Series or episode not found!")) {
useEpisode = false;
object = getByTitle(title);
@ -127,15 +133,18 @@ public class OMDbAPIController implements Runnable {
LOGGER.error(e);
}
// adding to cache
dbController.addCache(currentTableFilm.getStreamUrl(), omdbResponse);
dbController.setCached(currentTableFilm.getStreamUrl());
// load data to the MainWindowController
if (refresh) {
Platform.runLater(() -> {
dbController.readCache(currentTableFilm.getStreamUrl());
});
synchronized (this) {
// adding to cache
dbController.addCache(currentTableFilm.getStreamUrl(), omdbResponse);
dbController.setCached(currentTableFilm.getStreamUrl());
// load data to the MainWindowController
if (refresh) {
Platform.runLater(() -> {
dbController.readCache(currentTableFilm.getStreamUrl());
});
}
}
return;
@ -206,7 +215,9 @@ public class OMDbAPIController implements Runnable {
return movie.asObject().getString("Title", "");
}
} else {
LOGGER.warn("Movie not found! Not adding cache!");
// TODO set cached 1 and set the HomeFlix logo as picture
// System.out.println("Object is: " + searchObject);
LOGGER.warn("Movie \"{}\" not found! Not adding cache!", title);
}
return "";
}

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