@@ -12,18 +12,15 @@ import ReadiumShared
12
12
///
13
13
/// It can also work for a standalone audio file.
14
14
public final class AudioParser : PublicationParser {
15
- private let assetRetriever : AssetRetriever
16
- private let manifestAugmentor : AudioPublicationManifestAugmentor
15
+ /// The default set of audio format specifications that determine whether an archive qualifies as an audiobook.
16
+ /// These formats include common audio file types such as MP3, AAC, FLAC, etc.
17
+ public static let defaultAudioSpecifications : Set < FormatSpecification > = audioSpecifications
17
18
18
- public init (
19
- assetRetriever: AssetRetriever ,
20
- manifestAugmentor: AudioPublicationManifestAugmentor = AVAudioPublicationManifestAugmentor ( )
21
- ) {
22
- self . assetRetriever = assetRetriever
23
- self . manifestAugmentor = manifestAugmentor
24
- }
19
+ /// A set of file extensions that are ignored during audiobook processing.
20
+ /// These typically include playlist files, metadata, or auxiliary files that should not be treated as audio content.
21
+ public static let defaultIgnoredExtensions : Set < FileExtension > = ignoredExtensions
25
22
26
- private let audioSpecifications : Set < FormatSpecification > = [
23
+ private static let audioSpecifications : Set < FormatSpecification > = [
27
24
. aac,
28
25
. aiff,
29
26
. flac,
@@ -35,6 +32,38 @@ public final class AudioParser: PublicationParser {
35
32
. webm,
36
33
]
37
34
35
+ private static let ignoredExtensions : Set < FileExtension > = [
36
+ " asx " ,
37
+ " bio " ,
38
+ " m3u " ,
39
+ " m3u8 " ,
40
+ " pla " ,
41
+ " pls " ,
42
+ " smil " ,
43
+ " txt " ,
44
+ " vlc " ,
45
+ " wpl " ,
46
+ " xspf " ,
47
+ " zpl " ,
48
+ ]
49
+
50
+ private let assetRetriever : AssetRetriever
51
+ private let manifestAugmentor : AudioPublicationManifestAugmentor
52
+ private let ignoredExtensions : Set < FileExtension >
53
+ private let audioSpecifications : Set < FormatSpecification >
54
+
55
+ public init (
56
+ assetRetriever: AssetRetriever ,
57
+ manifestAugmentor: AudioPublicationManifestAugmentor = AVAudioPublicationManifestAugmentor ( ) ,
58
+ audioSpecifications: Set < FormatSpecification > = AudioParser . defaultAudioSpecifications,
59
+ ignoredExtensions: Set < FileExtension > = AudioParser . defaultIgnoredExtensions
60
+ ) {
61
+ self . assetRetriever = assetRetriever
62
+ self . manifestAugmentor = manifestAugmentor
63
+ self . ignoredExtensions = ignoredExtensions
64
+ self . audioSpecifications = audioSpecifications
65
+ }
66
+
38
67
public func parse(
39
68
asset: Asset ,
40
69
warnings: WarningLogger ?
@@ -107,23 +136,6 @@ public final class AudioParser: PublicationParser {
107
136
guard let filename = url. lastPathSegment else {
108
137
return true
109
138
}
110
- let ignoredExtensions : [ FileExtension ] = [
111
- " asx " ,
112
- " bio " ,
113
- " m3u " ,
114
- " m3u8 " ,
115
- " pla " ,
116
- " pls " ,
117
- " smil " ,
118
- " txt " ,
119
- " vlc " ,
120
- " wpl " ,
121
- " xspf " ,
122
- " zpl " ,
123
- " jpg " ,
124
- " pdf " ,
125
- ]
126
-
127
139
return url. pathExtension == nil
128
140
|| ignoredExtensions. contains ( url. pathExtension!)
129
141
|| filename. hasPrefix ( " . " )
0 commit comments