Skip to content

Commit

Permalink
improved filename suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
yermak committed Jan 4, 2018
1 parent 93707c9 commit a05302d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/freeipodsoftware/abc/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ private ConversionStrategy getConversionStrategy() {

private void startConversion() {
List<MediaInfo> 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);
ProgressView progressView = createProgressView();
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);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/freeipodsoftware/abc/Mp4Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Mp4Tags(Map<String, String> tags) {
}

public String getSeries() {
if (series == null) return title;
return this.series;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a05302d

Please sign in to comment.