series work

This commit is contained in:
Jannik
2018-04-13 11:11:25 +02:00
parent 2c1ce23315
commit 913513a237
2 changed files with 45 additions and 37 deletions

View File

@ -546,6 +546,7 @@ public class DBController {
*/
public void readCache(String streamUrl) {
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM cache WHERE streamUrl=\"" + streamUrl + "\";");
ArrayList<Text> nameText = new ArrayList<Text>();
@ -575,6 +576,7 @@ public class DBController {
responseText.add(new Text(rs.getString(j) + "\n"));
j++;
}
responseText.add(new Text(rs.getString(19) + "\n"));
im = new Image(new File(rs.getString(20)).toURI().toString());
@ -620,7 +622,7 @@ public class DBController {
rs.close();
stmt.close();
} catch (Exception e) {
LOGGER.error("Ups! error while refreshing mwc!", e);
LOGGER.error("Ups! error while getting the current time!", e);
}
return currentTime;
@ -673,6 +675,28 @@ public class DBController {
return nextFilm;
}
public String getLastWatchedEpisode(String title) {
LOGGER.info("last watched episode of: " + title);
String lastEpisodeStreamUrl = "";
double lastCurrentTime = -1;
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE title = \"" + title + "\";");
while (rs.next()) {
if (rs.getDouble("currentTime") > lastCurrentTime) {
lastCurrentTime = rs.getDouble("currentTime");
lastEpisodeStreamUrl = rs.getString("streamUrl");
}
}
} catch (Exception e) {
LOGGER.error("Ups! error while getting the last watched episode!", e);
}
return lastEpisodeStreamUrl;
}
// removes the ending
private String cutOffEnd(String str) {
if (str == null) return null;