remove global book variables
This commit is contained in:
		
							parent
							
								
									b8f3397afe
								
							
						
					
					
						commit
						fce19df179
					
				
					 1 changed files with 5 additions and 17 deletions
				
			
		
							
								
								
									
										22
									
								
								to-m4b.sh
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								to-m4b.sh
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -8,18 +8,12 @@ declare -r script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 | 
			
		|||
 | 
			
		||||
# VARS
 | 
			
		||||
LEADING_ZEROES=2
 | 
			
		||||
SRC="${SRC:${script_dir}/src}"
 | 
			
		||||
OUT="${OUT:${script_dir}/out}"
 | 
			
		||||
AUTHOR="${AUTHOR:-}"
 | 
			
		||||
NARRATOR="${NARRATOR:-}"
 | 
			
		||||
TITLE="${TITLE:-}"
 | 
			
		||||
YEAR="${YEAR:-}"
 | 
			
		||||
SERIES="${SERIES:-}"
 | 
			
		||||
SERIES_INDEX="${SERIES_INDEX:-}"
 | 
			
		||||
MAIN_SRC="${SRC:${script_dir}/src}"
 | 
			
		||||
MAIN_OUT="${OUT:${script_dir}/out}"
 | 
			
		||||
 | 
			
		||||
# FUNCTIONS
 | 
			
		||||
parse-vars() {
 | 
			
		||||
  # TODO implement parsing the directory structure to fill in missing vars and return them
 | 
			
		||||
  # TODO implement parsing the directory structure of the passed directory, to fill in missing vars and return them
 | 
			
		||||
  # Series structure: ${SRC}/<author>/<series>/Book <part> - <year> - <book> {<narrator>}/
 | 
			
		||||
  # Standalone structure: ${SRC}/<author>/<year> - <book> {<narrator>}/
 | 
			
		||||
  # Return the <part> wihh leading zeros based on the LEADING_ZEROES variable
 | 
			
		||||
| 
						 | 
				
			
			@ -61,13 +55,7 @@ m4b-merge() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
main() {
 | 
			
		||||
  parse-vars
 | 
			
		||||
  local book_dirs
 | 
			
		||||
  IFS=$'\n' read -r -d '' -a book_dirs < <(get-book-directories && printf '\0')
 | 
			
		||||
  for book_dir in "${book_dirs[@]}"; do
 | 
			
		||||
    local book_output_file="${OUT}/${AUTHOR}/${(SERIES:+${SERIES}/)}${(SERIES:+Book ${SERIES_INDEX} - )}${YEAR} - ${TITLE}.m4b"
 | 
			
		||||
    m4b-merge "${LEADING_ZEROES}" "${book_output_file}" "${book_dir}" "${AUTHOR}" "${NARRATOR}" "${TITLE}" "${YEAR}" "${SERIES}" "${SERIES_INDEX}"
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main "$@"
 | 
			
		||||
main "$@"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue