Adds handling of external subtitles for anime
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

This commit is contained in:
2020-04-11 00:58:12 +02:00
parent 3335d70930
commit 405c94789b
3 changed files with 61 additions and 39 deletions

View File

@ -452,7 +452,7 @@ public abstract class Converter {
* @param input <p>The text to print.</p>
* @throws IOException <p>If a write is not possible.</p>
*/
static void print(String input) throws IOException {
private static void print(String input) throws IOException {
if (!input.equals("")) {
writer.write(input);
writer.flush();
@ -479,4 +479,37 @@ public abstract class Converter {
writer.newLine();
writer.flush();
}
/**
* Checks whether there exists an external image subtitle with the same filename as the file
* @param directory <p>The directory containing the file.</p>
* @param file <p>The file to be converted.</p>
* @return <p>The extension of the subtitle or empty if no subtitle was found.</p>
*/
String hasExternalImageSubtitle(String directory, String file) {
String path = stripExtension(file);
for (String subtitleExtension : new String[] {".idx", ".sub"}) {
if (new File(directory + File.separator + path + subtitleExtension).exists()) {
return path + subtitleExtension;
}
}
return "";
}
/**
* Checks whether there exists an external subtitle with the same filename as the file
* @param directory <p>The directory containing the file.</p>
* @param file <p>The file to be converted.</p>
* @return <p>The extension of the subtitle or empty if no subtitle was found.</p>
*/
String hasExternalSubtitle(String directory, String file) {
String path = stripExtension(file);
for (String subtitleExtension : new String[] {".srt", ".ass"}) {
System.out.println(directory + File.separator + path + subtitleExtension);
if (new File(directory + File.separator + path + subtitleExtension).exists()) {
return path + subtitleExtension;
}
}
return "";
}
}