Changes main package name and fixes files with weird names throwing errors
All checks were successful
KnarCraft/FFmpegConvert/master This commit looks good

Fixes conversion of files with a single quote or square brackets in the filename
Moves all files into the net.knarcraft.ffmpegconverter package
This commit is contained in:
Kristian Knarvik 2020-02-21 17:23:00 +01:00
parent c80193281d
commit 4e1cebd95d
13 changed files with 39 additions and 40 deletions

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: ffmpegconverter.Main
Main-Class: net.knarcraft.ffmpegconverter.Main

View File

@ -57,7 +57,7 @@
<url>https://git.knarcraft.net</url>
<layout>default</layout>
</repository>
<downloadUrl>https://git.knarcraft.net/KnarCraft/FFmpegConvert</downloadUrl>
<downloadUrl>https://jenkins.knarcraft.net/job/KnarCraft/job/FFmpegConvert/job/master/lastSuccessfulBuild/artifact/</downloadUrl>
</distributionManagement>
<build>
<plugins>
@ -71,7 +71,7 @@
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>ffmpegconverter.Main</mainClass>
<mainClass>net.knarcraft.ffmpegconverter.Main</mainClass>
</manifest>
</archive>
</configuration>

View File

@ -1,17 +1,16 @@
package ffmpegconverter;
package net.knarcraft.ffmpegconverter;
import ffmpegconverter.converter.AnimeConverter;
import ffmpegconverter.converter.AudioConverter;
import ffmpegconverter.converter.Converter;
import ffmpegconverter.converter.VideoConverter;
import net.knarcraft.ffmpegconverter.converter.AnimeConverter;
import net.knarcraft.ffmpegconverter.converter.AudioConverter;
import net.knarcraft.ffmpegconverter.converter.Converter;
import net.knarcraft.ffmpegconverter.converter.VideoConverter;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Predicate;
import static ffmpegconverter.Parser.tokenize;
import static net.knarcraft.ffmpegconverter.Parser.tokenize;
/**
* Converts a files or files in a folder to a web playable mp4.

View File

@ -1,10 +1,8 @@
package ffmpegconverter;
package net.knarcraft.ffmpegconverter;
import java.util.ArrayList;
import java.util.List;
import static ffmpegconverter.Main.listContains;
public class Parser {
/**
@ -26,7 +24,7 @@ public class Parser {
new Main.converterArgument("-outext", true, Main.converterArgumentValueType.SINGLE_VALUE)
};
String type = tokens.get(0).toLowerCase();
if (!listContains(types, s -> s.equals(type))) {
if (!Main.listContains(types, s -> s.equals(type))) {
throw new IllegalArgumentException("Unknown converter type chosen.");
}
if (tokens.size() < 2) {

View File

@ -1,12 +1,13 @@
package ffmpegconverter.converter;
package net.knarcraft.ffmpegconverter.converter;
import ffmpegconverter.streams.AudioStream;
import ffmpegconverter.streams.StreamObject;
import ffmpegconverter.streams.SubtitleStream;
import ffmpegconverter.streams.VideoStream;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class AnimeConverter extends Converter {
@ -112,8 +113,9 @@ public class AnimeConverter extends Converter {
command.add("-map");
command.add("0:" + videoStream.getAbsoluteIndex());
command.add("-vf");
command.add("subtitles='" + fileName.replace("'", "\'") + "':si=" +
subtitleStream.getRelativeIndex());
String safeFileName = fileName.replace("'", "\\\\\\'").replace("]", "\\]").replace("[", "\\[");
String subtitleCommand = String.format("subtitles=\"%s\"", safeFileName);
command.add(subtitleCommand);
} else {
command.add("-map");
command.add("0:" + videoStream.getAbsoluteIndex());

View File

@ -1,7 +1,7 @@
package ffmpegconverter.converter;
package net.knarcraft.ffmpegconverter.converter;
import ffmpegconverter.streams.AudioStream;
import ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import java.io.File;
import java.io.IOException;

View File

@ -1,9 +1,9 @@
package ffmpegconverter.converter;
package net.knarcraft.ffmpegconverter.converter;
import ffmpegconverter.streams.AudioStream;
import ffmpegconverter.streams.StreamObject;
import ffmpegconverter.streams.SubtitleStream;
import ffmpegconverter.streams.VideoStream;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.SubtitleStream;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;

View File

@ -1,8 +1,8 @@
package ffmpegconverter.converter;
package net.knarcraft.ffmpegconverter.converter;
import ffmpegconverter.streams.AudioStream;
import ffmpegconverter.streams.StreamObject;
import ffmpegconverter.streams.VideoStream;
import net.knarcraft.ffmpegconverter.streams.AudioStream;
import net.knarcraft.ffmpegconverter.streams.StreamObject;
import net.knarcraft.ffmpegconverter.streams.VideoStream;
import java.io.File;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package ffmpegconverter.streams;
package net.knarcraft.ffmpegconverter.streams;
public class AudioStream extends StreamObject {
private String language; //The audio language

View File

@ -1,4 +1,4 @@
package ffmpegconverter.streams;
package net.knarcraft.ffmpegconverter.streams;
/**
* An object representation of a stream in a media file

View File

@ -1,4 +1,4 @@
package ffmpegconverter.streams;
package net.knarcraft.ffmpegconverter.streams;
/**
* An object representation of a subtitle stream in a media file

View File

@ -1,4 +1,4 @@
package ffmpegconverter.streams;
package net.knarcraft.ffmpegconverter.streams;
/**
* An object representation of a video stream in a media file

View File

@ -1,6 +1,6 @@
package ffmpegconverter;
package net.knarcraft.ffmpegconverter;
import ffmpegconverter.converter.AnimeConverter;
import net.knarcraft.ffmpegconverter.converter.AnimeConverter;
import org.junit.Before;
import org.junit.Test;