diff --git a/src/main/java/com/freeipodsoftware/abc/MainWindow.java b/src/main/java/com/freeipodsoftware/abc/MainWindow.java index a25f410c..c78e45f8 100644 --- a/src/main/java/com/freeipodsoftware/abc/MainWindow.java +++ b/src/main/java/com/freeipodsoftware/abc/MainWindow.java @@ -122,6 +122,7 @@ private ConversionStrategy getConversionStrategy() { private void startConversion() { List media = this.inputFileSelection.getMedia(); + getConversionStrategy().setMp4Tags(this.toggleableTagEditor.getTagEditor().getMp4Tags()); if (media.size() > 0) { if (this.getConversionStrategy().makeUserInterview(this.sShell, media.get(0).getFileName())) { conversionStrategy.setMedia(media); @@ -129,9 +130,8 @@ private void startConversion() { JobProgress jobProgress = new JobProgress(conversionStrategy, progressView, media); this.setUIEnabled(false); - this.getConversionStrategy().setMp4Tags(this.toggleableTagEditor.getTagEditor().getMp4Tags()); - this.getConversionStrategy().start(this.sShell); + this.getConversionStrategy().start(this.sShell); Executors.newSingleThreadExecutor().execute(jobProgress); } } diff --git a/src/main/java/com/freeipodsoftware/abc/Mp4Tags.java b/src/main/java/com/freeipodsoftware/abc/Mp4Tags.java index 64e822ca..fba99d46 100644 --- a/src/main/java/com/freeipodsoftware/abc/Mp4Tags.java +++ b/src/main/java/com/freeipodsoftware/abc/Mp4Tags.java @@ -45,6 +45,7 @@ public Mp4Tags(Map tags) { } public String getSeries() { + if (series == null) return title; return this.series; } diff --git a/src/main/java/com/freeipodsoftware/abc/conversionstrategy/AbstractConversionStrategy.java b/src/main/java/com/freeipodsoftware/abc/conversionstrategy/AbstractConversionStrategy.java index e096d169..0e89e8b5 100644 --- a/src/main/java/com/freeipodsoftware/abc/conversionstrategy/AbstractConversionStrategy.java +++ b/src/main/java/com/freeipodsoftware/abc/conversionstrategy/AbstractConversionStrategy.java @@ -58,7 +58,40 @@ protected static String selectOutputFile(Shell shell, String filenameSuggestion) protected String getOuputFilenameSuggestion(String fileName) { - String mp3Filename = fileName; + StringBuilder builder = new StringBuilder(); + if (StringUtils.isNotBlank(mp4Tags.getWriter())) { + builder + .append(StringUtils.trim(mp4Tags.getWriter())); + + } + if (StringUtils.isNotBlank(mp4Tags.getSeries()) && !StringUtils.equals(mp4Tags.getSeries(), mp4Tags.getTitle())) { + builder + .append(" - [") + .append(StringUtils.trim(mp4Tags.getSeries())); + if (mp4Tags.getTrack() > 0) { + builder + .append(" - ") + .append(mp4Tags.getTrack()); + } + builder.append("] "); + } + if (StringUtils.isNotBlank(mp4Tags.getTitle())) { + builder.append(StringUtils.trim(mp4Tags.getTitle())); + } + if (StringUtils.isNotBlank(mp4Tags.getNarrator())) { + builder + .append(" (") + .append(StringUtils.trim(mp4Tags.getNarrator())) + .append(")"); + } + String result = builder.toString(); + String mp3Filename; + + if (StringUtils.isBlank(result)) { + mp3Filename = fileName; + } else { + mp3Filename = result; + } return mp3Filename.replaceFirst("\\.\\w*$", ".m4b"); } diff --git a/src/main/java/uk/yermak/audiobookconverter/ParallelConversionStrategy.java b/src/main/java/uk/yermak/audiobookconverter/ParallelConversionStrategy.java index d4461c5d..0e33bf48 100644 --- a/src/main/java/uk/yermak/audiobookconverter/ParallelConversionStrategy.java +++ b/src/main/java/uk/yermak/audiobookconverter/ParallelConversionStrategy.java @@ -19,7 +19,7 @@ public class ParallelConversionStrategy extends AbstractConversionStrategy imple private String outputFileName; public boolean makeUserInterview(Shell shell, String fileName) { - this.outputFileName = selectOutputFile(shell, this.getOuputFilenameSuggestion(fileName)); + this.outputFileName = selectOutputFile(shell, getOuputFilenameSuggestion(fileName)); return this.outputFileName != null; }