minor player fixes and no more other files than videos in the db
* fixed episode = ""resulting in many exceptons * only add video files to the database (and GUI) * check the videos mimetype to decide which player is used
This commit is contained in:
parent
2c3e9fd5e7
commit
d6554b9acd
|
@ -36,6 +36,7 @@ import java.io.PrintWriter;
|
|||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
@ -596,11 +597,8 @@ public class MainWindowController {
|
|||
* @return true if so, false if not
|
||||
*/
|
||||
private boolean isSupportedFormat(FilmTabelDataType film) {
|
||||
if (film.getStreamUrl().endsWith(".mp4")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
String mimeType = URLConnection.guessContentTypeFromName(film.getStreamUrl());
|
||||
return mimeType != null && mimeType.contains("mp4");
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -997,9 +995,15 @@ public class MainWindowController {
|
|||
// try loading the omdbAPI key
|
||||
try {
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream("apiKeys.json");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
JsonObject apiKeys = Json.parse(reader).asObject();
|
||||
omdbAPIKey = apiKeys.getString("omdbAPIKey", "");
|
||||
if (in != null) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
JsonObject apiKeys = Json.parse(reader).asObject();
|
||||
omdbAPIKey = apiKeys.getString("omdbAPIKey", "");
|
||||
reader.close();
|
||||
in.close();
|
||||
} else {
|
||||
LOGGER.warn("Cloud not load apiKeys.json. No such file");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Cloud not load the omdbAPI key. Please contact the developer!", e);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.URLConnection;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -167,10 +168,9 @@ public class DBController {
|
|||
mainWindowController.addSourceToTable(path, mode); // add source to source-table
|
||||
if (mode.equals("local")) {
|
||||
for (File file : new File(path).listFiles()) {
|
||||
if (file.isFile()) {
|
||||
// get all files (films)
|
||||
if (file.isFile() && isVideoFile(file.getPath())) {
|
||||
filmsStreamURL.add(file.getPath());
|
||||
} else {
|
||||
} else if(file.isDirectory()) {
|
||||
// get all folders (series)
|
||||
for (File season : file.listFiles()) {
|
||||
if (season.isDirectory()) {
|
||||
|
@ -272,15 +272,14 @@ public class DBController {
|
|||
LOGGER.info("refreshing the Database ...");
|
||||
|
||||
// clean all ArraLists
|
||||
filmsdbAll.removeAll(filmsdbAll);
|
||||
filmsdbDir.removeAll(filmsdbDir);
|
||||
filmsdbStreamURL.removeAll(filmsdbStreamURL);
|
||||
filmsStreamURL.removeAll(filmsStreamURL);
|
||||
filmsdbAll.clear();
|
||||
filmsdbDir.clear();
|
||||
filmsdbStreamURL.clear();
|
||||
filmsStreamURL.clear();
|
||||
|
||||
loadSources(); // reload all sources
|
||||
loadDatabase(); // reload all films saved in the DB
|
||||
|
||||
|
||||
try {
|
||||
checkAddEntry();
|
||||
checkRemoveEntry();
|
||||
|
@ -306,8 +305,6 @@ public class DBController {
|
|||
|
||||
for (String entry : filmsdbStreamURL) {
|
||||
if (!filmsStreamURL.contains(entry)) {
|
||||
System.out.println(filmsdbStreamURL + "\n");
|
||||
System.out.println(filmsStreamURL);
|
||||
stmt.executeUpdate("delete from films where streamUrl = \"" + entry + "\"");
|
||||
connection.commit();
|
||||
LOGGER.info("removed \"" + entry + "\" from database");
|
||||
|
@ -685,4 +682,14 @@ public class DBController {
|
|||
return str.substring(0, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a file is a video
|
||||
* @param path the path to the file
|
||||
* @return true if the file is a video, else false
|
||||
*/
|
||||
public static boolean isVideoFile(String path) {
|
||||
String mimeType = URLConnection.guessContentTypeFromName(path);
|
||||
return mimeType != null && mimeType.startsWith("video");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -137,7 +137,8 @@ public class PlayerController {
|
|||
@Override
|
||||
public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) {
|
||||
currentTime = newValue.toMillis();
|
||||
int episode = Integer.parseInt(film.getEpisode());
|
||||
int episode = 0;
|
||||
if (film.getEpisode().length() != 0) episode = Integer.parseInt(film.getEpisode());
|
||||
|
||||
if ((duration - currentTime) < 10000 && episode != 0 && autoplay) {
|
||||
autoplay = false;
|
||||
|
|
Loading…
Reference in New Issue