mirror of
				https://github.com/KrumpetPirate/AAXtoMP3.git
				synced 2025-10-31 11:30:43 +01:00 
			
		
		
		
	Update of chapter titles with sortable 0padded numbers
* Removed chapter_padding() * Fixed $chaptercount * Redone 0-padded chapter titles with printf()
This commit is contained in:
		
							
								
								
									
										20
									
								
								AAXtoMP3
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								AAXtoMP3
									
									
									
									
									
								
							| @@ -67,18 +67,6 @@ normalize_whitespace() { | ||||
|     echo $* | ||||
| } | ||||
|  | ||||
| chapter_padding() { | ||||
|     chaptercount=$($GREP -Pc "title\s+:\sChapter\s\d+" $metadata_file) | ||||
|     if [[ $chaptercount -gt 9 && $chaptercount -lt 100 ]] | ||||
|     then | ||||
|             chapter=$(sed -e 's/Chapter \([[:digit:]]\)$/Chapter 0\1/' <<<$chapter) | ||||
|     elif [[ $chaptercount -gt 99 && $chaptercount -lt 999 ]] | ||||
|     then | ||||
|             chapter=$(sed -e 's/Chapter \([[:digit:]]\)$/Chapter 00\1/' <<<$chapter) | ||||
|             chapter=$(sed -e 's/Chapter \([[:digit:]]\{2\}\)$/Chapter 0\1/' <<<$chapter) | ||||
|     fi | ||||
| } | ||||
|  | ||||
| for path | ||||
| do | ||||
|     debug "Decoding ${path} with auth code ${auth_code}..." | ||||
| @@ -96,17 +84,19 @@ do | ||||
|     debug "Created ${full_file_path}." | ||||
|  | ||||
|     if [ "${mode}" == "chaptered" ]; then | ||||
|         debug "Extracting chapter files from ${full_file_path}..." | ||||
|         chaptercount=$($GREP -Pc "Chapter.*start.*end" $metadata_file) | ||||
|         debug "Extracting ${chaptercount} chapter files from ${full_file_path}..." | ||||
|  | ||||
|         chapternum=1 | ||||
|         while read -r -u9 first _ _ start _ end | ||||
|         do | ||||
|             if [[ "${first}" = "Chapter" ]] | ||||
|             then | ||||
|                 read -r -u9 _ | ||||
|                 read -r -u9 _ _ chapter | ||||
|                 chapter_padding | ||||
|                 chapter_file="${output_directory}/${title} - ${chapter}.${extension}" | ||||
|                 chapter_file="${output_directory}/${title} - $(printf %0${#chaptercount}d $chapternum) ${chapter}.${extension}" | ||||
|                 </dev/null ffmpeg -loglevel error -stats -i "${full_file_path}" -ss "${start%?}" -to "${end}" -codec:a copy -metadata track="${chapter}" "${chapter_file}" | ||||
|                 chapternum=$((chapternum + 1 )) | ||||
|             fi | ||||
|         done 9< "$metadata_file" | ||||
|         rm "${full_file_path}" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user