Skip to content

Commit

Permalink
* get chapter name from file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Yugov authored and Mikhail Yugov committed Mar 25, 2020
1 parent 4502aca commit bc87d28
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 19 deletions.
49 changes: 49 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>audiobookconverter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
2 changes: 2 additions & 0 deletions .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 9 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,3 @@ public String toString() {
}
}


7 changes: 2 additions & 5 deletions src/main/java/uk/yermak/audiobookconverter/Chapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public Chapter(Part part, List<MediaInfo> nextMedia) {
}

public String getTitle() {
if (rawTitle != null) {
return Chapter.this.getNumber() + ":" + rawTitle;
}
return "Chapter " + getNumber();
return details;
}

public int getNumber() {
Expand Down Expand Up @@ -91,7 +88,7 @@ public List<String> getMetaData(AudioBookInfo bookInfo) {
}

public String getRawTitle() {
return rawTitle;
return details;
}

public void setRawTitle(String rawTitle) {
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/uk/yermak/audiobookconverter/MetadataBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ public File prepareMeta(final long jobId, final AudioBookInfo bookInfo, Converta
metaData.add("major_brand=M4A");
metaData.add("minor_version=512");
metaData.add("compatible_brands=isomiso2");
metaData.add("title=" + bookInfo.getTitle() + (convertable.isTheOnlyOne() ? "" : ("-" + convertable.getNumber())));
metaData.add("artist=" + bookInfo.getWriter());
if (StringUtils.isNotBlank(bookInfo.getSeries())) {
metaData.add("album=" + bookInfo.getSeries());
} else {
metaData.add("album=" + bookInfo.getTitle());
}
metaData.add("composer=" + bookInfo.getNarrator());
metaData.add("date=" + bookInfo.getYear());
metaData.add("comment=" + bookInfo.getComment());
metaData.add("artist=" + ((StringUtils.isBlank(bookInfo.getWriter())) ? "" : bookInfo.getWriter()));
metaData.add("album=" + ((StringUtils.isBlank(bookInfo.getSeries())) ? "" : bookInfo.getSeries() + " - ") + bookInfo.getTitle());
metaData.add("composer=" + ((StringUtils.isBlank(bookInfo.getNarrator())) ? "" : bookInfo.getNarrator()));
metaData.add("date=" + ((StringUtils.isBlank(bookInfo.getYear())) ? "" : bookInfo.getYear()));
metaData.add("comment=" + ((StringUtils.isBlank(bookInfo.getComment())) ? "" : bookInfo.getComment()));
metaData.add("track=" + bookInfo.getBookNumber() + "/" + bookInfo.getTotalTracks());
metaData.add("media_type=2");
metaData.add("genre=" + bookInfo.getGenre());
metaData.add("genre=" + ((StringUtils.isBlank(bookInfo.getGenre())) ? "Audiobook" : bookInfo.getGenre()));
metaData.addAll(convertable.getMetaData(bookInfo));
String collect = metaData.stream().collect(Collectors.joining(toString()));
logger.debug(collect);
Expand All @@ -45,4 +40,3 @@ public File prepareMeta(final long jobId, final AudioBookInfo bookInfo, Converta
}
}


2 changes: 1 addition & 1 deletion src/main/java/uk/yermak/audiobookconverter/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void closeSilently(Process process) {
public static String formatChapter(int partNumber, Chapter chapter) {
String chapterFormat = AppProperties.getProperty("chapter_format");
if (chapterFormat == null) {
chapterFormat = "<if(BOOK_NUMBER)> Book <BOOK_NUMBER>. <endif>Chapter <CHAPTER_NUMBER><if(CHAPTER_TITLE)>- <CHAPTER_TITLE><endif> - <DURATION>";
chapterFormat = "<CHAPTER_TITLE> - <DURATION>";
AppProperties.setProperty("chapter_format", chapterFormat);
}

Expand Down

0 comments on commit bc87d28

Please sign in to comment.