Skip to content

Commit

Permalink
Split duration and name into separate variables for more clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek committed Jul 19, 2017
1 parent e66ceef commit 6826223
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ object MatroskaChapterFlattener {

fun addChapter(chapters: List<MatroskaChapter>, depth: Int) {
chapters.forEachIndexed { i, chapter ->
res.put(
// Simple hack with adding depth is needed because chapter
// and it's first sub-chapter have usually the same starting time.
(chapter.startTime / 1000000).toInt() + if (i == 0) depth else 0,
"+ ".repeat(depth) + (chapter.getName(*preferredLanguages) ?: "Chapter ${i + 1}"))
val duration = (chapter.startTime / 1000000).toInt() +
if (i == 0) depth else 0
// Simple hack with adding depth is needed because chapter
// and it's first sub-chapter have usually the same starting time.
val name = "+ ".repeat(depth) + (chapter.getName(*preferredLanguages) ?: "Chapter ${i + 1}")
res.put(duration, name)
addChapter(chapter.children, depth + 1)
}
}
Expand Down

0 comments on commit 6826223

Please sign in to comment.