mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-11 06:23:47 -05:00
user files now respect audio vs. video
This commit is contained in:
@@ -123,16 +123,29 @@ function outputDir() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function identifyUserFile() {
|
||||||
|
if [[ -n "${userFile}" ]]; then
|
||||||
|
#test -f "${f}" # Ensure that what we've found is a file
|
||||||
|
extension="${userFile##*.}" # Grab file extension of input file
|
||||||
|
success "We have ${userFile} with extension: $extension"
|
||||||
|
if [[ "${videoTypes[*]}" =~ "${extension}" ]]; then
|
||||||
|
userVideoFile="${userFile}"
|
||||||
|
fi
|
||||||
|
if [[ "${audioTypes[*]}" =~ "${extension}" ]]; then
|
||||||
|
userAudioFile="${userFile}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
convertVideo() {
|
convertVideo() {
|
||||||
if [ -n "${MEDIATYPE}" ]; then
|
if [ -n "${MEDIATYPE}" ]; then
|
||||||
videoTypes=($MEDIATYPE) # Reset the video type array to user-input, if specified
|
videoTypes=($MEDIATYPE) # Reset the video type array to user-input, if specified
|
||||||
fi
|
fi
|
||||||
for vt in "${videoTypes[@]}"; do
|
for vt in "${videoTypes[@]}"; do
|
||||||
for f in *."${vt}"; do
|
for f in *."${vt}"; do
|
||||||
if [[ -n "${userFile}" ]]; then
|
if [[ -n "${userVideoFile}" ]]; then
|
||||||
# Override the file search if user specifies a specific file from CLI.
|
# Override the file search if user specifies a specific file from CLI.
|
||||||
verbose "User specified file: "${userFile}""
|
f="${userVideoFile}"
|
||||||
f="${userFile}"
|
|
||||||
fi
|
fi
|
||||||
test -f "${f}" || continue # Ensure that what we've found is a file
|
test -f "${f}" || continue # Ensure that what we've found is a file
|
||||||
extension="${f##*.}" # Grab file extension of input file
|
extension="${f##*.}" # Grab file extension of input file
|
||||||
@@ -418,10 +431,9 @@ convertMusic() {
|
|||||||
fi
|
fi
|
||||||
for mt in "${musicTypes[@]}"; do
|
for mt in "${musicTypes[@]}"; do
|
||||||
for f in *."${mt}"; do
|
for f in *."${mt}"; do
|
||||||
if [[ -n "${userMusicFile}" ]]; then # TODO: Rewrite user video files and write function to detect user video or music
|
if [[ -n "${userAudioFile}" ]]; then # TODO: Rewrite user video files and write function to detect user video or music
|
||||||
# Override the file search if user specifies a specific file from CLI.
|
# Override the file search if user specifies a specific file from CLI.
|
||||||
verbose "User specified file: "${userMusicFile}""
|
f="${userAudioFile}"
|
||||||
f="${userFile}"
|
|
||||||
fi
|
fi
|
||||||
test -f "${f}" || continue # Ensure that what we've found is a file
|
test -f "${f}" || continue # Ensure that what we've found is a file
|
||||||
extension="${f##*.}" # Grab file extension of input file
|
extension="${f##*.}" # Grab file extension of input file
|
||||||
@@ -503,10 +515,10 @@ convertMusic() {
|
|||||||
verbose "output="${output}""
|
verbose "output="${output}""
|
||||||
|
|
||||||
# Don't convert to self if no other options set
|
# Don't convert to self if no other options set
|
||||||
if [[ -z $height && -z $width && -z $videoSize && $downsize720 == "0" && "$outputFormat" == "$extension" ]]; then
|
# if [[ -z $height && -z $width && -z $videoSize && $downsize720 == "0" && "$outputFormat" == "$extension" ]]; then
|
||||||
warning "Can't convert a '"${extension}"' to itself. Skipping all '"${extension}"' files."
|
# warning "Can't convert a '"${extension}"' to itself. Skipping all '"${extension}"' files."
|
||||||
break
|
# break
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# SET AUDIO INFORMATION
|
# SET AUDIO INFORMATION
|
||||||
# Copy audio in compatible formats. Re-encode audio when needed
|
# Copy audio in compatible formats. Re-encode audio when needed
|
||||||
@@ -595,6 +607,7 @@ convertMusic() {
|
|||||||
|
|
||||||
# Run the functions
|
# Run the functions
|
||||||
checkDependencies
|
checkDependencies
|
||||||
|
identifyUserFile
|
||||||
outputDir
|
outputDir
|
||||||
convertVideo
|
convertVideo
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user