- Add all the existing files.
This commit is contained in:
185
bin/album_convert
Executable file
185
bin/album_convert
Executable file
@@ -0,0 +1,185 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
AC_NAME="album_convert"
|
||||
AC_VERSION="$Name: album_convert-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${AC_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${AC_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-r | --resample] [-d | --downsampled_tag] <source_dir> <target_dir> [<target_format>]"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
resample="false"
|
||||
dstag="flase"
|
||||
source_dir=""
|
||||
target_dir=""
|
||||
|
||||
tmp_args=$(getopt -o ThVvrd --long test,help,version,verbose,resample,downsampled_tag -n "${AC_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Options
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
-r|--resample) resample="true"; shift;;
|
||||
-d|--downsampled_tag) dstag="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${mode}" != "exit" ]]
|
||||
then
|
||||
if [[ "${#}" != "2" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "2" ]]
|
||||
then
|
||||
echo "Not enough args!"
|
||||
else
|
||||
echo "Too many args!"
|
||||
fi
|
||||
|
||||
mode="exit"
|
||||
help_print
|
||||
else
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ "${mode}" == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ "${mode}" == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${resample}" == "true" ]]
|
||||
then
|
||||
resample_flags="-af \"aresample=out_sample_fmt=s16:out_sample_rate=44100\""
|
||||
else
|
||||
resample_flags=""
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] resample : [${resample}] downsampled_tag : [${dstag}] source_dir: [${source_dir}] target_dir: [${target_dir}]" 1>&2
|
||||
|
||||
if [[ ! -d "${target_dir}" ]]
|
||||
then
|
||||
echo "Target directory doesn't exit !"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
for file in "${source_dir}"/*@(.flac|.ogg|.mp3|.m4a|.ape|.wav)
|
||||
do
|
||||
id="$(basename "${file}" | sed -e "s/-.*//")"
|
||||
target_file="${target_dir}/${prefix}$(basename "${file}" | sed -e 's/\.[^.]*$//').flac"
|
||||
|
||||
cmd="ffmpeg -i \"${file}\" -compression_level 12 ${resample_flags} \"${target_file}\""
|
||||
exec_cmd "${cmd}"
|
||||
done
|
||||
|
||||
if [[ ${resample} == "true" ]]
|
||||
then
|
||||
for file in "${target_dir}"/*.flac
|
||||
do
|
||||
if [[ "${dstag}" == "true" ]]
|
||||
then
|
||||
tag="DESCRIPTION"
|
||||
|
||||
value="$(tag_read "${file}" "${tag}")"
|
||||
|
||||
if [[ "$( echo "${value}" | grep "Downsampled")" == "" ]]
|
||||
then
|
||||
value="${value}\nDownsampled"
|
||||
tag_delete "${file}" "${tag}"
|
||||
tag_write "${file}" "${tag}" "${value}"
|
||||
fi
|
||||
fi
|
||||
|
||||
for tag in "ALBUM" "TITLE"
|
||||
do
|
||||
value="$(tag_read "${file}" "${tag}")"
|
||||
new_value="$(echo ${value} | sed -e 's/ - HD$//')"
|
||||
|
||||
if [[ "${value}" != "${new_value}" ]]
|
||||
then
|
||||
tag_delete "${file}" "${tag}"
|
||||
tag_write "${file}" "${tag}" "${new_value}"
|
||||
fi
|
||||
done
|
||||
|
||||
cmd="mv \"${file}\" \"${file/-hd.flac/.flac}\""
|
||||
exec_cmd "${cmd}"
|
||||
done
|
||||
fi
|
||||
145
bin/album_merge
Executable file
145
bin/album_merge
Executable file
@@ -0,0 +1,145 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
AM_NAME="album_merge"
|
||||
AM_VERSION="$Name: album_merge-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${AM_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${AM_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] <source_dir> <target_dir> <album_name> <prefix>"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
source_dir=""
|
||||
target_dir=""
|
||||
album_name=""
|
||||
prefix=""
|
||||
|
||||
tmp_args=$(getopt -o ThVv --long test,help,version,verbose -n "${AM_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Options
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${mode}" != "exit" ]]
|
||||
then
|
||||
if [[ "${#}" != "4" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "4" ]]
|
||||
then
|
||||
echo "Not enough args!"
|
||||
else
|
||||
echo "Too many args!"
|
||||
fi
|
||||
|
||||
mode="exit"
|
||||
help_print
|
||||
else
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
album_name="$3"
|
||||
prefix="$4"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] source_dir: [${source_dir}] target_dir: [${target_dir}] album_name: [${album_name}] prefix: [${prefix}]" 1>&2
|
||||
|
||||
for file in "${source_dir}"/*@(.flac|.mp3)
|
||||
do
|
||||
id="$(basename $file | sed -e "s/-.*//")"
|
||||
target_file="${target_dir}/${prefix}$(basename $file)"
|
||||
|
||||
cmd="cp \"${file}\" \"${target_file}\""
|
||||
exec_cmd "${cmd}"
|
||||
|
||||
tag_delete "${target_file}" "ALBUM"
|
||||
tag_write "${target_file}" "ALBUM" "${album_name}"
|
||||
tag_delete "${target_file}" "TRACKNUMBER"
|
||||
tag_write "${target_file}" "TRACKNUMBER" "${prefix}${id}"
|
||||
done
|
||||
168
bin/album_metadata_load
Executable file
168
bin/album_metadata_load
Executable file
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
AML_NAME="album_metadata_load"
|
||||
AML_VERSION="$Name: album_metadata_load-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${AML_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${AML_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-c | --clean] <source_dir> <target_dir> <metadata_file>"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
clean="false"
|
||||
source_dir=""
|
||||
target_dir=""
|
||||
metadata_file=""
|
||||
|
||||
tmp_args=$(getopt -o ThVvc --long test,help,version,verbose,clean -n "${AML_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Options
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
-c|--clean) clean="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${mode}" != "exit" ]]
|
||||
then
|
||||
if [[ "${#}" != "3" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "3" ]]
|
||||
then
|
||||
echo "Not enough args!"
|
||||
else
|
||||
echo "Too many args!"
|
||||
fi
|
||||
|
||||
mode="exit"
|
||||
help_print
|
||||
else
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
metadata_file="$3"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] clean: [${clean}] source_dir: [${source_dir}] target_dir: [${target_dir}] metadata_file: [${metadata_file}]" 1>&2
|
||||
|
||||
tagtab_alloc
|
||||
|
||||
echo "Reading MetaData..."
|
||||
|
||||
tagtab_load "${metadata_file}" "DEFAULT"
|
||||
|
||||
nb_track=${track_id}
|
||||
echo "Nb track found: ${nb_track}"
|
||||
|
||||
|
||||
|
||||
track_id=1
|
||||
|
||||
find "${source_dir}" -maxdepth 1 -name '*.flac' -o -name '*.mp3' | sort | (
|
||||
while read track_file
|
||||
do
|
||||
# title="${tagtab["${track_id},TITLE"]}"
|
||||
tag_get title "${track_id}" "TITLE"
|
||||
|
||||
suffix="${track_file##*.}"
|
||||
target_file="$(printf "%02d" ${track_id})-${title}.${suffix}"
|
||||
target_file="$(fix_file_name "${target_file}" "")"
|
||||
target_file="${target_dir}/$(fix_file_name "${target_file}" "")"
|
||||
|
||||
echo "Copying ${track_file} into ${target_file}"
|
||||
cmd="cp \"${track_file}\" \"${target_file}\""
|
||||
exec_cmd "${cmd}"
|
||||
|
||||
|
||||
if [[ "${clean}" == "true" ]]
|
||||
then
|
||||
tag_save "${target_file}" "${track_id}" "CLEAN"
|
||||
else
|
||||
tag_save "${target_file}" "${track_id}" "NOCLEAN"
|
||||
fi
|
||||
|
||||
track_id=$((${track_id} + 1))
|
||||
done
|
||||
)
|
||||
193
bin/album_metadata_save
Executable file
193
bin/album_metadata_save
Executable file
@@ -0,0 +1,193 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
AMS_NAME="album_metadata_save"
|
||||
AMS_VERSION="$Name: album_metadata_save-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${AMS_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${AMS_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-f | --factoring] [-s | standardising] <source_dir> <metadata_file>"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
factoring="false"
|
||||
standardising="false"
|
||||
source_dir=""
|
||||
metadata_file=""
|
||||
|
||||
tmp_args=$(getopt -o ThVvfs --long test,help,version,verbose,factoring,standardising -n "${AMS_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Options
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
-f|--factoring) factoring="true"; shift;;
|
||||
-s|--standardising) standardising="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${mode}" != "exit" ]]
|
||||
then
|
||||
if [[ "${#}" != "2" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "2" ]]
|
||||
then
|
||||
echo "Not enough args!"
|
||||
else
|
||||
echo "Too many args!"
|
||||
fi
|
||||
|
||||
mode="exit"
|
||||
help_print
|
||||
else
|
||||
source_dir="$1"
|
||||
metadata_file="$2"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] factoring: [${factoring}] standardising: [${standardising}] source_dir: [${source_dir}] metadata_file: [${metadata_file}]" 1>&2
|
||||
|
||||
declare -g nb_track
|
||||
|
||||
|
||||
|
||||
find "${source_dir}" -maxdepth 1 -name '*.flac' -o -name '*.mp3' | sort | (
|
||||
|
||||
tagtab_alloc
|
||||
|
||||
while read track_file
|
||||
do
|
||||
nb_track=$((${nb_track} + 1))
|
||||
|
||||
if [[ "${factoring}" == "true" ]]
|
||||
then
|
||||
tagtab_read "${nb_track}" "${track_file}" "FACTORING"
|
||||
else
|
||||
tagtab_read "${nb_track}" "${track_file}" "NOFACTORING"
|
||||
fi
|
||||
done
|
||||
|
||||
track_id=0
|
||||
|
||||
while [[ "${track_id}" -le "${nb_track}" ]]
|
||||
do
|
||||
if [[ "${track_id}" == 0 ]]
|
||||
then
|
||||
echo "DEF"
|
||||
else
|
||||
echo "SOT"
|
||||
fi
|
||||
|
||||
if [[ "${standardising}" == "true" ]]
|
||||
then
|
||||
tagtab_dump "${track_id}" "STANDARD"
|
||||
else
|
||||
tagtab_dump "${track_id}" "PASSTHROUGH"
|
||||
fi
|
||||
|
||||
echo "EOT"
|
||||
|
||||
track_id=$((${track_id} + 1))
|
||||
done
|
||||
|
||||
echo "EOA"
|
||||
|
||||
echo 1>&2 "NB Track dumped: [${nb_track}]"
|
||||
#)
|
||||
#) >"${metadata_file}"
|
||||
) | (
|
||||
if [[ "${dry_run}" == "true" ]]
|
||||
then
|
||||
cat
|
||||
else
|
||||
tee "${metadata_file}"
|
||||
fi
|
||||
) | (
|
||||
if [[ "${verbose}" == "true" ]]
|
||||
then
|
||||
cat
|
||||
else
|
||||
cat >/dev/null
|
||||
fi
|
||||
)
|
||||
|
||||
138
bin/album_name_fix
Executable file
138
bin/album_name_fix
Executable file
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
ANF_VERSION="$Name: album_name_fix-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${ANF_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "album_name_fix [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-a <album_dir>] [-p|--music_pattern <music_pattern>] [-s|--sed_substitute_pattern <sed_substitue_pattern>]"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
album_dir="."
|
||||
music_pattern="."
|
||||
|
||||
tmp_args=$(getopt -o a:p:s:ThVv --long album_dir:,music_pattern:,sed_substitute_pattern:,test,help,version,verbose -n 'album_name_fix' -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Path options
|
||||
-a|--album_dir) shift; album_dir="$1"; shift;;
|
||||
|
||||
# Options
|
||||
-p|--music_pattern) shift; music_pattern="$1"; shift;;
|
||||
-s|--sed_substitute_pattern) shift; ssp="$1"; shift;;
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] album_dir: [${album_dir}] music_pattern: [${music_pattern}] sed_substitue_pattern: [${ssp}]" 1>&2
|
||||
|
||||
cd "${album_dir}"
|
||||
|
||||
IFS="\n"
|
||||
find . -maxdepth 1 -name '*.flac' -o -name '*.FLAC' -o -name '*.ogg' -o -name '*.OGG' -o -name '*.mp3' -o -name '*.MP3' -o -name '*.m4a' -o -name '*.M4A' -o -name '*.ape' -o -name '*.APE' -o -name '*.wav' -o -name '*.WAV' -o -name '*.mp4' -o -name '*.MP4' -o -name '*.mkv' -o -name '*.MKV' | sed -e 's/^.\///' | grep -e "${music_pattern}" | sort |
|
||||
while read track_file
|
||||
do
|
||||
IFS=" "
|
||||
new_track_file="$(fix_file_name "${track_file}" "${ssp}")"
|
||||
|
||||
if [[ "${new_track_file}" != "${track_file}" ]]
|
||||
then
|
||||
echo "Moving '${track_file}' into '${new_track_file}'..."
|
||||
if [[ "${dry_run}" != "true" ]]
|
||||
then
|
||||
mv -- "${track_file}" "${new_track_file}"
|
||||
else
|
||||
if [[ "${verbose}" == "true" ]]
|
||||
then
|
||||
echo mv -- "${track_file}" "${new_track_file}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Skiping '${track_file}'..."
|
||||
fi
|
||||
|
||||
IFS="\n"
|
||||
done
|
||||
21
bin/album_rename
Executable file
21
bin/album_rename
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$1" == "-h" ]]
|
||||
then
|
||||
echo "album_rename [-h] | <source_dir> <target_dir> <album_name>"
|
||||
exit
|
||||
fi
|
||||
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
album_name="$3"
|
||||
|
||||
for file in ${source_dir}/*.flac
|
||||
do
|
||||
target_file="${target_dir}/$(basename $file)"
|
||||
|
||||
cp "${file}" "${target_file}"
|
||||
metaflac --remove-tag=ALBUM --set-tag="ALBUM=${album_name}" "${target_file}"
|
||||
|
||||
i=$(($i+1))
|
||||
done
|
||||
146
bin/album_renum
Executable file
146
bin/album_renum
Executable file
@@ -0,0 +1,146 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
AR_NAME="album_renum"
|
||||
AR_VERSION="$Name: album_renum-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${AR_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${AR_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [ -f | --first_number <first_number>] [ -d | --number_of_digit <number_of_digit>] <source_dir> <target_dir>"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
source_dir=""
|
||||
target_dir=""
|
||||
first_number="1"
|
||||
number_of_digit="2"
|
||||
|
||||
tmp_args=$(getopt -o f:d:ThVv --long first_number:,number_of_digit:,test,help,version,verbose -n "${AR_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Options
|
||||
-f|--first_number) shift; first_number="$1"; shift;;
|
||||
-d|--number_of_digit) shift; number_of_digit="$1"; shift;;
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${#}" != "2" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "2" ]]
|
||||
then
|
||||
echo "Not enough args!"
|
||||
else
|
||||
echo "Too many args!"
|
||||
fi
|
||||
|
||||
mode="exit"
|
||||
help_print
|
||||
else
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=flase
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] source_dir: [${source_dir}] target_dir: [${target_dir}] first_number: [${first_number}] number_of_digit: [${number_of_digit}]" 1>&2
|
||||
|
||||
i="${first_number}"
|
||||
|
||||
for file in "${source_dir}"/*@(.flac|.mp3)
|
||||
do
|
||||
|
||||
j=$(printf "%0${number_of_digit}d" $i)
|
||||
target_file="${target_dir}/$(echo $(basename ${file}) | sed -e "s/^[0-9]*-/$j-/")";
|
||||
|
||||
cmd="cp \"${file}\" \"${target_file}\""
|
||||
exec_cmd "${cmd}"
|
||||
|
||||
tag_delete "${target_file}" "TRACKNUMBER"
|
||||
tag_delete "${target_file}" "DISCNUMBER"
|
||||
tag_delete "${target_file}" "DISCTOTAL"
|
||||
tag_write "${target_file}" "TRACKNUMBER" "$j"
|
||||
|
||||
i=$(($i+1))
|
||||
done
|
||||
48
bin/album_retitle
Executable file
48
bin/album_retitle
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
function fix_file_name
|
||||
{
|
||||
input="$1"
|
||||
|
||||
# echo ${input} | sed -e 's/ /_/g' -e "s/'/_/g" -e 's/_(/-/g' -e 's/)//g' -e 's/_-_/-/g' -e 's/\//_/g' | tr '[:upper:]' '[:lower:]'
|
||||
echo ${input} | sed -e 's/\(^[0-9]*\)./\1-/' -e 's/[ ,!/?]/_/g' -e 's/\[/-/g' -e 's/\]//g' -e "s/'/_/g" -e 's/(/-/g' -e 's/)//g' -e 's/__/_/g' -e 's/_\././' -e 's/_-/-/g' -e 's/--/-/g' -e 's/-_/-/g' -e 's/é/e/g' -e 's/è/e/g' -e 's/ê/e/g' -e 's/ë/e/g' -e 's/à/a/g' -e 's/[+&]/and/' -e 's/^-//' -e 's/"/_inch/' | tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
if [[ "$1" == "-h" ]]
|
||||
then
|
||||
echo "album_retitle [-h] | <source_dir> <target_dir> <title_file>"
|
||||
exit
|
||||
fi
|
||||
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
title_file="$3"
|
||||
|
||||
i=1
|
||||
|
||||
while read title
|
||||
do
|
||||
file=(${source_dir}/$(printf %02d $i)-*.@(flac|mp3))
|
||||
suffix=${file##*.}
|
||||
target_file="${target_dir}/$( fix_file_name $( fix_file_name $( fix_file_name $(printf "%02d" $i)-"${title}.${file##*.}")))"
|
||||
|
||||
echo "${target_file}: '"${title}"'"
|
||||
cp "${file}" "${target_file}"
|
||||
|
||||
case "${suffix}"
|
||||
in
|
||||
flac)
|
||||
metaflac --remove-tag=TRACKNUMBER --set-tag=TRACKNUMBER=$i --remove-tag=TITLE --set-tag=TITLE="${title}" "${target_file}"
|
||||
;;
|
||||
|
||||
mp3)
|
||||
mid3v2 -T $i -t "${title}" "${target_file}"
|
||||
;;
|
||||
esac
|
||||
|
||||
i=$(($i + 1))
|
||||
done < ${title_file}
|
||||
24
bin/album_seekpoint
Executable file
24
bin/album_seekpoint
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$1" == "-h" ]]
|
||||
then
|
||||
echo "album_seekpoint [-h] | <source_dir> <target_dir> <seek_point_delay>"
|
||||
exit
|
||||
fi
|
||||
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
seek_point_delay="$3"
|
||||
|
||||
for file in ${source_dir}/*.flac
|
||||
do
|
||||
target_file="${target_dir}/$(basename $file)"
|
||||
|
||||
if [[ "${file}" != "${target_file}" ]]
|
||||
then
|
||||
cp "${file}" "${target_file}"
|
||||
fi
|
||||
|
||||
metaflac --remove --block-type=SEEKTABLE "${target_file}"
|
||||
metaflac --add-seekpoint "${seek_point_delay}"s "${target_file}"
|
||||
done
|
||||
182
bin/music-info
Executable file
182
bin/music-info
Executable file
@@ -0,0 +1,182 @@
|
||||
#!/bin/bash
|
||||
|
||||
default_top=/opt/music/src
|
||||
|
||||
function list
|
||||
{
|
||||
type="$1"
|
||||
suffix="$2"
|
||||
|
||||
case $type in
|
||||
"track")
|
||||
find $top -type f | grep "\.${suffix}$"
|
||||
;;
|
||||
|
||||
"lp"|"ep"|"single"|"live"|"compilation"|"tribute")
|
||||
find $top -type f | grep -v -e "/child/" -e "/original_soundtrack/" -e "/various_artists/" | grep -e "/${type}/" | grep "\.${suffix}$" | sed -e 's/\/[^/]*$//' | sort -u
|
||||
;;
|
||||
|
||||
"child")
|
||||
find $top -type f | grep -e "/child/" | grep "\.${suffix}$" | sed -e 's/\/[^/]*$//' | sort -u
|
||||
;;
|
||||
|
||||
"ost")
|
||||
find $top -type f | grep -e "/original_soundtrack/" | grep "\.${suffix}$" | sed -e 's/\/[^/]*$//' | sort -u
|
||||
;;
|
||||
|
||||
"va")
|
||||
find $top -type f | grep -e "/various_artists/" | grep "\.${suffix}$" | sed -e 's/\/[^/]*$//' | sort -u
|
||||
;;
|
||||
|
||||
"us")
|
||||
find $top -type f | grep -v -e "/various_artists/" -e "/original_soundtrack/" -e "/lp/" -e "/ep/" -e "/single/" -e "/live/" -e "/compilation/" -e '/misc/' -e "/tribute/" | grep "\.${suffix}$" | sed -e 's/\/[^/]*$//' | sort -u
|
||||
;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
function count
|
||||
{
|
||||
type="$1"
|
||||
suffix="$2"
|
||||
|
||||
echo "$( list ${type} ${suffix} | wc -l)"
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [[ "$1" == "-l" ]]
|
||||
then
|
||||
mode="list"
|
||||
shift
|
||||
else
|
||||
mode="stats"
|
||||
fi
|
||||
|
||||
arg_top="$1"
|
||||
|
||||
if [[ "${arg_top}" != "" ]]
|
||||
then
|
||||
top="$(realpath ${arg_top})"
|
||||
else
|
||||
top="${default_top}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ "${mode}" == "stats" ]]
|
||||
then
|
||||
|
||||
track_flac="$(count track flac)"
|
||||
track_ogg="$(count track ogg)"
|
||||
track_mp3="$(count track mp3)"
|
||||
track_music=$((${track_flac} + ${track_ogg} + ${track_mp3}))
|
||||
|
||||
track_avi="$(count track avi)"
|
||||
track_mp4="$(count track mp4)"
|
||||
track_mkv="$(count track mkv)"
|
||||
track_video=$((${track_avi} + ${track_mp4} + ${track_mkv}))
|
||||
|
||||
track_jpg="$(count track jpg)"
|
||||
track_png="$(count track png)"
|
||||
track_picture=$((${track_jpg} + ${track_png}))
|
||||
|
||||
track_total=$((${track_music} + ${track_video} + ${track_picture}))
|
||||
|
||||
lp_flac="$(count lp flac)"
|
||||
lp_ogg="$(count lp ogg)"
|
||||
lp_mp3="$(count lp mp3)"
|
||||
lp_music=$((${lp_flac} + ${lp_ogg} + ${lp_mp3}))
|
||||
|
||||
ep_flac="$(count ep flac)"
|
||||
ep_ogg="$(count ep ogg)"
|
||||
ep_mp3="$(count ep mp3)"
|
||||
ep_music=$((${ep_flac} + ${ep_ogg} + ${ep_mp3}))
|
||||
|
||||
single_flac="$(count single flac)"
|
||||
single_ogg="$(count single ogg)"
|
||||
single_mp3="$(count single mp3)"
|
||||
single_music=$((${single_flac} + ${single_ogg} + ${single_mp3}))
|
||||
|
||||
live_flac="$(count live flac)"
|
||||
live_ogg="$(count live ogg)"
|
||||
live_mp3="$(count live mp3)"
|
||||
live_music=$((${live_flac} + ${live_ogg} + ${live_mp3}))
|
||||
|
||||
compilation_flac="$(count compilation flac)"
|
||||
compilation_ogg="$(count compilation ogg)"
|
||||
compilation_mp3="$(count compilation mp3)"
|
||||
compilation_music=$((${compilation_flac} + ${compilation_ogg} + ${compilation_mp3}))
|
||||
|
||||
tribute_flac="$(count tribute flac)"
|
||||
tribute_ogg="$(count tribute ogg)"
|
||||
tribute_mp3="$(count tribute mp3)"
|
||||
tribute_music=$((${tribute_flac} + ${tribute_ogg} + ${tribute_mp3}))
|
||||
|
||||
child_flac="$(count child flac)"
|
||||
child_ogg="$(count child ogg)"
|
||||
child_mp3="$(count child mp3)"
|
||||
child_music=$((${child_flac} + ${child_ogg} + ${child_mp3}))
|
||||
|
||||
ost_flac="$(count ost flac)"
|
||||
ost_ogg="$(count ost ogg)"
|
||||
ost_mp3="$(count ost mp3)"
|
||||
ost_music=$((${ost_flac} + ${ost_ogg} + ${ost_mp3}))
|
||||
|
||||
va_flac="$(count va flac)"
|
||||
va_ogg="$(count va ogg)"
|
||||
va_mp3="$(count va mp3)"
|
||||
va_music=$((${va_flac} + ${va_ogg} + ${va_mp3}))
|
||||
|
||||
us_flac="$(count us flac)"
|
||||
us_ogg="$(count us ogg)"
|
||||
us_mp3="$(count us mp3)"
|
||||
us_music=$((${us_flac} + ${us_ogg} + ${us_mp3}))
|
||||
|
||||
set_flac_total=$((${lp_flac} + ${ep_flac} + ${single_flac} + ${live_flac} + ${compilation_flac} + ${tribute_flac} + ${child_flac} + ${ost_flac} + ${va_flac} + ${us_flac}))
|
||||
set_ogg_total=$((${lp_ogg} + ${ep_ogg} + ${single_ogg} + ${live_ogg} + ${compilation_ogg} + ${tribute_ogg} + ${child_ogg} + ${ost_ogg} + ${va_ogg} + ${us_ogg}))
|
||||
set_mp3_total=$((${lp_mp3} + ${ep_mp3} + ${single_mp3} + ${live_mp3} + ${compilation_mp3} + ${tribute_mp3} + ${child_mp3} + ${ost_mp3} + ${va_mp3} + ${us_mp3}))
|
||||
set_total=$((${lp_music} + ${ep_music} + ${single_music} + ${live_music} + ${compilation_music} + ${tribute_music} + ${child_music} + ${ost_music} + ${va_music} + ${us_music}))
|
||||
|
||||
echo "Music Statistics from ${top}:"
|
||||
echo "Tracks:"
|
||||
printf "Music: Flac: %5s OGG: %5s MP3: %5s Total: %6s\n" ${track_flac} ${track_ogg} ${track_mp3} ${track_music}
|
||||
printf "Video: AVI: %5s mp4: %5s MKV: %5s Total: %6s\n" ${track_avi} ${track_mp4} ${track_mkv} ${track_video}
|
||||
printf "Picture: JPG: %5s PNG: %5s %5s Total: %6s\n" ${track_jpg} ${track_png} "" ${track_picture}
|
||||
printf " %5s %5s %5s Total: %6s\n" "" "" "" ${track_total}
|
||||
|
||||
echo ""
|
||||
echo "Album | Flac | OGG | MP3 || Total"
|
||||
echo "---------+-------+-------+-------++------"
|
||||
printf "LP | %5s | %5s | %5s || %5s\n" ${lp_flac} ${lp_ogg} ${lp_mp3} ${lp_music}
|
||||
printf "EP | %5s | %5s | %5s || %5s\n" ${ep_flac} ${ep_ogg} ${ep_mp3} ${ep_music}
|
||||
printf "Single | %5s | %5s | %5s || %5s\n" ${single_flac} ${single_ogg} ${single_mp3} ${single_music}
|
||||
printf "Live | %5s | %5s | %5s || %5s\n" ${live_flac} ${live_ogg} ${live_mp3} ${live_music}
|
||||
printf "Compil | %5s | %5s | %5s || %5s\n" ${compilation_flac} ${compilation_ogg} ${compilation_mp3} ${compilation_music}
|
||||
printf "Tribute | %5s | %5s | %5s || %5s\n" ${tribute_flac} ${tribute_ogg} ${tribute_mp3} ${tribute_music}
|
||||
printf "Child | %5s | %5s | %5s || %5s\n" ${child_flac} ${child_ogg} ${child_mp3} ${child_music}
|
||||
printf "OST | %5s | %5s | %5s || %5s\n" ${ost_flac} ${ost_ogg} ${ost_mp3} ${ost_music}
|
||||
printf "VA | %5s | %5s | %5s || %5s\n" ${va_flac} ${va_ogg} ${va_mp3} ${va_music}
|
||||
printf "UnSorted | %5s | %5s | %5s || %5s\n" ${us_flac} ${us_ogg} ${us_mp3} ${us_music}
|
||||
echo "---------+-------+-------+-------++------"
|
||||
printf "Total | %5s | %5s | %5s || %5s\n" ${set_flac_total} ${set_ogg_total} ${set_mp3_total} ${set_total}
|
||||
|
||||
else
|
||||
|
||||
for suffix in flac ogg mp3 avi mp4 mkv jpg png
|
||||
do
|
||||
echo "Track ${suffix}:"
|
||||
list track ${suffix} | sed -e "s/^/track /"
|
||||
echo
|
||||
done
|
||||
|
||||
for type in lp ep single live compilation tribute va ost us
|
||||
do
|
||||
for suffix in flac ogg mp3
|
||||
do
|
||||
echo "Set ${type} ${suffix}:"
|
||||
list ${type} ${suffix} | sed -e "s/^/${type} /"
|
||||
echo
|
||||
done
|
||||
done
|
||||
fi
|
||||
19
bin/music_check
Executable file
19
bin/music_check
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
i=1
|
||||
|
||||
for file in $(find /opt/music/src -name '*.flac' | sort)
|
||||
do
|
||||
echo -ne "\r \r"
|
||||
|
||||
printf "%05d: " $i; echo -n "${file}: "
|
||||
flac --test "${file}" >/dev/null 2>&1
|
||||
|
||||
if [[ "$?" == "0" ]]
|
||||
then
|
||||
echo -n "OK"
|
||||
else echo "KO"
|
||||
fi
|
||||
|
||||
i=$(($i+1))
|
||||
done
|
||||
158
bin/music_folder_make
Executable file
158
bin/music_folder_make
Executable file
@@ -0,0 +1,158 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
MFM_NAME="music_folder_make"
|
||||
MFM_VERSION="$Name: music_mk_folder-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${MFM_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${MFM_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-p | --music_pattern <music_pattern>] [-r | --root_dir <music_root_dir>]"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
root_dir="/opt/music/src"
|
||||
music_pattern="/"
|
||||
|
||||
tmp_args=$(getopt -o r:p:ThVv --long root_dir:,music_pattern:,test,help,version,verbose -n "${MFM_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Path options
|
||||
-r|--root_dir) shift; root_dir="$1"; shift;;
|
||||
|
||||
# Options
|
||||
-p|--music_pattern) shift; music_pattern="$1"; shift;;
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] root_dir: [${root_dir}] music_pattern: [${music_pattern}]" 1>&2
|
||||
|
||||
find ${root_dir} -type d -links 2 | grep -e "${music_pattern}" | grep -v -e "/video" -e "/photo" | sort | (
|
||||
while read dir
|
||||
do
|
||||
if [[ $(basename ${dir}) == "misc" ]]
|
||||
then
|
||||
line_echo "${dir}: Misc\r" "${i}"
|
||||
else
|
||||
|
||||
src=""
|
||||
dst="${dir}/folder.jpg"
|
||||
|
||||
for file in ${dir}/cover-front ${dir}/slipcase-front ${dir}/box-front
|
||||
do
|
||||
for suffix in png jpg
|
||||
do
|
||||
if [[ "${src}" == "" ]]
|
||||
then
|
||||
if [[ -f "${file}.${suffix}" ]]
|
||||
then
|
||||
src="${file}.${suffix}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [[ "${src}" == "" ]]
|
||||
then
|
||||
line_echo "${dir}: BAD!\n" "${i}"
|
||||
else
|
||||
if [[ ( -f "${dst}") && ( -s "${dst}") && ( "${dst}" -nt "${src}") ]]
|
||||
then
|
||||
line_echo "${dir}: Skipping\r" "${i}"
|
||||
else
|
||||
line_echo "${dir}: Processing...\n" "${i}"
|
||||
|
||||
cmd="anytopnm \"${src}\" | pamscale -xyfit 1024 1024 | pnmtojpeg -quality=95 -optimize >\"${dst}\""
|
||||
exec_cmd "${cmd}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
i=$(($i + 1))
|
||||
done
|
||||
|
||||
line_echo ""
|
||||
)
|
||||
195
bin/music_tag_cleanner
Executable file
195
bin/music_tag_cleanner
Executable file
@@ -0,0 +1,195 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/global/lib/music.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# System Constants
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
MTC_NAME="music_tag_cleaner"
|
||||
MTC_VERSION="$Name: music_tag_cleaner-1_0_0-1 $"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function version_print()
|
||||
{
|
||||
echo ${MTC_VERSION} | sed -e 's/.*: //' -e 's/-/ /' -e 's/_/\./g' -e 's/\$$//'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Prin Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function help_print()
|
||||
{
|
||||
echo "${MTC_NAME} [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-f | --fix_missing_album_artist] [-a | --default_artist <default_artist>] [-p | --music_pattern <music_pattern>] [-r | --root_dir <music_root_dir>]"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
fix_maa="false"
|
||||
default_artist=""
|
||||
root_dir="/opt/music/src"
|
||||
music_pattern="/"
|
||||
|
||||
tmp_args=$(getopt -o r:p:a:ThVvf --long root_dir:,music_pattern:,default_artist,test,help,version,verbose,fix_missing_album_artist -n "${MTC_NAME}" -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
# Path options
|
||||
-r|--root_dir) shift; root_dir="$1"; shift;;
|
||||
|
||||
# Options
|
||||
-a|--default_artist) shift; default_artist="$1"; shift;;
|
||||
-p|--music_pattern) shift; music_pattern="$1"; shift;;
|
||||
|
||||
# Mode switches
|
||||
-T|--test) mode="test"; shift;;
|
||||
-h|--help) mode="exit"; help_print; shift;;
|
||||
-V|--version) mode="exit"; version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-f|--fix_missing_album_artist) fix_maa="true"; shift;;
|
||||
-v|--verbose) verbose="true"; shift;;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
args_parse "$@"
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ ${mode} == "test" ]]
|
||||
then
|
||||
dry_run=true
|
||||
else
|
||||
dry_run=false
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "mode: [${mode}] verbose: [${verbose}] root_dir: [${root_dir}] music_pattern: [${music_pattern}] fix_maa: [${fix_maa}] default_artist: [${default_artist}]" 1>&2
|
||||
|
||||
i=1
|
||||
|
||||
find "${root_dir}" -name '*.flac' -o -name '*.mp3' | grep -e "${music_pattern}" | sort |
|
||||
while read track_file
|
||||
do
|
||||
tagtab_alloc
|
||||
|
||||
tagtab_read "0" "${track_file}" "DEFAULT"
|
||||
|
||||
for tag in DISCTOTAL DISCNUMBER
|
||||
do
|
||||
if [[ "$(echo ${taglist} | grep -e ":${tag}:")" != "" ]]
|
||||
then
|
||||
line_echo "${track_file}: Cleaning '${tag}' Tag...\n" "${i}"
|
||||
tag_delete "${track_file}" "${tag}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$(tag_exist "ALBUM ARTIST")" != "" ]]
|
||||
then
|
||||
if [[ "$(tag_exist "ALBUMARTIST")" == "" ]]
|
||||
then
|
||||
line_echo "${track_file}: Copying 'ALBUM ARTIST' into 'ALBUMARTIST' Tag...\n" "${i}"
|
||||
tag_write "${track_file}" "ALBUMARTIST" "${tagtab["0,ALBUM ARTIST"]}"
|
||||
fi
|
||||
|
||||
line_echo "${track_file}: Cleaning 'ALBUM ARTIST' Tag...\n" "${i}"
|
||||
tag_delete "${track_file}" "ALBUM ARTIST"
|
||||
else
|
||||
if [[ "$(tag_exist "ALBUMARTIST")" == "" ]]
|
||||
then
|
||||
line_echo "${track_file}: Missing 'ALBUMARTIST' and 'ALBUM ARTIST' Tag...\n" "${i}"
|
||||
|
||||
if [[ ( "${fix_maa}" == "true") ]]
|
||||
then
|
||||
if [[ "${default_artist}" != "" ]]
|
||||
then
|
||||
artist=${default_artist}
|
||||
else
|
||||
album_type=$(album_type_get "${track_file}")
|
||||
|
||||
if [[ "/various_artists/tribute/original_soundtrack/child/" == */${album_type}/* ]]
|
||||
then
|
||||
artist="Various Artists"
|
||||
else
|
||||
if [[ "$(tag_exist "ARTIST")" == "" ]]
|
||||
then
|
||||
line_echo "${track_file}: Warning: Missing 'ARTIST' Tag...\n" "${i}"
|
||||
else
|
||||
artist="${tagtab["0,ARTIST"]}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${artist}" != "" ]]
|
||||
then
|
||||
line_echo "${track_file}: Copying '${artist}' into 'ALBUMARTIST' Tag...\n" "${i}"
|
||||
tag_write "${track_file}" "ALBUMARTIST" "${artist}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${track_file##*.}" == "flac" ]]
|
||||
then
|
||||
if [[ "$(file ${track_file} | grep ID3 )" != "" ]]
|
||||
then
|
||||
line_echo "${track_file}: Cleaning Flac ID3 Tags...\n" "${i}"
|
||||
tag_all_delete ${track_file} "id3"
|
||||
fi
|
||||
fi
|
||||
|
||||
line_echo "${track_file}: OK\r" "${i}"
|
||||
|
||||
i=$(($i + 1))
|
||||
done
|
||||
|
||||
line_echo ""
|
||||
|
||||
Reference in New Issue
Block a user