All pastes #273496 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-09 23:17 UTC
rendered paste body
chapter_length=$(( total_length / CHAPTERS ))
remainder=0
unset x

for vid in ${!VID_LENS[@]}; do
    adjusted_length=$(( ${VID_LENS[vid]} + remainder ))
    num_chapters=$(( adjusted_length / chapter_length ))
    if (( num_chapters > 0)); then
        chapter_length_array=( $( for ((t=0; t<num_chapters; t++)); do
        echo $chapter_length; done) )
        chapter_length_array[0]=$(( chapter_length - remainder ))
        chapter_in_secs=$( running_total <<< ${chapter_length_array[@]} )
        remainder=$(( adjusted_length % chapter_length ))
        chapters[x++]=$chapter_in_secs
    else
        chapters[x++]=""
        remainder=$adjusted_length
    fi
    unset chapter_length_array
done

chapters[0]="0 ${chapters[0]}"