currently only this section is avoided if -r 'rip-only' flag is set
if [[ -z $rip_only ]]; then
get_max_progress () {
echo 100
}
#
get_total_progress () {
#We use this variable in this instance as we need to manipulate the output so interger and no leading zero. eg. '1' no '01'
#tot_progress_result=$(grep '"Progress":' "$working_dir/temp/$bluray_name"/handbrake.log | tail -1 | cut -d '.' -f 2 | cut -d ',' -f 1 | cut -c-2)
tot_progress_result=$(grep -a "Progress: {" -A 8 handbrake.log | grep '"WORKING"' -A 7 | grep '"Progress"' | tail -1 | cut -d '.' -f 2 | cut -d ',' -f 1 | cut -c-2)
tot_progress_result=$((10#$tot_progress_result))
echo $tot_progress_result
}
esilent "${colbor}Encoding started...${colrst}"
#HandBrakeCLI $options -i $source_loc $source_options -o $output_loc $output_options $video_options $audio_options $picture_options $filter_options $subtitle_options > /dev/null 2>&1 &
unit_of_measure="percent"
HandBrakeCLI $options -i $source_loc $source_options -o "${output_loc}${feature_name}" $output_options $video_options $audio_options $picture_options $filter_options $subtitle_options > "$working_dir"/temp/"$bluray_name"/handbrake.log 2>&1 &
handbrake_pid=$!
edebug "handbrake_pid: $handbrake_pid"
pid_name=$handbrake_pid
edebug "pid name: $pid_name"
sleep 10s # to give time file to be created and data being inputted
if [[ -z $bar_override ]]; then
progress_bar2_init
#check for any non zero errors
if [ $? -eq 0 ]; then
edebug "...handbrake conversion of: $bluray_name complete."
else
eerror "...handbrake produced an error, code: $?"
exit 66
fi
else
edebug "progress bars overriden"
wait $handbrake_pid
fi
fi
But should it be this entire section?
#+----------------------+
#+---"Setup Encoding"---+
#+----------------------+
#
options="--json --no-dvdna"
source_loc="$makemkv_out_loc" #this should match the makemkv output location
output_options="-f mkv"
container_type="mkv"
video_options="-e x264 --encoder-preset medium --encoder-tune film --encoder-profile high --encoder-level 4.1 -q $quality -2"
picture_options="--crop 0:0:0:0 --loose-anamorphic --keep-display-aspect --modulus 2"
filter_options="--decomb"
subtitle_options="-N eng -F scan"
#
#make the working directory if not already existing
#this step is vital, otherwise the files below are created whereever the script is run from and will fail
cd "$working_dir/temp/$bluray_name" || { edebug "Failure changing to working directory temp"; exit 65; }
#
#Grab all titles from source
edebug "scanning source location for titles..."
HandBrakeCLI --json -i $source_loc -t 0 --main-feature &> all_titles_scan.json
#search file for identified main feature
auto_found_main_feature=$(grep -w "Found main feature title" all_titles_scan.json)
if [[ -z $auto_found_main_feature ]]; then
eerror "Something went wrong with auto_found_main_feature"
exit 66
fi
edebug "auto_found_main_feature is: $auto_found_main_feature"
#we cut unwanted "Found main feature title " text from the variable
auto_found_main_feature=${auto_found_main_feature:25}
edebug "auto_found_main_feature cut to: $auto_found_main_feature"
#
#NOW CREATE main feature_scan
edebug "creating main_feature_scan.json ..."
#do X if no title over-ride, else use the title over-ride
if [[ -z $title_override ]]; then
HandBrakeCLI --json -i $source_loc -t $auto_found_main_feature --scan 1> main_feature_scan.json 2> /dev/null
else
HandBrakeCLI --json -i $source_loc -t $title_override --scan 1> main_feature_scan.json 2> /dev/null
fi
#
#CLEAN FILE FOR JQ
clean_main_feature_scan
#SEARCH FOR FEATURE NAME VIA JQ, unless override in place
if [[ -z $name_override ]]; then
feature_name=$(jq --raw-output '.[].TitleList[].Name' main_feature_scan_trimmed.json | head -n 1 | sed -e "s/ /_/g")
else
feature_name="$name_override"
fi
edebug "feature name is: $feature_name"
#
#CLEAN THE FOUND LOCAL TITLE TO SEARCH WITH
#extract '_' in name
field_count="${feature_name//[^_]}"
edebug "delimeter pick is: $field_count"
#count them
field_count="${#field_count}"
edebug "count of delimiters is: $field_count, so $((field_count+1)) elements"
#increase delimeter count by 1 so it represents number of fields/elements
field_count=$((field_count+1))
edebug "field_count +1 is: $field_count"
#
#start the array
title_array=() # declare an empty array; same as: declare -a groups
#for i in {1..5..1}; do
for ((i=1;i<=field_count;i++)); do
title_array[i]=$(echo $feature_name | cut -d '_' -f $i)
edebug "element is: $i, value is: ${title_array[i]}"
if [[ $banned_list =~ (^|[[:space:]])${title_array[i]}($|[[:space:]]) ]]; then
edebug "element matches banned list removing from array"
unset title_array[i]
else
edebug "valid title content, using"
fi
done
#
# Print the resulting array's elements.
#printf '%s\n' "${title_array[@]}"
edebug "array element 1: ${title_array[1]}"
# check if element 1 is a number and if so greater than year format for movie titles, eg 1949 would be valid but 83442423 (in disc lable) woudl not be
if [[ ${title_array[1]} =~ ^[0-9]+$ ]] && [[ ${title_array[1]} -ge 9999 ]]; then
edebug "element1 of array equaled a number of 10000 or more, unlikely to part of a valid film title removing from array"
#remove from array if it is bigger than should be
unset title_array[1]
edebug "element array now shows:"
# printf '%s\n' "${groups[@]}"
feature_name=( "${title_array[*]}" )
edebug "online feature name check now set for: $feature_name"
else
edebug "Array element 1 not a number so using"
fi
#
if [[ $banned_name_endings =~ (^|[[:space:]])${title_array[-1]}($|[[:space:]]) ]]; then
edebug "last of array matche the banned ending element list, removing from array"
unset title_array[-1]
feature_name=( "${title_array[*]}" )
edebug "online feature name check now set for: $feature_name"
else
edebug "last element in array passes checks, using"
fi
#
feature_name=$(echo "${title_array[*]}")
feature_name_prep="${feature_name//_/ }"
edebug "$feature_name_prep"
# do some work to make the array result acceptable for a http api request, replace ' ' with '+'
feature_name_prep="${feature_name_prep// /+}"
edebug "$feature_name_prep"
#create http segment in a variable so that individual variables don't need expanding in curl request, it doesn't work!
http_construct="http://www.omdbapi.com/?t=$feature_name_prep&apikey=$omdb_apikey"
#
#run online query
edebug "http_construct is: $http_construct"
edebug "Querying omdb..."
#omdb_title_result=$(curl -sX GET --header "Accept: */*" "http://www.omdbapi.com/?t=${feature_name}&apikey=${omdb_apikey}")
omdb_title_result=$(curl -sX GET --header "Accept: */*" "$http_construct")
#
#IF ONLINE SEARCH SUCCEEDS DO EXTRA.
#{"Response":"False","Error":"Incorrect IMDb ID."}
if [[ "$omdb_title_result" = *'"Title":"'* ]]; then
edebug "omdb matching info is: $omdb_title_result"
omdb_title_name_result=$(echo $omdb_title_result | jq --raw-output '.Title')
edebug "omdb title name is: $omdb_title_name_result"
omdb_year_result=$(echo $omdb_title_result | jq --raw-output '.Year')
edebug "omdb year is: $omdb_year_result"
edebug "Getting runtime info..."
#extract runtime from mass omdb result
omdb_runtime_result=$(echo $omdb_title_result | jq --raw-output '.Runtime')
#strip out 'min'
omdb_runtime_result=${omdb_runtime_result%????}
edebug "omdb runtime is (mins): $omdb_runtime_result ..."
edebug "...converting to hh:mm:ss"
omdb_runtime_result=$((omdb_runtime_result*60))
secs=$omdb_runtime_result
omdb_runtime_result=$(convert_secs_hr_min)
edebug "omdb runtime in hh:mm:ss format is: $omdb_runtime_result"
#
#START ARRAY WORK TO ANALYSE TRACK TIMES AND ROUND UP SO AS TO COMPART TO OMDB TIMES
track_times_array=()
array_matching_track=()
#find all results matching MPLS in all_titles_scan.json and save the time from the line afterwards...
#...remove all blank lines and those with -- in them and save result list to grepped_times file
grep -A 1 MPLS all_titles_scan.json | cut -d ' ' -f 5 | cut -d ' ' -f 1 | awk 'NF' | sed '/--/d' > grepped_times
#remove last line of file (auto_found_main_features time)
sed -i '$d' grepped_times
#remove last line of file (auto_found_main_features title)
sed -i '$d' grepped_times
#read in grepped file to array
mapfile -t track_times_array <grepped_times
#time conversion work in array
for ((i=0; i<${#track_times_array[@]}; i++)); do
#TRACK DETAILS
track_num=$((i+1))
edebug "Running time of track $track_num is: ${track_times_array[$i]}"
#
#SECONDS
track_secs_old=$(echo ${track_times_array[$i]} | cut -d ':' -f 3)
#remove padding zeros to reduce 'base 8 errors'
#track_secs_new=${track_secs_old##+(0)}
track_secs_new=${track_secs_old#0}
if [[ $track_secs_new -ge 31 ]]; then
edebug "rounding up seconds"
track_secs_new=0
inc_mins=1
else
inc_mins=
fi
track_secs_new=$(printf "%02d\n" $track_secs_new)
edebug "seconds = $track_secs_new"
#
#MINS
track_mins_old=$(echo ${track_times_array[$i]} | cut -d ':' -f 2)
#remove padding zeros to reduce 'base 8 errors'
track_mins_new=${track_mins_old#0}
edebug "track_mins being used are: $track_mins_new"
if [[ ! -z $inc_mins ]]; then
edebug "track_mins_new before rounding = $track_mins_new"
track_mins_new=$((track_mins_new+1))
edebug "track_mins after rounding = $track_mins_new"
fi
if [[ $track_mins_new -ge 59 ]]; then
edebug "rounding up minutes"
track_mins_new=0
inc_hours=1
else
inc_hours=
fi
track_mins_new=$(printf "%02d\n" $track_mins_new)
edebug "mins = $track_mins_new"
#
#HOURS
track_hours_old=$(echo ${track_times_array[$i]} | cut -d ':' -f 1)
#remove padding zeros to reduce 'base 8 errors'
#track_hours_new=${track_hours_old##+(0)}
track_hours_new=${track_hours_old#0}
if [[ ! -z $inc_hours_new ]]; then
edebug "track_hours before rounding = $track_hours_new"
track_hours_new=$((track_hours_new+1))
edebug "track_hours_new after rounding = $track_hours_new"
fi
if [[ $track_hours_new -ge 59 ]]; then
edebug "really, 60 hour film?!!!"
track_hours=0
fi
track_hours_new=$(printf "%02d\n" $track_hours_new)
edebug "hours = $track_hours_new"
#
# COMPARISON WORK
local_track_time=$(echo "$track_hours_new:$track_mins_new:$track_secs_new")
edebug "new track time is: $local_track_time"
edebug "omdb_runtime is: $omdb_runtime_result"
if [[ "$local_track_time" = "$omdb_runtime_result" ]]; then
edebug "track matched, using"
array_matching_track+=( $track_num )
else
edebug "no match"
fi
done
edebug "array_matching_track contents are: ${array_matching_track[@]}"
edebug "element 1 = ${array_matching_track[0]}"
edebug "element 2 = ${array_matching_track[1]}"
#
if [[ ${#array_matching_track[@]} -gt 0 ]]; then
if [[ ${#array_matching_track[@]} -gt 1 ]]; then
matching_track_text="Matching runtime tracks detected as:"
matching_track_list=${array_matching_track[@]}
edebug "$matching_track_text $matching_track_list"
for ((i=0, j=1; i<${#array_matching_track[@]}; i++, j++)); do
declare "title_$j"="${array_matching_track[$i]}"
edebug "title_$j is set as: $title_$j"
done
else
matching_track_text="Matching runtime track detected as:"
matching_track_list=${array_matching_track[@]}
edebug "$matching_track_text $dts_track_list"
for ((i=0, j=1; i<${#array_matching_track[@]}; i++, j++)); do
declare "title_$j"="${array_matching_track[$i]}"
edebug "title_$j is set as: $title_$j"
done
fi
else
edebug "No title track matching runtime found"
matching_track_list=
fi
#
elif [[ "$omdb_title_result" = *'"Error":"No API key provided."'* ]]; then
edebug "online search failed not doing extra stuff"
omdb_title_result=
elif [[ "$omdb_title_result" = *'"Error":"Incorrect IMDb ID."'* ]]; then
edebug "omdb search ran but no matching result could be found"
omdb_title_result=
elif [[ "$omdb_title_result" = *'"Error":"Movie not found!"'* ]]; then
edebug "omdb search ran but no matching result could be found"
omdb_title_result=
elif [[ "$omdb_title_result" = *'</html>nter>cloudflare</center>></center>d>'* ]]; then
edebug "omdb search ran but no matching result could be found"
omdb_title_result=
else
edebug "Some other error occured, dumping omdb_title_result"
edebug "omdb_title_result is: $omdb_title_result"
omdb_title_result=
fi
#
#TEST RESULTS TO SEE WHICH TO CHOOSE AND IF DIFFERENT TO OUT AUTO FIND TITLE WE NEED TO RECREATE main_feature_scan.json BEFORE AUDIO CHECK
if [[ -z "$title_1" ]] && [[ -z "$title_2" ]]; then
edebug "no online data to use, so using local data"
elif [[ ! -z "$title_1" ]] && [[ ! -z "$title_2" ]]; then
enotify "online check resulted in both titles (title_1: $title_1 & title_2: $title_2) matching handbrakes automatically found main feature: $auto_found_main_feature. Using title_2"
#we choose title 2 when there are 2 detected as this better than 50% right most of the time imo.
mv main_feature_scan.json main_feature_scan.json.original
auto_found_main_feature=$(echo $title_2)
HandBrakeCLI --json -i $source_loc -t $auto_found_main_feature --scan 1> main_feature_scan.json 2> /dev/null
clean_main_feature_scan
elif [[ -z "$title_1" ]] && [[ ! -z "$title_2" ]]; then #title 1 doesnt match but title 2 does, use it.
edebug "online check resulted in title_2, matching handbrakes automatically found main feature $auto_found_main_feature, using title_2"
mv main_feature_scan.json main_feature_scan.json.original
auto_found_main_feature=$(echo $title_2)
HandBrakeCLI --json -i $source_loc -t $auto_found_main_feature --scan 1> main_feature_scan.json 2> /dev/null
clean_main_feature_scan
elif [[ ! -z "$title_1" ]] && [[ -z "$title_2" ]]; then
#then title 1 is set but if $title_2 is valid $title_2 is set
edebug "online check resulted in only title_1: $title_1 matching handbrakes automatically found main feature, so using"
fi
#
#EXTRACT AUDIO TRACKS FROM $main_feature_scan_trimmed into parsed_audio_tracks
jq '.[].TitleList[].AudioList[].Description' main_feature_scan_trimmed.json > parsed_audio_tracks
#
#+----------------------------------+
#+---"Determine Availiable Audio"---+
#+----------------------------------+
#First we search the file for the line number of our preferred source because line number = track number of the audio
#these tests produce boolean returns
#
#set up arrays we will use
bdlpcm_array=()
truehd_array=()
dtshd_array=()
dts_array=()
ac3_51_array=()
ac3_array=()
#read file into the array
mapfile -t parsed_audio_array <parsed_audio_tracks
#show ray array contents once read in from file
edebug "array contents are: ${parsed_audio_array[@]}"
#for each array entry search for specific set text, if found add that entry to relevant array defined above
for ((i=0; i<${#parsed_audio_array[@]}; i++)); do
#"(BD LPCM)"
if [[ ${parsed_audio_array[$i]} =~ (^|[[:space:]])"(BD LPCM)"($|[[:space:]]) ]]; then
bdlpcm_track[i]=$((i+1))
edebug "Bluray uncompressed LPCM detected at element $i, audio track: ${bdlpcm_track[i]}"
bdlpcm_array+=( ${bdlpcm_track[i]} )
fi
#"(TrueHD)"
if [[ ${parsed_audio_array[$i]} =~ (^|[[:space:]])"(TrueHD)"($|[[:space:]]) ]]; then
truehd_track[i]=$((i+1))
edebug "TrueHD detected at element $i, audio track: ${truehd_track[i]}"
truehd_array+=( ${truehd_track[i]} )
fi
#"(DTS-HD MA)"
if [[ ${parsed_audio_array[$i]} =~ (^|[[:space:]])"(DTS-HD"[[:space:]]"MA)"($|[[:space:]]) ]]; then
dtshd_track[i]=$((i+1))
edebug "DTS-HD detected at element $i, audio track: ${dtshd_track[i]}"
dtshd_array+=( ${dtshd_track[i]} )
fi
#"(DTS)"
if [[ ${parsed_audio_array[$i]} =~ (^|[[:space:]])"(DTS)"($|[[:space:]]) ]]; then
dts_track[i]=$((i+1))
edebug "DTS detected at element $i, audio track: ${dts_track[i]}"
dts_array+=( ${dts_track[i]} )
fi
#"(AC3) (5.1"
if [[ ${parsed_audio_array[$i]} =~ (^|[[:space:]])"(AC3)"[[:space:]]"(5.1"($|[[:space:]]) ]]; then
ac3_51_track[i]=$((i+1))
edebug "AC3 5.1 detected at element $i, audio track: ${ac3_51_track[i]}"
ac3_51_array+=( ${ac3_51_track[i]} )
fi
if [[ ${parsed_audio_array[$i]} =~ (^|[[:space:]])"(AC3)"[[:space:]]"(2.0"($|[[:space:]]) ]]; then
ac3_track[i]=$((i+1))
edebug "AC3 2.0 detected at element $i, audio track: ${ac3_track[i]}"
ac3_array+=( ${ac3_track[i]} )
fi
done
#
#construct messaging text and set *audio_track_list. If more than one entry seperate them by ', '
#so they will be format required by handbrake for multiple tracks, set variable single value or to empty if no tracks found.
#"*BD LPCM*"
if [[ ${#bdlpcm_array[@]} -gt 0 ]]; then
if [[ ${#bdlpcm_array[@]} -gt 1 ]]; then
bdlpcm_text="tracks:"
bdlpcm_track_list=${bdlpcm_array[@]}
bdlpcm_track_list=${bdlpcm_track_list// /,}
edebug "BD LPCM detected on $bdlpcm_text $bdlpcm_track_list"
else
bdlpcm_text="BD LPCM detected on track:"
bdlpcm_track_list=${bdlpcm_array[@]}
edebug "BD LPCM detected on $bdlpcm_text $bdlpcm_track_list"
fi
else
edebug "NO BD LPCM tracks detected"
bdlpcm_track_list=
fi
#
#"*TrueHD*"
if [[ ${#truehd_array[@]} -gt 0 ]]; then
if [[ ${#truehd_array[@]} -gt 1 ]]; then
truehd_text="tracks:"
truehd_track_list=${truehd_array[@]}
truehd_track_list=${truehd_track_list// /,}
edebug "TrueHD detected on $truehd_text $truehd_track_list"
else
truehd_text="track:"
truehd_track_list=${truehd_array[@]}
edebug "TrueHD detected on $truehd_text $truehd_track_list"
fi
else
edebug "NO TrueHD tracks detected"
dts_track_list=
fi
#
#"*DTS-HD*"
if [[ ${#dtshd_array[@]} -gt 0 ]]; then
if [[ ${#dtshd_array[@]} -gt 1 ]]; then
dtshd_text="tracks:"
dtshd_track_list=${dtshd_array[@]}
dtshd_track_list=${dtshd_track_list// /,}
edebug "DTS-HD detected on $dtshd_text $dtshd_track_list"
else
dtshd_text="track:"
dtshd_track_list=${dtshd_array[@]}
edebug "DTS-HD detected on $dtshd_text $dtshd_track_list"
fi
else
edebug "NO DTS-HD tracks detected"
dtshd_track_list=
fi
#
#"*DTS*"
if [[ ${#dts_array[@]} -gt 0 ]]; then
if [[ ${#dts_array[@]} -gt 1 ]]; then
dts_text="tracks:"
dts_track_list=${dts_array[@]}
dts_track_list=${dts_track_list// /,}
edebug "DTS detected on $dts_text $dts_track_list"
else
dts_text="track:"
dts_track_list=${dts_array[@]}
edebug "DTS detected on $dts_text $dts_track_list"
fi
else
edebug "NO DTS tracks detected"
dts_track_list=
fi
#
#"*AC3 5.1*"
if [[ ${#ac3_51_array[@]} -gt 0 ]]; then
if [[ ${#ac3_51_array[@]} -gt 1 ]]; then
ac3_51_text="tracks:"
ac3_51_track_list=${ac3_51_array[@]}
ac3_51_track_list=${ac3_51_track_list// /,}
edebug "AC3 5.1 detected on $ac3_51_text $ac3_51_track_list"
else
ac3_51_text="track:"
ac3_51_track_list=${ac3_51_array[@]}
edebug "AC3 5.1 detected on $ac3_51_text $ac3_51_track_list"
fi
else
edebug "NO AC3 5.1 tracks detected"
ac3_51_track_list=
fi
#
#"*AC3 2.0*"
if [[ ${#ac3_array[@]} -gt 0 ]]; then
if [[ ${#ac3_array[@]} -gt 1 ]]; then
ac3_text="tracks:"
ac3_track_list=${ac3_array[@]}
ac3_track_list=${ac3_track_list// /,}
edebug "AC3 detected on $ac3_text $ac3_track_list"
else
ac3_text="track:"
ac3_track_list=${ac3_array[@]}
edebug "AC3 detected on $ac3_text $ac3_track_list"
fi
else
edebug "NO AC3 tracks detected, error??"
ac3_track_list=
fi
#
#+------------------------------+
#+---"Determine 'Best' Audio"---+
#+------------------------------+
#Now we make some decisons about audio choices
# if its present always prefer, TrueHD; if not, DTS-HD, if not, BD LPCM; if not, DTS; if not, AC3 5.1, and if none of these AC3 2.0 track"
if [[ ! -z "$truehd_track_list" ]]; then #true = TrueHD
selected_audio_track=$truehd_track_list
edebug "Selecting True_HD audio on $truehd_text $truehd_track_list"
audio_codec="TrueHD"
elif [[ ! -z "$truehd_track_list" ]] && [[ ! -z "$dtshd_track_list" ]]; then #true false = TrueHD
selected_audio_track=$truehd_track_list
edebug "Selecting True_HD audio on $truehd_text $truehd_track_list"
audio_codec="TrueHD"
elif [[ -z "$truehd_track_list" ]] && [[ ! -z "$dtshd_track_list" ]]; then #false true = DTS-HD
selected_audio_track=$dtshd_track_list
edebug "Selecting DTS-HD audio on $dtshd_text $dtshd_track_list"
audio_codec="DTS-HD"
elif [[ ! -z "$bdlpcm_track_list" ]] && [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]]; then #true false false = BD LPCM
selected_audio_track=$bdlpcm_track_list
edebug "Selecting BD LPCM audio on $bdlpcm_text $bdlpcm_track_list"
audio_codec="FLAC"
elif [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]] && [[ -z "$bdlpcm_track_list" ]] && [[ ! -z "$dts_track_list" ]]; then #false false false true = DTS
selected_audio_track=$dts_track_list
edebug "Selecting DTS audio on $dts_text $dts_track_list"
audio_codec="DTS"
elif [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]] && [[ -z "$bdlpcm_track_list" ]] && [[ -z "$dts_track_list" ]] && [[ ! -z "$ac3_51_track_list" ]]; then #false, false, flase, false = AC3 5.1
selected_audio_track=$ac3_51_track_list
edebug "Selecting AC3 5.1 audio on $ac3_51_text $ac3_51_track_list"
audio_codec="AC-3"
elif [[ -z "$truehd_track_list" ]] && [[ -z "$dtshd_track_list" ]] && [[ -z "$bdlpcm_track_list" ]] && [[ -z "$dts_track_list" ]] && [[ -z "$ac3_51_track_list" ]]; then #false false false false false false = AC3 (default)
selected_audio_track=${ac3_array[0]}
edebug "no matches for preferred audio types, defaulting to first AC3 track: ${ac3_array[0]}"
audio_codec="AC-3"
fi
#
#insert the audio selection into the audio_options variable, something different wiht BD_lpcm if selected as cannot be passed thru
if [[ ! -z $bdlpcm_track_list ]]; then
audio_options="-a $selected_audio_track -E flac24 --mixdown 5point1"
else
audio_options="-a $selected_audio_track -E copy --audio-copy-mask dtshd,truehd,dts,flac"
fi
edebug "audio options passed to HandBrakeCLI are: $audio_options"
#
#
#+----------------------------+
#+---"Create Encoding Name"---+
#+----------------------------+
#use our found main feature from the work at the top...
source_options="-t $auto_found_main_feature"
#...but override it if override is set
if [[ ! -z "$title_override" ]]; then
source_options=-"t $title_override"
edebug "title override selected, using: $title_override"
fi
#display what the result is
edebug "source options are: $source_options"
#
#lets use our fancy name IF found online, else revert to basic
if [[ ! -z "$working_dir" ]] && [[ ! -z "$encode_dest" ]] && [[ ! -z "$category" ]] && [[ ! -z "$omdb_title_name_result" ]] && [[ ! -z "$omdb_year_result" ]] && [[ ! -z "$container_type" ]]; then
edebug "using online found movie title & year for naming"
output_loc="$working_dir/$encode_dest/$category/$omdb_title_name_result ($omdb_year_result)/"
feature_name="${omdb_title_name_result} (${omdb_year_result}) - Bluray-1080p_Proper - $audio_codec.${container_type}"
elif [[ ! -z "$working_dir" ]] && [[ ! -z "$encode_dest" ]] && [[ ! -z "$category" ]] && [[ -z "$omdb_title_result" ]] && [[ ! -z "$feature_name" ]] && [[ ! -z "$container_type" ]]; then
edebug "using local data based naming"
output_loc="$working_dir/$encode_dest/$category/$feature_name/"
feature_name="${feature_name} - Bluray-1080p_Proper - $audio_codec.${container_type}"
else
eerror "Error setting output_loc, investigation needed"
exit 64
fi
#echo "$working_dir" "$encode_dest" "$category" "$omdb_title_result" "$omdb_year_result" "$container_type"
#echo "$working_dir" "$encode_dest" "$category" "$omdb_title_result" "$feature_name" "$container_type"
# create the
edebug "output_loc is: $output_loc"
edebug "...creating output_loc if not in existance"
mkdir -p "$output_loc"
edebug "feature name is: $feature_name"
edebug "final file name construct will be: ${output_loc}${feature_name}"
#display the final full options passed to handbrake
edebug "Final HandBrakeCLI Options are: $options -i $source_loc $source_options -o ${output_loc}${feature_name} $output_options $video_options $audio_options $picture_options $filter_options $subtitle_options > $working_dir/temp/$bluray_name/handbrake.log"
#
#
#+--------------------------+
#+---"Carry Out Encoding"---+
#+--------------------------+
# Set out how to get information for progress bar, see notes in helper_script.sh
#
if [[ -z $rip_only ]]; then
get_max_progress () {
echo 100
}
#
get_total_progress () {
#We use this variable in this instance as we need to manipulate the output so interger and no leading zero. eg. '1' no '01'
#tot_progress_result=$(grep '"Progress":' "$working_dir/temp/$bluray_name"/handbrake.log | tail -1 | cut -d '.' -f 2 | cut -d ',' -f 1 | cut -c-2)
tot_progress_result=$(grep -a "Progress: {" -A 8 handbrake.log | grep '"WORKING"' -A 7 | grep '"Progress"' | tail -1 | cut -d '.' -f 2 | cut -d ',' -f 1 | cut -c-2)
tot_progress_result=$((10#$tot_progress_result))
echo $tot_progress_result
}
esilent "${colbor}Encoding started...${colrst}"
#HandBrakeCLI $options -i $source_loc $source_options -o $output_loc $output_options $video_options $audio_options $picture_options $filter_options $subtitle_options > /dev/null 2>&1 &
unit_of_measure="percent"
HandBrakeCLI $options -i $source_loc $source_options -o "${output_loc}${feature_name}" $output_options $video_options $audio_options $picture_options $filter_options $subtitle_options > "$working_dir"/temp/"$bluray_name"/handbrake.log 2>&1 &
handbrake_pid=$!
edebug "handbrake_pid: $handbrake_pid"
pid_name=$handbrake_pid
edebug "pid name: $pid_name"
sleep 10s # to give time file to be created and data being inputted
if [[ -z $bar_override ]]; then
progress_bar2_init
#check for any non zero errors
if [ $? -eq 0 ]; then
edebug "...handbrake conversion of: $bluray_name complete."
else
eerror "...handbrake produced an error, code: $?"
exit 66
fi
else
edebug "progress bars overriden"
wait $handbrake_pid
fi
fi
also need to make sure that any trap work acknowledges this and acts as flags are set in implied....
currently only this section is avoided if -r 'rip-only' flag is set
But should it be this entire section?
also need to make sure that any trap work acknowledges this and acts as flags are set in implied....