From 1a3f9b2c5246cb5f696690dbebabceebd35a4f68 Mon Sep 17 00:00:00 2001 From: Kaleb Smith Date: Sat, 5 Dec 2026 22:11:53 -0500 Subject: [PATCH] fix: recognize m4b audiobook files as audio Add m4b to the audio/mp4 extension list so autodetection and ID3-based music matching treat audiobooks as audio instead of falling back to movie/series detection. Fixes #9 --- source/org/openfilebot/MediaTypes.properties | 2 +- test/org/openfilebot/media/MediaDetectionTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/org/openfilebot/MediaTypes.properties b/source/org/openfilebot/MediaTypes.properties index 832a0d040..2bcbee15e 100644 --- a/source/org/openfilebot/MediaTypes.properties +++ b/source/org/openfilebot/MediaTypes.properties @@ -17,7 +17,7 @@ archive/tar: tar archive/bzip2: bzip2 audio/mp3: mp3 -audio/mp4: m4a aac +audio/mp4: m4a m4b aac audio/flac: flac audio/wma: wma audio/ogm: ogg ogm ogv oga diff --git a/test/org/openfilebot/media/MediaDetectionTest.java b/test/org/openfilebot/media/MediaDetectionTest.java index f7edf3fd1..d25516a6d 100644 --- a/test/org/openfilebot/media/MediaDetectionTest.java +++ b/test/org/openfilebot/media/MediaDetectionTest.java @@ -2,6 +2,7 @@ import static java.util.Collections.*; import static org.junit.Assert.*; +import static org.openfilebot.MediaTypes.*; import java.io.File; import java.util.Locale; @@ -10,6 +11,16 @@ public class MediaDetectionTest { + @Test + public void m4bIsAudio() { + File m4b = new File("book.m4b"); + + assertTrue(AUDIO_FILES.accept(m4b)); + assertTrue(AUDIO_FILES.accept(new File("BOOK.M4B"))); + assertFalse(VIDEO_FILES.accept(m4b)); + assertTrue(new AutoDetection(emptyList(), false, Locale.ENGLISH).isMusic(m4b)); + } + @Test public void parseMovieYear() { assertEquals("[2009]", MediaDetection.parseMovieYear("Avatar 2009 2100").toString());