Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 6 initial release #362

Merged
merged 47 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
42cec03
Mac OS Build
yermak Oct 29, 2021
d041e26
Merge branch 'issues/312_m4b_optimisatin' into macos
yermak Dec 13, 2021
1e8adde
Merge branch 'feature/318_force_reencoding' into macos
yermak Dec 13, 2021
4148a0c
moved os dependand tools and Dev plugs into Environment
yermak Dec 13, 2021
4608538
Merge branch 'development' into macos
yermak Dec 20, 2021
d7a7259
merge fixes
yermak Dec 20, 2021
e3172b7
fixed macos/windows environment issues
yermak Dec 20, 2021
eef4f07
fixed macos/windows environment issues
yermak Dec 20, 2021
bd62c63
fixed macos/windows environment issues
yermak Dec 20, 2021
1b0ba8f
Merge pull request #341 from yermak/macos
yermak Dec 20, 2021
6e1fd64
fixed version hack
yermak Dec 20, 2021
fd5d7bc
fixed version hack
yermak Dec 20, 2021
fa6300c
clean-up
yermak Dec 20, 2021
7177de8
clean-up
yermak Dec 20, 2021
344c18a
Merge pull request #342 from yermak/clean-up
yermak Dec 20, 2021
fa13b0f
fixed potential image name clash in temp files
yermak Dec 22, 2021
f85a14d
Merge pull request #344 from yermak/issue/343_artwork_conflict
yermak Dec 22, 2021
9dc738d
Fixed random io bug on iOS while searching artwork on samba network d…
yermak Dec 23, 2021
3e003a5
Fixed combining Parts
yermak Dec 23, 2021
f03f61c
Fixed splitting chapters
yermak Dec 23, 2021
843e697
Merge pull request #346 from yermak/issue/345_split_combine
yermak Dec 23, 2021
16af7b6
added Xodus database instead of property file, Moved genres to database
yermak Dec 24, 2021
2b9b105
moved presets to database
yermak Dec 24, 2021
5e63bf1
propperties moved to database
yermak Dec 24, 2021
62ec7e2
renamed properties into settings
yermak Dec 24, 2021
e6f2923
fixed NPE in loading properties from settings db
yermak Dec 25, 2021
6249091
adding lazy reencoding option and fixing optimisation error
yermak Dec 27, 2021
49d81b2
adding lazy reencoding option and fixing optimisation error
yermak Dec 27, 2021
7e7ad8b
Merge pull request #348
yermak Dec 27, 2021
b705e98
Merge pull request #350 from yermak/features/206_avoid_reencoding
yermak Dec 27, 2021
24572e2
adding progress for artwork and optimisation, fixed force reencoding
yermak Dec 28, 2021
0923da5
Merge pull request #351 from yermak/features/332_progress_for_art_wor…
yermak Dec 28, 2021
25be3d3
fixed preset saving behaviour
yermak Dec 28, 2021
5d83963
fixed preset saving behaviour
yermak Dec 28, 2021
955fb44
fixed preset saving behaviour
yermak Dec 28, 2021
622a381
fixed preset saving behaviour
yermak Dec 28, 2021
97922cf
Merge pull request #354 from yermak/issue/347_app_settings
yermak Dec 28, 2021
c59aea2
fixed #269
yermak Dec 28, 2021
61a88d7
Merge pull request #355 from yermak/issues/269_subtracks_single_file
yermak Dec 28, 2021
82c62bf
packaging jdk for xodus
yermak Dec 28, 2021
9c30da0
Merge pull request #356
yermak Dec 28, 2021
3fb7ad5
division by zero fix
yermak Dec 28, 2021
3e04887
Merge pull request #357
yermak Dec 28, 2021
db10c17
fixed optimsation issue with jpg art added as binary data
yermak Dec 29, 2021
bac8f37
Merge pull request #360
yermak Dec 29, 2021
cd3f709
version bump
yermak Dec 29, 2021
0208959
Merge pull request #361
yermak Dec 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,27 @@
<version>1.4</version>
</dependency>


<!--
<dependency>
<groupId>com.apple</groupId>
<artifactId>javaextensions</artifactId>
<scope>>system</scope>
<systemPath>/Users/Yarick_Yermak/Projects/AudioBookConverter/lib/applejavaextensions-1.4.jar</systemPath>
<groupId>org.jetbrains.xodus</groupId>
<artifactId>xodus-openAPI</artifactId>
<version>1.3.232</version>
</dependency>
-->
<dependency>
<groupId>org.jetbrains.xodus</groupId>
<artifactId>xodus-environment</artifactId>
<version>1.3.232</version>
</dependency>
<dependency>
<groupId>org.jetbrains.xodus</groupId>
<artifactId>xodus-entity-store</artifactId>
<version>1.3.232</version>
</dependency>
<dependency>
<groupId>org.jetbrains.xodus</groupId>
<artifactId>xodus-vfs</artifactId>
<version>1.3.232</version>
</dependency>


<dependency>
<groupId>org.testng</groupId>
Expand Down
63 changes: 0 additions & 63 deletions src/main/java/uk/yermak/audiobookconverter/AppProperties.java

This file was deleted.

163 changes: 163 additions & 0 deletions src/main/java/uk/yermak/audiobookconverter/AppSetting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
package uk.yermak.audiobookconverter;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import jetbrains.exodus.ByteIterable;
import jetbrains.exodus.bindings.StringBinding;
import jetbrains.exodus.entitystore.Entity;
import jetbrains.exodus.entitystore.EntityIterable;
import jetbrains.exodus.entitystore.PersistentEntityStore;
import jetbrains.exodus.entitystore.PersistentEntityStores;
import jetbrains.exodus.env.*;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.*;
import java.util.stream.StreamSupport;

public class AppSetting {
final static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final File APP_DIR = new File(System.getProperty("APP_HOME"));
public static final String PRESET_ENTITY = "Preset";
public static final String PRESET_NAME = "name";
public static final String PRESET_FORMAT = "format";
public static final String PRESET_BITRATE = "bitrate";
public static final String PRESET_FREQUENCY = "frequency";
public static final String PRESET_CHANNELS = "channels";
public static final String PRESET_CUTOFF = "cutoff";
public static final String PRESET_CBR = "cbr";
public static final String PRESET_QUALITY = "quality";
public static final String GENRE_ENTITY = "Genre";
public static final String GENRE_TITLE = "title";
public static final String GENRE_CREATED = "created";
public static final String SETTINGS = "Settings";


public static String getProperty(String key) {
String result;
try (jetbrains.exodus.env.Environment env = Environments.newInstance(APP_DIR.getPath())) {
result = env.computeInReadonlyTransaction(txn -> {
final Store store = env.openStore(SETTINGS, StoreConfig.WITHOUT_DUPLICATES, txn);
ByteIterable entry = store.get(txn, StringBinding.stringToEntry(key));
if (entry!=null) {
return StringBinding.entryToString(entry);
} else {
return null;
}
});
}
return result;
}

public static synchronized void setProperty(String key, String value) {
try (jetbrains.exodus.env.Environment env = Environments.newInstance(APP_DIR.getPath())) {
env.executeInTransaction(txn -> {
final Store store = env.openStore(SETTINGS, StoreConfig.WITHOUT_DUPLICATES, txn);
store.put(txn, StringBinding.stringToEntry(key), StringBinding.stringToEntry(value));
});
}
}

public static void saveGenres(String genre) {
if (StringUtils.isNotEmpty(genre) & loadGenres().stream().noneMatch(s -> s.equals(genre))) {
try (PersistentEntityStore entityStore = PersistentEntityStores.newInstance(APP_DIR.getPath())) {
entityStore.executeInTransaction(txn -> {
final Entity genreEntity = txn.newEntity(GENRE_ENTITY);
genreEntity.setProperty(GENRE_TITLE, genre);
genreEntity.setProperty(GENRE_CREATED, System.currentTimeMillis());
});
}
}
}

public static ObservableList<String> loadGenres() {
ObservableList<String> genres;
try (PersistentEntityStore entityStore = PersistentEntityStores.newInstance(APP_DIR.getPath())) {
genres = entityStore.computeInReadonlyTransaction(txn -> {
ObservableList<String> list = FXCollections.observableArrayList();
StreamSupport.stream(txn.sort(GENRE_ENTITY, GENRE_TITLE, true).spliterator(), false).forEach(g -> list.add((String) g.getProperty(GENRE_TITLE)));
return list;
});
}
return genres;
}

public static void removeGenre(String genre) {
try (PersistentEntityStore entityStore = PersistentEntityStores.newInstance(APP_DIR.getPath())) {
entityStore.executeInTransaction(txn -> {
EntityIterable entities = txn.find(GENRE_ENTITY, GENRE_TITLE, genre);
for (Entity entity : entities) {
entity.delete();
}
});
}
}

public static List<Preset> loadPresets() {
List<Preset> presets;
try (PersistentEntityStore entityStore = PersistentEntityStores.newInstance(APP_DIR.getPath())) {
presets = entityStore.computeInReadonlyTransaction(txn -> {
List<Preset> list = new ArrayList<>();
EntityIterable all = txn.getAll(PRESET_ENTITY);
for (Entity entity : all) {
Preset preset = bindPreset(entity);
list.add(preset);
}
return list;
});
}
return presets;
}

@NotNull
private static Preset bindPreset(Entity entity) {
String name = (String) entity.getProperty(PRESET_NAME);
String format = (String) entity.getProperty(PRESET_FORMAT);
Integer bitrate = (Integer) entity.getProperty(PRESET_BITRATE);
Integer frequency = (Integer) entity.getProperty(PRESET_FREQUENCY);
Integer channels = (Integer) entity.getProperty(PRESET_CHANNELS);
Integer cutoff = (Integer) entity.getProperty(PRESET_CUTOFF);
Boolean cbr = (Boolean) entity.getProperty(PRESET_CBR);
Integer quality = (Integer) entity.getProperty(PRESET_QUALITY);
Preset preset = new Preset(name, new OutputParameters(Format.instance(format), bitrate, frequency, channels, cutoff, cbr, quality));
return preset;
}

public static void savePreset(Preset preset) {
try (PersistentEntityStore entityStore = PersistentEntityStores.newInstance(APP_DIR.getPath())) {
entityStore.executeInTransaction(txn -> {
Entity entity;
EntityIterable entities = txn.find(PRESET_ENTITY, PRESET_NAME, preset.getName());
if (entities.isEmpty()) {
entity = txn.newEntity(PRESET_ENTITY);
} else {
entity = entities.getFirst();
}
entity.setProperty(PRESET_NAME, preset.getName());
entity.setProperty(PRESET_FORMAT, preset.getFormat().format);
entity.setProperty(PRESET_BITRATE, preset.getBitRate());
entity.setProperty(PRESET_FREQUENCY, preset.getFrequency());
entity.setProperty(PRESET_CHANNELS, preset.getChannels());
entity.setProperty(PRESET_CUTOFF, preset.getCutoff());
entity.setProperty(PRESET_CBR, preset.isCbr());
entity.setProperty(PRESET_QUALITY, preset.getVbrQuality());
});
}
}

public static Preset loadPreset(String presetName) {
Preset preset;
try (PersistentEntityStore entityStore = PersistentEntityStores.newInstance(APP_DIR.getPath())) {
preset = entityStore.computeInReadonlyTransaction(txn -> {
EntityIterable entities = txn.find(PRESET_ENTITY, PRESET_NAME, presetName);
if (entities.isEmpty()) return null;
return bindPreset(entities.getFirst());
});
}
return preset;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.apple.eio.FileManager;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
Expand All @@ -16,7 +15,6 @@
import org.controlsfx.control.Notifications;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.yermak.audiobookconverter.Version;
import uk.yermak.audiobookconverter.fx.ConversionContext;
import uk.yermak.audiobookconverter.fx.JfxEnv;

Expand Down Expand Up @@ -138,13 +136,13 @@ static class VersionChecker implements Runnable {
@Override
public void run() {
try {
String platform = Environment.current.loadAppProperties().getProperty("platform");
String platform = Platform.current.loadAppProperties().getProperty("platform");
if (platform == null) platform = "version";
if ("steam".equals(platform)) return;
String version = readStringFromURL("https://raw.githubusercontent.com/yermak/AudioBookConverter/version/" + platform + ".txt");
if (!Version.getVersionString().equals(StringUtils.trim(version))) {
logger.info("New version found: {}", version);
Platform.runLater(() -> {
javafx.application.Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("New Version Available!");
String path = FileManager.getPathToApplicationBundle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static long parseDuration(String info) {
public static void mp4v2UpdateDuration(MediaInfo mediaInfo, String outputFileName) throws IOException {
Process process = null;
try {
ProcessBuilder infoProcessBuilder = new ProcessBuilder(Environment.MP4INFO, outputFileName);
ProcessBuilder infoProcessBuilder = new ProcessBuilder(Platform.MP4INFO, outputFileName);
process = infoProcessBuilder.start();
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamCopier.copy(process.getInputStream(), out);
Expand All @@ -67,7 +67,7 @@ public static void mp4v2UpdateDuration(MediaInfo mediaInfo, String outputFileNam

public static void ffMpegUpdateDuration(MediaInfo mediaInfo, String outputFileName) throws IOException {
final Set<String> AUDIO_CODECS = ImmutableSet.of("mp3", "aac", "wmav2", "flac", "alac", "vorbis", "opus");
FFprobe ffprobe = new FFprobe(Environment.FFPROBE);
FFprobe ffprobe = new FFprobe(Platform.FFPROBE);
FFmpegProbeResult probe = ffprobe.probe(outputFileName);
List<FFmpegStream> streams = probe.getStreams();
for (FFmpegStream stream : streams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public FFMediaLoader(List<String> files, ConversionGroup conversionGroup) {
public List<MediaInfo> loadMediaInfo() {
logger.info("Loading media info");
try {
FFprobe ffprobe = new FFprobe(Environment.FFPROBE);
FFprobe ffprobe = new FFprobe(Platform.FFPROBE);
List<MediaInfo> media = new ArrayList<>();
for (String fileName : fileNames) {
Future<MediaInfo> futureLoad = mediaExecutor.submit(new MediaInfoCallable(ffprobe, fileName, conversionGroup));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void optimize() throws InterruptedException {
try {

String[] optimize = {
Environment.FFMPEG,
Platform.FFMPEG,
"-i", tempFile,
"-map", "0:v",
"-map", "0:a",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package uk.yermak.audiobookconverter;

import javafx.application.Platform;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.concurrent.Callable;
Expand All @@ -28,7 +26,7 @@ public ArtWork call() throws Exception {
if (conversionGroup.isOver() || conversionGroup.isStarted() || conversionGroup.isDetached())
throw new InterruptedException("ArtWork loading was interrupted");
String poster = Utils.getTmp(mediaInfo.getUID(), stream, format);
ProcessBuilder pictureProcessBuilder = new ProcessBuilder(Environment.FFMPEG,
ProcessBuilder pictureProcessBuilder = new ProcessBuilder(Platform.FFMPEG,
"-i", mediaInfo.getFileName(),
"-map", "0:" + stream,
"-y",
Expand All @@ -50,7 +48,7 @@ public ArtWork call() throws Exception {
FFMediaLoader.logger.error("ArtWork Error: {}", err);

ArtWorkBean artWorkBean = new ArtWorkBean(poster);
Platform.runLater(() -> {
javafx.application.Platform.runLater(() -> {
if (!conversionGroup.isOver() && !conversionGroup.isStarted() && !conversionGroup.isDetached()) {
AudiobookConverter.getContext().addPosterIfMissingWithDelay(artWorkBean);
}
Expand Down
Loading