From ebfbdeb2841fd40aea238489e9a480938fec20ab Mon Sep 17 00:00:00 2001 From: CXwudi Date: Wed, 25 Dec 2024 12:49:30 -0500 Subject: [PATCH] :sparkles: Add MkaAudioTagger mapping for AnyToMkaAudioExtractor Implement missing tagger decision for MKA audio files to ensure proper handling of this format --- .../cx/vvd/extractor/component/TaggerDecider.kt | 3 +++ .../vvd/extractor/component/TaggerDeciderCoreTest.kt | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/vvd-extractor/src/main/kotlin/mikufan/cx/vvd/extractor/component/TaggerDecider.kt b/vvd-extractor/src/main/kotlin/mikufan/cx/vvd/extractor/component/TaggerDecider.kt index dda3d83..0f19c5f 100644 --- a/vvd-extractor/src/main/kotlin/mikufan/cx/vvd/extractor/component/TaggerDecider.kt +++ b/vvd-extractor/src/main/kotlin/mikufan/cx/vvd/extractor/component/TaggerDecider.kt @@ -3,9 +3,11 @@ package mikufan.cx.vvd.extractor.component import mikufan.cx.vvd.common.exception.RuntimeVocaloidException import mikufan.cx.vvd.extractor.component.extractor.base.BaseAudioExtractor import mikufan.cx.vvd.extractor.component.extractor.impl.AacToM4aAudioExtractor +import mikufan.cx.vvd.extractor.component.extractor.impl.AnyToMkaAudioExtractor import mikufan.cx.vvd.extractor.component.extractor.impl.OpusToOggAudioExtractor import mikufan.cx.vvd.extractor.component.tagger.base.BaseAudioTagger import mikufan.cx.vvd.extractor.component.tagger.impl.M4aAudioTagger +import mikufan.cx.vvd.extractor.component.tagger.impl.MkaAudioTagger import mikufan.cx.vvd.extractor.component.tagger.impl.Mp3AudioTagger import mikufan.cx.vvd.extractor.component.tagger.impl.OggOpusAudioTagger import mikufan.cx.vvd.extractor.component.util.MediaFormatChecker @@ -53,6 +55,7 @@ class TaggerDeciderCore( when (val decidedExtractor = decidedExtractorOpt.get()) { is AacToM4aAudioExtractor -> beanFactory.getBean() is OpusToOggAudioExtractor -> beanFactory.getBean() + is AnyToMkaAudioExtractor -> beanFactory.getBean() else -> error("This should not happened, unknown audio extractor: ${decidedExtractor.name}") } } else { diff --git a/vvd-extractor/src/test/kotlin/mikufan/cx/vvd/extractor/component/TaggerDeciderCoreTest.kt b/vvd-extractor/src/test/kotlin/mikufan/cx/vvd/extractor/component/TaggerDeciderCoreTest.kt index 1b777b9..e6d3c7a 100644 --- a/vvd-extractor/src/test/kotlin/mikufan/cx/vvd/extractor/component/TaggerDeciderCoreTest.kt +++ b/vvd-extractor/src/test/kotlin/mikufan/cx/vvd/extractor/component/TaggerDeciderCoreTest.kt @@ -10,8 +10,10 @@ import io.mockk.mockk import mikufan.cx.vvd.common.exception.RuntimeVocaloidException import mikufan.cx.vvd.extractor.component.extractor.base.BaseAudioExtractor import mikufan.cx.vvd.extractor.component.extractor.impl.AacToM4aAudioExtractor +import mikufan.cx.vvd.extractor.component.extractor.impl.AnyToMkaAudioExtractor import mikufan.cx.vvd.extractor.component.extractor.impl.OpusToOggAudioExtractor import mikufan.cx.vvd.extractor.component.tagger.impl.M4aAudioTagger +import mikufan.cx.vvd.extractor.component.tagger.impl.MkaAudioTagger import mikufan.cx.vvd.extractor.component.tagger.impl.Mp3AudioTagger import mikufan.cx.vvd.extractor.component.tagger.impl.OggOpusAudioTagger import mikufan.cx.vvd.extractor.component.util.MediaFormatChecker @@ -41,6 +43,7 @@ class TaggerDeciderCoreTest : ShouldSpec({ every { getBean() } returns mockk(relaxed = true) every { getBean() } returns mockk(relaxed = true) every { getBean() } returns mockk(relaxed = true) + every { getBean() } returns mockk(relaxed = true) } } @@ -64,6 +67,15 @@ class TaggerDeciderCoreTest : ShouldSpec({ tagger.shouldBeInstanceOf() coVerify(exactly = 0) { mockAudioFormatChecker.checkAudioFormat(any()) } } + should("decide mka tagger for mka file produced by any->mka extractor") { + val mockAudioFormatChecker = createMockChecker() + val mockBeanFactory = createMockFactory() + val taggerDecider = TaggerDeciderCore(mockAudioFormatChecker, mockBeanFactory) + + val tagger = taggerDecider.decideTagger(Optional.of(mockk(relaxed = true)), null) + tagger.shouldBeInstanceOf() + coVerify(exactly = 0) { mockAudioFormatChecker.checkAudioFormat(any()) } + } should("throw exception for unknown extractor") { val mockAudioFormatChecker = createMockChecker() val mockBeanFactory = createMockFactory()