Skip to content

Commit

Permalink
Merge pull request #230 from yermak/development
Browse files Browse the repository at this point in the history
New Version checker
  • Loading branch information
yermak authored Jan 30, 2021
2 parents 4a50986 + 7370b52 commit 02bdbdc
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 16 deletions.
1 change: 1 addition & 0 deletions build/windows/package.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REM build\windows\package.bat C:\Users\Yermak\Programs\OpenJDK\jdk-15.0.2 C:\Users\Yermak\Programs\JavaFX\javafx-jmods-15.0.1 1.0.0
ECHO ON
SET JAVA_HOME=%~1
ECHO %JAVA_HOME%
Expand Down
4 changes: 4 additions & 0 deletions external/x64/linux/path.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ffmpeg=../lib/app/external/ffmpeg
ffprobe=../lib/app/external/ffprobe
mp4art=../lib/app/external/mp4art
mp4info=../lib/app/external/mp4info
4 changes: 4 additions & 0 deletions external/x64/windows/path.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ffmpeg=app/external/ffmpeg.exe
ffprobe=app/external/ffprobe.exe
mp4art=app/external/mp4art.exe
mp4info=app/external/mp4info.exe
4 changes: 4 additions & 0 deletions path.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ffmpeg=external/x64/windows/ffmpeg.exe
ffprobe=external/x64/windows/ffprobe.exe
mp4art=external/x64/windows/mp4art.exe
mp4info=external/x64/windows/mp4info.exe
7 changes: 7 additions & 0 deletions src/main/deploy/assembly/linux-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
<include>*</include>
</includes>
</fileSet>
<fileSet>
<directory>external/x64/linux</directory>
<outputDirectory>app</outputDirectory>
<includes>
<include>path.properties</include>
</includes>
</fileSet>

</fileSets>
<dependencySets>
Expand Down
8 changes: 7 additions & 1 deletion src/main/deploy/assembly/windows-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
<includes>
<include>*.exe</include>
<include>*.dll</include>
<include>*.txt</include>
<include>*.md</include>
</includes>
</fileSet>
<fileSet>
<directory>external/x64/windows</directory>
<outputDirectory>app</outputDirectory>
<includes>
<include>path.properties</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
Expand Down
1 change: 0 additions & 1 deletion src/main/deploy/assembly/windows-nodeps-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<fileSet>
<includes>
<include>README*</include>
<include>*.txt</include>
<include>*.ico</include>
</includes>
<outputDirectory>app</outputDirectory>
Expand Down
42 changes: 28 additions & 14 deletions src/main/java/uk/yermak/audiobookconverter/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import org.stringtemplate.v4.*;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.text.DecimalFormat;
import java.time.Duration;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

Expand All @@ -23,6 +25,7 @@
*/
public class Utils {
final static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final Properties PATH = new Properties();

public static String getTmp(long jobId, long fileId, String extension) {
return new File(System.getProperty("java.io.tmpdir"), "~ABC_" + Version.getVersionString() + "_" + jobId + "_" + fileId + "." + extension).getAbsolutePath();
Expand Down Expand Up @@ -198,26 +201,37 @@ public static boolean isLinux() {
return System.getProperty("os.name").contains("Linux");
}

public static boolean isMac() {
return System.getProperty("os.name").contains("Mac");
}
public final static String FFMPEG = getPath("ffmpeg");

private static boolean isSupported() {
return isWindows() || isLinux();
}
public static final String MP4ART = getPath("mp4art");

public final static String FFMPEG = isSupported() ? new File(getFFMpegPath() + "/ffmpeg" + (isWindows() ? ".exe" : "")).getAbsolutePath() : "ffmpeg";
public static final String MP4INFO = getPath("mp4info");

private static String getFFMpegPath() {
if (System.getenv("FFMPEG") != null) return System.getenv("FFMPEG");
return (isWindows() ? "" : "../lib/") + "app/external";
}
public static final String FFPROBE = getPath("ffprobe");

public static final String MP4ART = isSupported() ? new File(getFFMpegPath() + "/mp4art" + (isWindows() ? ".exe" : "")).getAbsolutePath() : "mp4art";
private static String getPath(String binary) {
String property = loadAppProperties().getProperty(binary);
if (property != null) {
return property;
}
return binary + (isWindows() ? ".exe" : "");

public static final String MP4INFO = isSupported() ? new File(getFFMpegPath() + "/mp4info" + (isWindows() ? ".exe" : "")).getAbsolutePath() : "mp4info";
}

public static final String FFPROBE = isSupported() ? new File(getFFMpegPath() + "/ffprobe" + (isWindows() ? ".exe" : "")).getAbsolutePath() : "ffprobe";
private static synchronized Properties loadAppProperties() {
if (PATH.isEmpty()) {
File file = new File((isLinux()) ? "../lib/app/path.properties" : "path.properties");

if (file.exists()) {
try (FileInputStream in = new FileInputStream(file)) {
PATH.load(in);
} catch (IOException e) {
logger.error("Error during loading properties", e);
}
}
}
return PATH;
}


private static class DurationRender implements AttributeRenderer<Duration> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static void initAppHome() {
private static final ConversionContext context = new ConversionContext();

public static void main(String[] args) {
//GitHub certificate issue
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");

//-Dprism.allowhidpi=false
//below does not work
// System.setProperty("prism.allowhidpi", "false");
Expand Down

0 comments on commit 02bdbdc

Please sign in to comment.