diff --git a/pom.xml b/pom.xml
index 7920727..811c854 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
The configuration handler
+ */ + @NotNull + public static ConfigHandler getConfigHandler() { + return configHandler; + } + + /** + * Gets whether debug mode is enabled + * + * @returnTrue if debug mode is enabled
+ */ + public static boolean isDebugEnabled() { + return debug; + } + /** * Asks the user which converter they want, and assigns a converter instance to the converter variable */ + @Nullable private static Converter loadConverter() { int choice = getChoice(""" Which converter do you want do use? @@ -101,7 +132,7 @@ class Main { * @param recursionStepsThe depth to recurse if a folder is given.
* @throws IOExceptionIf conversion or writing fails.
*/ - private static void convertAllFiles(File fileOrFolder, int recursionSteps) throws IOException { + private static void convertAllFiles(@NotNull File fileOrFolder, int recursionSteps) throws IOException { if (fileOrFolder.isDirectory()) { File[] files = FileUtil.listFilesRecursive(fileOrFolder, converter.getValidFormats(), recursionSteps); if (files != null && files.length > 0) { @@ -113,7 +144,7 @@ class Main { } } else if (fileOrFolder.exists()) { String path = fileOrFolder.getPath(); - if (Arrays.stream(converter.getValidFormats()).anyMatch((format) -> format.equalsIgnoreCase( + if (converter.getValidFormats().stream().anyMatch((format) -> format.equalsIgnoreCase( path.substring(path.lastIndexOf('.') + 1)))) { converter.convert(fileOrFolder); } else { @@ -130,6 +161,7 @@ class Main { * * @returnThe initialized downscale converter
*/ + @Nullable private static Converter generateDownScaleConverter() { OutputUtil.println("(New width e.x. 1920) (New height e.x. 1080)\nYour input: "); ListThe initialized transcoder
*/ + @Nullable private static Converter generateMKVToMP4Transcoder() { OutputUtil.println("[Audio stream index 0-n] [Subtitle stream index 0-n] [Video stream index 0-n]\nYour input: "); ListThe initialized anime converter
*/ + @Nullable private static Converter generateAnimeConverter() { OutputUtil.println("[Audio languages jpn,eng,ger,fre] [Subtitle languages eng,ger,fre] [Minimal subtitle " + "preference REQUIRE/PREFER/NO_PREFERENCE/AVOID/REJECT] [Forced audio index 0-n] " + @@ -224,6 +258,7 @@ class Main { * * @returnThe initialized anime converter
*/ + @Nullable private static Converter generateWebAnimeConverter() { OutputUtil.println("[Audio languages jpn,eng,ger,fre] [Subtitle languages eng,ger,fre] [Convert to stereo if " + "necessary true/false] [Prevent signs&songs subtitles true/false] [Forced audio index 0-n] " + @@ -274,6 +309,7 @@ class Main { * @param maxThe number of tokens expected.
* @returnA list of tokens.
*/ + @NotNull private static ListThe prompt shown to the user.
* @returnThe non-empty choice given by the user.
*/ - private static String getChoice(String prompt) { + @NotNull + private static String getChoice(@NotNull String prompt) { OutputUtil.println(prompt); String choice = ""; while (choice.isEmpty()) { @@ -307,7 +344,7 @@ class Main { * @param max The maximum allowed value * @return The value given by the user */ - private static int getChoice(String prompt, int min, int max) { + private static int getChoice(@NotNull String prompt, int min, int max) { OutputUtil.println(prompt); int choice = Integer.MIN_VALUE; do { diff --git a/src/main/java/net/knarcraft/ffmpegconverter/config/ConfigHandler.java b/src/main/java/net/knarcraft/ffmpegconverter/config/ConfigHandler.java new file mode 100644 index 0000000..0f23de8 --- /dev/null +++ b/src/main/java/net/knarcraft/ffmpegconverter/config/ConfigHandler.java @@ -0,0 +1,92 @@ +package net.knarcraft.ffmpegconverter.config; + +import net.knarcraft.ffmpegconverter.utility.FileHelper; +import net.knarcraft.ffmpegconverter.utility.OutputUtil; +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; +import org.apache.commons.configuration2.builder.fluent.Configurations; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.jetbrains.annotations.NotNull; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.util.Map; + +/** + * A handler for dealing with configurations + */ +public class ConfigHandler { + + private final File configFolder = new File("conf").getAbsoluteFile(); + private final Configurations configurations = new Configurations(); + private final File settingsFile = new File(configFolder, "config.properties"); + private FileBasedConfigurationBuilderA writable properties configuration
+ */ + @NotNull + public PropertiesConfiguration getWritableConfiguration() { + try { + return builder.getConfiguration(); + } catch (ConfigurationException e) { + throw new RuntimeException(e); + } + } + + /** + * Writes the writable configuration to disk + */ + public void writeConfiguration() { + OutputUtil.printDebug("Preparing to save config"); + if (!configFolder.exists() && !configFolder.mkdir()) { + throw new RuntimeException("Unable to create config folder. Make sure to run this .jar file from a " + + "writable directory!"); + } + try { + if (!settingsFile.exists() && !settingsFile.createNewFile()) { + OutputUtil.println("Failed to create configuration file."); + } + } catch (IOException e) { + OutputUtil.println("Failed to create configuration file."); + } + try { + builder.save(); + } catch (ConfigurationException e) { + throw new RuntimeException(e); + } + OutputUtil.printDebug("Saved available hardware encoder handler"); + } + + /** + * Loads the saved configuration file + * + * @returnThe loaded configuration
+ */ + @NotNull + public Configuration load() throws IOException { + Configuration configuration; + if (!settingsFile.exists()) { + configuration = new PropertiesConfiguration(); + BufferedReader reader = FileHelper.getBufferedReaderForInternalFile("/conf/config.properties"); + MapThe failed ffmpeg command
* @param fileThe file that was to be converted
* @param newPathThe path of the output file
- * @throws IOExceptionIf unable to produce output
- * @throws ConfigurationExceptionIf unable
+ * @throws IOExceptionIf unable to produce output
*/ private void handleError(@NotNull FFMpegCommand ffMpegCommand, @NotNull File file, - @NotNull String newPath) throws IOException, ConfigurationException { + @NotNull String newPath) throws IOException { File outputFile = new File(newPath); if (outputFile.exists() && !outputFile.delete()) { OutputUtil.println("Failed to remove failed output file. Please remove it manually"); @@ -118,23 +115,24 @@ public abstract class AbstractConverter implements Converter { * * @returnAvailable hardware encoding methods
*/ + @NotNull protected ListPath/command to ffmpeg.
* @param newExtensionThe extension of the new file.
*/ - public AudioConverter(String ffprobePath, String ffmpegPath, String newExtension) { + public AudioConverter(@NotNull String ffprobePath, @NotNull String ffmpegPath, @NotNull String newExtension) { super(newExtension); this.ffprobePath = ffprobePath; this.ffmpegPath = ffmpegPath; } @Override + @Nullable public FFMpegCommand generateConversionCommand(@NotNull String executable, @NotNull StreamProbeResult probeResult, @NotNull String outFile) { FFMpegCommand command = FFMpegHelper.getFFMpegGeneralFileCommand(executable, probeResult.parsedFiles()); @@ -50,7 +52,8 @@ public class AudioConverter extends AbstractConverter { } @Override - public String[] getValidFormats() { + @NotNull + public ListA list of valid input formats
*/ @NotNull - String[] getValidFormats(); + ListThe output file
* @returnA list of commands
*/ + @Nullable FFMpegCommand generateConversionCommand(@NotNull String executable, @NotNull StreamProbeResult probeResult, @NotNull String outFile); diff --git a/src/main/java/net/knarcraft/ffmpegconverter/converter/DownScaleConverter.java b/src/main/java/net/knarcraft/ffmpegconverter/converter/DownScaleConverter.java index 9b066d6..5e79c0e 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/converter/DownScaleConverter.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/converter/DownScaleConverter.java @@ -16,6 +16,7 @@ import net.knarcraft.ffmpegconverter.streams.StreamObject; import net.knarcraft.ffmpegconverter.streams.VideoStream; import net.knarcraft.ffmpegconverter.utility.FFMpegHelper; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -36,7 +37,7 @@ public class DownScaleConverter extends AbstractConverter { * @param newWidthThe new width of the video
* @param newHeightThe new height of the video
*/ - public DownScaleConverter(String ffprobePath, String ffmpegPath, int newWidth, int newHeight) { + public DownScaleConverter(@NotNull String ffprobePath, @NotNull String ffmpegPath, int newWidth, int newHeight) { super(null); this.ffprobePath = ffprobePath; this.ffmpegPath = ffmpegPath; @@ -45,6 +46,7 @@ public class DownScaleConverter extends AbstractConverter { } @Override + @Nullable public FFMpegCommand generateConversionCommand(@NotNull String executable, @NotNull StreamProbeResult probeResult, @NotNull String outFile) { ListIf the configuration file cannot be saved
+ * Saves settings for this available hardware encoder handler */ - public void save() throws ConfigurationException { - OutputUtil.printDebug("Preparing to save config"); - if (!configFolder.exists() && !configFolder.mkdir()) { - throw new RuntimeException("Unable to create config folder. Make sure to run this .jar file from a " + - "writable directory!"); - } - File settingsFile = new File(configFolder, "config.properties"); - try { - if (!settingsFile.exists() && !settingsFile.createNewFile()) { - OutputUtil.println("Failed to create configuration file."); - } - } catch (IOException e) { - OutputUtil.println("Failed to create configuration file."); - } - - FileBasedConfigurationBuilderThe loaded available hardware encoder handler, or a new one if no data has been saved
- * @throws ConfigurationExceptionIf the configuration file cannot be loaded
*/ - public static AvailableHardwareEncoderHandler load() throws ConfigurationException { - File settingsFile = new File(configFolder, "config.properties"); - if (!settingsFile.exists()) { - return new AvailableHardwareEncoderHandler(new ArrayList<>()); + @NotNull + public static AvailableHardwareEncoderHandler load() { + Configuration configuration; + try { + configuration = configHandler.load(); + } catch (IOException e) { + throw new RuntimeException(e); } - Configuration configuration = configurations.properties(settingsFile); ListWhether the argument must be followed by a valid value.
* @param valueTypeThe type of value the argument requires.
*/ - public ConverterArgument(String name, char shorthand, boolean valueRequired, ConverterArgumentValueType valueType) { + public ConverterArgument(@NotNull String name, char shorthand, boolean valueRequired, + @NotNull ConverterArgumentValueType valueType) { this.name = name; this.shorthand = shorthand; this.valueRequired = valueRequired; @@ -60,7 +62,7 @@ public class ConverterArgument { * @param valueThe value to test.
* @returnTrue if the argument is valid. False otherwise.
*/ - public boolean testArgumentValue(String value) { + public boolean testArgumentValue(@NotNull String value) { if (value.isEmpty()) { return !valueRequired; } diff --git a/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java b/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java index abf94f5..f6f62a9 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/streams/AbstractStream.java @@ -36,7 +36,8 @@ public abstract class AbstractStream implements StreamObject { } @Override - public @NotNull String getCodecName() { + @NotNull + public String getCodecName() { return this.codecName; } @@ -51,7 +52,8 @@ public abstract class AbstractStream implements StreamObject { } @Override - public @NotNull String getLanguage() { + @NotNull + public String getLanguage() { return this.language; } diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java index 6b44fd1..426bde6 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/FFMpegHelper.java @@ -27,7 +27,6 @@ import java.util.Map; public final class FFMpegHelper { private static final String PROBE_SPLIT_CHARACTER = "øæåÆØå"; - private static String[] subtitleFormats = null; private FFMpegHelper() { @@ -70,14 +69,16 @@ public final class FFMpegHelper { /** * Gets streams from a file * - * @param ffprobePathThe path/command to ffprobe.
- * @param fileThe file to probe.
- * @returnA list of StreamObjects.
- * @throws IOExceptionIf the process can't be readProcess.
+ * @param ffprobePathThe path/command to ffprobe
+ * @param fileThe file to probe
+ * @param subtitleFormatsThe extensions to accept for external subtitles
+ * @returnA list of StreamObjects
+ * @throws IOExceptionIf the process can't be readProcess
*/ @NotNull - public static StreamProbeResult probeFile(@NotNull String ffprobePath, @NotNull File file) throws IOException { - return parseStreams(ffprobePath, probeForStreams(ffprobePath, file), file); + public static StreamProbeResult probeFile(@NotNull String ffprobePath, @NotNull File file, + @NotNull ListThe filename to escape.
* @returnA filename with known special characters escaped.
*/ - public static String escapeSpecialCharactersInFileName(String fileName) { + @NotNull + public static String escapeSpecialCharactersInFileName(@NotNull String fileName) { return fileName.replaceAll("\\\\", "\\\\\\\\\\\\\\\\") .replaceAll("'", "'\\\\\\\\\\\\\''") .replaceAll("%", "\\\\\\\\\\\\%") @@ -260,7 +262,8 @@ public final class FFMpegHelper { * @returnA list of streams.
* @throws IOExceptionIf something goes wrong while probing.
*/ - private static ListA list of all streams for the current file.
- * @param fileThe file currently being converted.
+ * @param ffprobePathThe path to the ffprobe executable
+ * @param streamsA list of all streams for the current file.
+ * @param fileThe file currently being converted.
+ * @param subtitleFormatsThe extensions to accept for external subtitles
* @returnA list of StreamObjects.
*/ @NotNull private static StreamProbeResult parseStreams(@NotNull String ffprobePath, @NotNull ListThe path/command to ffprobe
- * @param directoryThe directory containing the file
- * @param convertingFileThe first/main file to be converted
+ * @param streamProbeResultThe stream probe result to append to
+ * @param ffprobePathThe path/command to ffprobe
+ * @param directoryThe directory containing the file
+ * @param convertingFileThe first/main file to be converted
+ * @param subtitleFormatsThe extensions to accept for external subtitles
*/ private static void getExternalSubtitles(@NotNull StreamProbeResult streamProbeResult, @NotNull String ffprobePath, @NotNull File directory, - @NotNull String convertingFile) throws IOException { + @NotNull String convertingFile, @NotNull ListThe output from the readProcess.
* @throws IOExceptionOn reader failure.
*/ - private static String readProcess(BufferedReader reader, String spacer) throws IOException { + @NotNull + private static String readProcess(@NotNull BufferedReader reader, @NotNull String spacer) throws IOException { String line; StringBuilder text = new StringBuilder(); while (reader.ready() && (line = reader.readLine()) != null && !line.isEmpty() && !line.equals("\n")) { @@ -398,6 +403,7 @@ public final class FFMpegHelper { * @returnThe available hardware acceleration methods
* @throws IOExceptionIf the process fails
*/ + @NotNull public static ListThe name of the file to get a buffered reader for (start with a '/'). The file should reside in + * the resources directory.
+ * @returnA buffered read for reading the file
+ * @throws FileNotFoundExceptionIf unable to get an input stream for the given file
+ */ + @NotNull + public static BufferedReader getBufferedReaderForInternalFile(@NotNull String file) throws FileNotFoundException { + InputStream inputStream = getInputStreamForInternalFile(file); + if (inputStream == null) { + throw new FileNotFoundException("Unable to read the given file"); + } + return getBufferedReaderFromInputStream(inputStream); + } + + /** + * Gets an input stream from a string pointing to an internal file + * + *This is used for getting an input stream for reading a file contained within the compiled .jar file. The file + * should be in the resources directory, and the file path should start with a forward slash ("/") character.
+ * + * @param fileThe file to read
+ * @returnAn input stream for the file
+ */ + @Nullable + public static InputStream getInputStreamForInternalFile(@NotNull String file) { + return FileHelper.class.getResourceAsStream(file); + } + + /** + * Gets a buffered reader from a string pointing to a file + * + * @param fileThe file to read
+ * @returnA buffered reader reading the file
+ * @throws FileNotFoundExceptionIf the given file does not exist
+ */ + @NotNull + + public static BufferedReader getBufferedReaderFromString(@NotNull String file) throws FileNotFoundException { + FileInputStream fileInputStream = new FileInputStream(file); + return getBufferedReaderFromInputStream(fileInputStream); + } + + /** + * Gets a buffered reader given an input stream + * + * @param inputStreamThe input stream to read
+ * @returnA buffered reader reading the input stream
+ */ + @NotNull + public static BufferedReader getBufferedReaderFromInputStream(@NotNull InputStream inputStream) { + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + return new BufferedReader(inputStreamReader); + } + + /** + * Gets a buffered writer from a string pointing to a file + * + * @param fileThe file to write to
+ * @returnA buffered writer writing to the file
+ * @throws FileNotFoundExceptionIf the file does not exist
+ */ + @NotNull + public static BufferedWriter getBufferedWriterFromString(@NotNull String file) throws FileNotFoundException { + FileOutputStream fileOutputStream = new FileOutputStream(file); + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8); + return new BufferedWriter(outputStreamWriter); + } + + /** + * Reads key/value pairs from a buffered reader + * + * @param bufferedReaderThe buffered reader to read
+ * @param separatorThe separator separating a key from a value
+ * @returnA map containing the read pairs
+ * @throws IOExceptionIf unable to read from the stream
+ */ + @NotNull + public static MapThe buffered reader to read
+ * @returnA list of the read strings
+ * @throws IOExceptionIf unable to read from the stream
+ */ + @NotNull + public static ListThe string to remove the BOM from
+ * @returnA string guaranteed without a BOM
+ */ + private static @NotNull String removeUTF8BOM(@NotNull String string) { + String UTF8_BOM = "\uFEFF"; + if (string.startsWith(UTF8_BOM)) { + string = string.substring(1); + } + return string; + } + +} diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java index f8d1c13..556ef4d 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/FileUtil.java @@ -1,10 +1,10 @@ package net.knarcraft.ffmpegconverter.utility; -import java.io.BufferedReader; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.util.List; /** * A class which helps with file handling @@ -23,7 +23,8 @@ public final class FileUtil { * @param outExtensionThe extension of the output file.
* @returnA file name with the new extension and without any collisions.
*/ - public static String getNonCollidingPath(File folder, File file, String outExtension) { + @NotNull + public static String getNonCollidingPath(@NotNull File folder, @NotNull File file, @NotNull String outExtension) { return FileUtil.getNonCollidingFilename(folder.getAbsolutePath() + File.separator + FileUtil.stripExtension(file.getName()) + "." + outExtension, outExtension); } @@ -35,7 +36,8 @@ public final class FileUtil { * @param maxRecursionsMaximum number of recursions
* @return A list of files */ - public static File[] listFilesRecursive(File folder, String[] extensions, int maxRecursions) { + @Nullable + public static File[] listFilesRecursive(@NotNull File folder, @NotNull ListThe file must contain the number of lines to read in the first line.
- * - * @param fileNameThe file to read.
- * @returnA string list where each element is one line of the file.
- * @throws IOExceptionIf the file cannot be read.
- */ - public static String[] readFileLines(String fileName) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(getResourceAsStream(fileName))); - int numberOfLines = Integer.parseInt(reader.readLine()); - String[] lines = new String[numberOfLines]; - for (int i = 0; i < lines.length; i++) { - lines[i] = reader.readLine(); - } - return lines; - } - - /** - * Gets a resource as an InputStream - * - * @param resourceNameThe name of the resource you want to read.
- * @returnAn input stream which can be used to access the resource.
- */ - private static InputStream getResourceAsStream(String resourceName) { - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - return classloader.getResourceAsStream(resourceName); - } - /** * Adds parentheses with an integer if the output file already exists * @@ -105,7 +78,8 @@ public final class FileUtil { * @param extensionThe extension of the target file.
* @returnA filename guaranteed not to collide with other files.
*/ - private static String getNonCollidingFilename(String targetPath, String extension) { + @NotNull + private static String getNonCollidingFilename(@NotNull String targetPath, @NotNull String extension) { File newFile = new File(targetPath); String fileName = stripExtension(targetPath).replaceAll("\\([0-9]+\\)$", ""); int i = 1; @@ -121,7 +95,8 @@ public final class FileUtil { * @param fileThe filename to check
* @returnThe file's extension
*/ - public static String getExtension(String file) { + @NotNull + public static String getExtension(@NotNull String file) { if (file.contains(".")) { return file.substring(file.lastIndexOf('.') + 1); } else { @@ -135,7 +110,8 @@ public final class FileUtil { * @param fileA filename.
* @returnA filename without its extension.
*/ - public static String stripExtension(String file) { + @NotNull + public static String stripExtension(@NotNull String file) { return file.substring(0, file.lastIndexOf('.')); } diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java index f8cba56..8854270 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/ListUtil.java @@ -1,5 +1,7 @@ package net.knarcraft.ffmpegconverter.utility; +import org.jetbrains.annotations.NotNull; + import java.lang.reflect.Array; import java.util.ArrayList; import java.util.List; @@ -22,7 +24,8 @@ public final class ListUtil { * @paramThe type of the two lists.
* @returnA new array containing all elements from the two arrays.
*/ - staticThe type of the list.
* @returnA new list containing all matching elements.
*/ - staticA string which may include commas.
* @returnA string list.
*/ - public static String[] getListFromCommaSeparatedString(String string) { + @NotNull + public static String[] getListFromCommaSeparatedString(@NotNull String string) { String[] result; if (string.contains(",")) { result = string.split(","); diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java index 5964e85..b142229 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/OutputUtil.java @@ -1,5 +1,7 @@ package net.knarcraft.ffmpegconverter.utility; +import org.jetbrains.annotations.NotNull; + import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; @@ -30,7 +32,7 @@ public final class OutputUtil { * * @param inputThe text to print.
*/ - public static void println(String input) { + public static void println(@NotNull String input) { if (!input.isEmpty()) { try { writer.write(input); @@ -46,7 +48,7 @@ public final class OutputUtil { * * @param inputThe string to print.
*/ - public static void print(String input) { + public static void print(@NotNull String input) { try { writer.write(input); writer.flush(); @@ -82,7 +84,7 @@ public final class OutputUtil { * * @param messageThe debug message to show.
*/ - public static void printDebug(String message) { + public static void printDebug(@NotNull String message) { if (debug) { println(message); } diff --git a/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java b/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java index a361299..88f73e4 100644 --- a/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java +++ b/src/main/java/net/knarcraft/ffmpegconverter/utility/Parser.java @@ -1,6 +1,7 @@ package net.knarcraft.ffmpegconverter.utility; import net.knarcraft.ffmpegconverter.parser.ConverterArgument; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.HashMap; @@ -23,7 +24,8 @@ public final class Parser { * @param validArgumentsAll arguments which are considered valid.
* @returnA map with all parsed arguments.
*/ - static MapA list of arguments which are considered valid.
* @returnA map with all parsed arguments.
*/ - private static MapA list of all the valid arguments in existence.
* @param parsedArgumentsThe map to store the parsed argument to.
*/ - private static void parseArgument(ListThe found argument to store.
* @param parsedArgumentsThe map to store parsed arguments to.
*/ - private static void storeArgumentValue(ListA string.
* @returnA list of tokens.
*/ - public static ListThe index of the read character.
* @param tokensThe list of processed tokens.
*/ - private static void tokenizeNormalCharacter(StringBuilder currentToken, char character, int inputLength, int index, - ListThe list of processed tokens.
* @returnTrue if the token is finished.
*/ - private static boolean tokenizeSpace(boolean startedQuote, StringBuilder currentToken, ListThe string builder to check.
* @returnTrue if the string builder is non empty.
*/ - private static boolean isNotEmpty(StringBuilder builder) { + private static boolean isNotEmpty(@NotNull StringBuilder builder) { return !builder.toString().trim().isEmpty(); } diff --git a/src/main/resources/audio_formats.txt b/src/main/resources/audio_formats.txt index 4279515..badc645 100644 --- a/src/main/resources/audio_formats.txt +++ b/src/main/resources/audio_formats.txt @@ -1,4 +1,3 @@ -39 3gp aa aac diff --git a/src/main/resources/conf/config.properties b/src/main/resources/conf/config.properties new file mode 100644 index 0000000..aab92eb --- /dev/null +++ b/src/main/resources/conf/config.properties @@ -0,0 +1 @@ +debug=false \ No newline at end of file diff --git a/src/main/resources/subtitle_formats.txt b/src/main/resources/subtitle_formats.txt index 4dfd314..54de0e5 100644 --- a/src/main/resources/subtitle_formats.txt +++ b/src/main/resources/subtitle_formats.txt @@ -1,4 +1,3 @@ -5 idx sub srt diff --git a/src/main/resources/video_formats.txt b/src/main/resources/video_formats.txt index 4dc9a08..074e447 100644 --- a/src/main/resources/video_formats.txt +++ b/src/main/resources/video_formats.txt @@ -1,4 +1,3 @@ -31 avi mpg mpeg diff --git a/src/test/java/net/knarcraft/ffmpegconverter/utility/ListUtilTest.java b/src/test/java/net/knarcraft/ffmpegconverter/utility/ListUtilTest.java index df97a1b..14c684d 100644 --- a/src/test/java/net/knarcraft/ffmpegconverter/utility/ListUtilTest.java +++ b/src/test/java/net/knarcraft/ffmpegconverter/utility/ListUtilTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertFalse; public class ListUtilTest { private static List