fixed issue #6
This commit is contained in:
parent
079f15cd59
commit
9f8c19ab8e
|
@ -161,6 +161,7 @@ public class DBController {
|
||||||
String path = source.asObject().getString("path", "");
|
String path = source.asObject().getString("path", "");
|
||||||
String mode = source.asObject().getString("mode", "");
|
String mode = source.asObject().getString("mode", "");
|
||||||
mainWindowController.addSourceToTable(path, mode); // add source to source-table
|
mainWindowController.addSourceToTable(path, mode); // add source to source-table
|
||||||
|
|
||||||
if (mode.equals("local")) {
|
if (mode.equals("local")) {
|
||||||
for (File file : new File(path).listFiles()) {
|
for (File file : new File(path).listFiles()) {
|
||||||
if (file.isFile() && isVideoFile(file.getPath())) {
|
if (file.isFile() && isVideoFile(file.getPath())) {
|
||||||
|
@ -350,11 +351,11 @@ public class DBController {
|
||||||
int sn = 1;
|
int sn = 1;
|
||||||
for (File season : file.listFiles()) {
|
for (File season : file.listFiles()) {
|
||||||
if (season.isDirectory()) {
|
if (season.isDirectory()) {
|
||||||
int ep = 1;
|
int ep = getLastEpisode(cutOffEnd(file.getName()), Integer.toString(sn)) + 1;
|
||||||
for (File episode : season.listFiles()) {
|
for (File episode : season.listFiles()) {
|
||||||
if (!filmsdbStreamURL.contains(episode.getPath())) {
|
if (!filmsdbStreamURL.contains(episode.getPath())) {
|
||||||
ps.setString(1, episode.getPath().replace("'", "''"));
|
ps.setString(1, episode.getPath().replace("'", "''"));
|
||||||
ps.setString(2, cutOffEnd(file.getName()));
|
ps.setString(2, cutOffEnd(file.getName())); // the title is the series root folder's name
|
||||||
ps.setString(3, Integer.toString(sn));
|
ps.setString(3, Integer.toString(sn));
|
||||||
ps.setString(4, Integer.toString(ep));
|
ps.setString(4, Integer.toString(ep));
|
||||||
ps.setInt(5, 0);
|
ps.setInt(5, 0);
|
||||||
|
@ -406,6 +407,34 @@ public class DBController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the last episode of a season of a given series
|
||||||
|
* @param seriesTitle the actual series
|
||||||
|
* @param season the actual season
|
||||||
|
* @return the last episode number
|
||||||
|
*/
|
||||||
|
private int getLastEpisode(String seriesTitle, String season) {
|
||||||
|
int lastEpisode = 0;
|
||||||
|
try {
|
||||||
|
Statement stmt = connection.createStatement();
|
||||||
|
PreparedStatement ps = connection.prepareStatement("SELECT * FROM films WHERE title = ? AND season = ?");
|
||||||
|
ps.setString(1, seriesTitle);
|
||||||
|
ps.setString(2, season);
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
if (Integer.parseInt(rs.getString("episode")) > lastEpisode)
|
||||||
|
lastEpisode = Integer.parseInt(rs.getString("episode"));
|
||||||
|
}
|
||||||
|
stmt.close();
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error("An error occured, while printing all entries", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastEpisode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DEBUG
|
* DEBUG
|
||||||
* prints all entries from the database to the console
|
* prints all entries from the database to the console
|
||||||
|
|
Loading…
Reference in New Issue