Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
Fixes for jq command generating chapters.txt
Browse files Browse the repository at this point in the history
Fixes #184

Adds a reduce + flatten step to generate a flat list of chapters.

Fixes #206

Support for emitting timestamps greater than 24 hours.
  • Loading branch information
bismark committed Mar 2, 2022
1 parent 3e42539 commit cab6394
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion AAXtoMP3
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,10 @@ save_metadata() {
jq -r \
'def pad(n): tostring | if (n > length) then ((n - length) * "0") + . else . end;
.content_metadata.chapter_info.chapters |
reduce .[] as $c ([]; if $c.chapters? then .+[$c | del(.chapters)]+[$c.chapters] else .+[$c] end) | flatten |
to_entries |
.[] |
"CHAPTER\((.key))=\(((.value.start_offset_ms / (1000*60*60)) %24 | floor | pad(2))):\(((.value.start_offset_ms / (1000*60)) %60 | floor | pad(2))):\(((.value.start_offset_ms / 1000) %60 | floor | pad(2))).\((.value.start_offset_ms % 1000 | pad(3)))
"CHAPTER\((.key))=\((((((.value.start_offset_ms / (1000*60*60)) /24 | floor) *24 ) + ((.value.start_offset_ms / (1000*60*60)) %24 | floor)) | pad(2))):\(((.value.start_offset_ms / (1000*60)) %60 | floor | pad(2))):\(((.value.start_offset_ms / 1000) %60 | floor | pad(2))).\((.value.start_offset_ms % 1000 | pad(3)))
CHAPTER\((.key))NAME=\(.value.title)"' "${extra_chapter_file}" > "${tmp_chapter_file}"
fi

Expand Down

0 comments on commit cab6394

Please sign in to comment.