Simple CUE Sheet parser implemented in Kotlin
For repository url, please see ShinonomeTN Public Maven Repository
Maven:
<dependency>
<groupId>com.shinonometn</groupId>
<artifactId>cue-parser-kt</artifactId>
<version>${cue-parser-version}</version>
</dependency>
Gradle:
implementation 'com.shinonometn:cue-parser-kt:${cue-parser-version}'
fun main() {
println("Read CUE sheet file.")
val cue = CueParser(FileInputStream(File("sample.cue")))
println(cue)
}
fun main() {
val reader = CueParser(FileInputStream(File("sample.cue"))).reader()
println("""
Cue file information:
------------------------------------------------
Title : ${reader.albumInfo(AlbumInfo.Title)}
Performer: ${reader.albumInfo(AlbumInfo.Performer)}
Genre : ${reader.albumInfo(AlbumInfo.Genre)}
Date : ${reader.albumInfo(AlbumInfo.Date)}
------------------------------------------------
Raw data:
------------------------------------------------
${reader.rootNode.properties}
""".trimIndent())
}
Current supported meta:
- Catalog
- CDTextFile
- Performer
- SongWriter
- Arranger
- Composer
- Title
- DiscID
- Genre
- Date
fun main() {
val reader = CueParser(FileInputStream(File("sample.cue"))).reader()
val file = reader.mediaFile()
val trackList = file.trackList()
trackList.forEach {
println("""
Track ${it.number} Info:
---------------------------------------
Type :${it.type}
Title : ${it.trackInfo(TrackInfo.Title)}
Performer: ${it.trackInfo(TrackInfo.Performer)}
---------------------------------------
Raw data :
${it.node.properties}
---------------------------------------
""".trimIndent())
}
}
Current supported meta:
- Title
- Performer
- SongWriter
- ISRC
- Number
- Year
- Genre
There are two CueParser usage:
- CueParser() function accept an InputStream, return root node of CUE info tree. See above.
- CueParser() constructor accept an Iterable of CUE content lines, creates an iterator.
The hierarchy of a CUE sheet usually like this:
- meta
- file
|- track
|- meta
CUE Sheets that not in this hierarchy will cause errors when parsing.
Each CueNode has those fields:
- type: node type
- parent: parent node, root has no parent
- properties: a Map containing meta info about this node, usually key is argument index, value is argument,
@
means it might be a command. - children: child nodes
There are two types of node can become parent:
- ROOT: the CUE Sheet itself, containing FILEs.
- FILE: containing TRACKs.
- TRACK: containing INDEXs and metas.
REM, metas, and INDEXs have no children.
(The parser supports multiple FILE declaration.)
CueInfoReader is the default reader implementation provided, use CueTreeNode.reader()
on root node to get one.
It uses CueTreeNode.properties
to read album and track info.
CueSheet Dsl can help you build a CUE sheet.
CueSheet {
rem("COMMENT", "This is a comment")
comment("This is also a comment")
file("Hallo Event.wav", "WAV") {
track(1, "AUDIO") {
index(1, "00:00:00".toMSFTimePoint())
meta("TITLE", "Hallo Event")
}
}
}