- Migrate album_seekpoint & music_check,
- Add album_seekpoint & music_check completion script.
This commit is contained in:
@@ -1,24 +1,184 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Album SeekPoint
|
||||
#
|
||||
# Copyright (C) 2016-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "$1" == "-h" ]]
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
|
||||
. "${RX3_LIB_DIR}/music_tools.bash"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
declare -g VERSION="1.0.0"
|
||||
declare -g NAME="album_seekpoint"
|
||||
declare -g HELP="usage: [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] <source_dir> <target_dir> <seek_point_delay>"
|
||||
|
||||
declare -g SOURCE_DIR=""
|
||||
declare -g TARGET_DIR=""
|
||||
declare -g SEEK_POINT_DELAY=""
|
||||
|
||||
declare -g MODE="DEFAULT"
|
||||
declare -g VERBOSE="FALSE"
|
||||
declare -g DRY_RUN="FALSE"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Version Print
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
as_version_print()
|
||||
{
|
||||
version_print
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Help Print
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
as_help_print()
|
||||
{
|
||||
as_version_print
|
||||
help_print
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
as_args_parse()
|
||||
{
|
||||
tmp_args=$(getopt -o ThVv --long test,help,version,verbose -n "${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"; as_help_print; shift;;
|
||||
-V|--version) MODE="EXIT"; as_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 [[ "${#}" != "3" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "3" ]]
|
||||
then
|
||||
echo_error "Not enough args!"
|
||||
else
|
||||
echo_error "Too many args!"
|
||||
fi
|
||||
|
||||
MODE="EXIT"
|
||||
as_help_print
|
||||
else
|
||||
SOURCE_DIR="$1"
|
||||
TARGET_DIR="$2"
|
||||
SEEK_POINT_DELAY="$3"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
as_args_parse "$@"
|
||||
|
||||
|
||||
|
||||
if [[ "${MODE}" == "EXIT" ]]
|
||||
then
|
||||
echo "album_seekpoint [-h] | <source_dir> <target_dir> <seek_point_delay>"
|
||||
exit
|
||||
exit 0
|
||||
else
|
||||
if [[ "${MODE}" == "TEST" ]]
|
||||
then
|
||||
DRY_RUN="TRUE"
|
||||
fi
|
||||
fi
|
||||
|
||||
source_dir="$1"
|
||||
target_dir="$2"
|
||||
seek_point_delay="$3"
|
||||
|
||||
for file in ${source_dir}/*.flac
|
||||
echo_error "${NAME}: Mode: [${MODE}] Verbose: [${VERBOSE}] Source_Dir: [${SOURCE_DIR}] Target_Dir: [${TARGET_DIR}] Seek_Point_Delay: [${SEEK_POINT_DELAY}]"
|
||||
|
||||
if [[ ! -d "${TARGET_DIR}" ]]
|
||||
then
|
||||
echo_error "Target directory doesn't exist!"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
for file in "${SOURCE_DIR}"/*@(.flac)
|
||||
do
|
||||
target_file="${target_dir}/$(basename $file)"
|
||||
id="$(basename "${file}" | sed -e "s/-.*//")"
|
||||
target_file="${TARGET_DIR}/$(basename "${file}")"
|
||||
|
||||
if [[ "${file}" != "${target_file}" ]]
|
||||
then
|
||||
cp "${file}" "${target_file}"
|
||||
fi
|
||||
if [[ "${file}" != "${target_file}" ]]
|
||||
then
|
||||
cmd_exec cp "${file}" "${target_file}"
|
||||
fi
|
||||
|
||||
metaflac --remove --block-type=SEEKTABLE "${target_file}"
|
||||
metaflac --add-seekpoint "${seek_point_delay}"s "${target_file}"
|
||||
cmd_exec metaflac --remove --block-type=SEEKTABLE "${target_file}"
|
||||
cmd_exec metaflac --add-seekpoint "${SEEK_POINT_DELAY}s" "${target_file}"
|
||||
done
|
||||
|
||||
192
bin/music_check
192
bin/music_check
@@ -1,19 +1,183 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Music Check
|
||||
#
|
||||
# Copyright (C) 2016-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
|
||||
. "${RX3_LIB_DIR}/music_tools.bash"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
declare -g VERSION="1.0.0"
|
||||
declare -g NAME="music_check"
|
||||
declare -g HELP="usage: [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] <source_dir>"
|
||||
|
||||
declare -g SOURCE_DIR=""
|
||||
|
||||
declare -g MODE="DEFAULT"
|
||||
declare -g VERBOSE="FALSE"
|
||||
declare -g DRY_RUN="FALSE"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Version Print
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
mc_version_print()
|
||||
{
|
||||
version_print
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Help Print
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
mc_help_print()
|
||||
{
|
||||
mc_version_print
|
||||
help_print
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
mc_args_parse()
|
||||
{
|
||||
tmp_args=$(getopt -o ThVv --long test,help,version,verbose -n "${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"; mc_help_print; shift;;
|
||||
-V|--version) MODE="EXIT"; mc_version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-v|--verbose) VERBOSE="TRUE"; shift;;
|
||||
|
||||
# End of options
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${MODE}" != "EXIT" ]]
|
||||
then
|
||||
if [[ "${#}" != "1" ]]
|
||||
then
|
||||
if [[ "${#}" -lt "1" ]]
|
||||
then
|
||||
echo_error "Not enough args!"
|
||||
else
|
||||
echo_error "Too many args!"
|
||||
fi
|
||||
|
||||
MODE="EXIT"
|
||||
mc_help_print
|
||||
else
|
||||
SOURCE_DIR="$1"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
mc_args_parse "$@"
|
||||
|
||||
|
||||
|
||||
if [[ "${MODE}" == "EXIT" ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
if [[ "${MODE}" == "TEST" ]]
|
||||
then
|
||||
DRY_RUN="TRUE"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo_error "${NAME}: Mode: [${MODE}] Verbose: [${VERBOSE}] Source_Dir: [${SOURCE_DIR}]"
|
||||
|
||||
if [[ ! -d "${SOURCE_DIR}" ]]
|
||||
then
|
||||
echo_error "Source directory doesn't exist!"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
i=1
|
||||
|
||||
for file in $(find /opt/music/src -name '*.flac' | sort)
|
||||
find "${SOURCE_DIR}" -name '*.flac' -print0 | sort -z | while IFS= read -r -d '' file
|
||||
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
|
||||
echo_line "${file}: " "${i}"
|
||||
cmd_exec flac --test "${file}" >/dev/null 2>&1
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "KO"
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
|
||||
|
||||
|
||||
95
etc/bash_completion.d/album_seekpoint
Normal file
95
etc/bash_completion.d/album_seekpoint
Normal file
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Album SeekPoint Bash Completion
|
||||
#
|
||||
# Copyright (C) 2016-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Album SeekPoint Completion
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
_album_seekpoint_completion()
|
||||
{
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local opts="-h --help -V --version -T --test -v --verbose"
|
||||
|
||||
local pos=0
|
||||
local i
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
# Complete options if current word starts with '-'
|
||||
if [[ "${cur}" == -* ]]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Count non-option positional arguments already provided
|
||||
for (( i=1; i<COMP_CWORD; i++ ))
|
||||
do
|
||||
case "${COMP_WORDS[i]}" in
|
||||
-T|--test|-h|--help|-V|--version|-v|--verbose)
|
||||
;;
|
||||
|
||||
--)
|
||||
;;
|
||||
|
||||
-*)
|
||||
;;
|
||||
|
||||
*)
|
||||
pos=$(( pos + 1 ))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Complete positional arguments
|
||||
case "${pos}" in
|
||||
0)
|
||||
# source_dir: directory completion
|
||||
COMPREPLY=( $(compgen -d -- "${cur}") )
|
||||
;;
|
||||
|
||||
1)
|
||||
# target_dir: directory completion
|
||||
COMPREPLY=( $(compgen -d -- "${cur}") )
|
||||
;;
|
||||
|
||||
2)
|
||||
# seek_point_delay: no completion
|
||||
COMPREPLY=()
|
||||
;;
|
||||
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
complete -o filenames -F _album_seekpoint_completion album_seekpoint
|
||||
85
etc/bash_completion.d/music_check
Normal file
85
etc/bash_completion.d/music_check
Normal file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Music Check Bash Completion
|
||||
#
|
||||
# Copyright (C) 2016-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Music Check Completion
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
_music_check_completion()
|
||||
{
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
local opts="-h --help -V --version -T --test -v --verbose"
|
||||
|
||||
local pos=0
|
||||
local i
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
# Complete options if current word starts with '-'
|
||||
if [[ "${cur}" == -* ]]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Count non-option positional arguments already provided
|
||||
for (( i=1; i<COMP_CWORD; i++ ))
|
||||
do
|
||||
case "${COMP_WORDS[i]}" in
|
||||
-T|--test|-h|--help|-V|--version|-v|--verbose)
|
||||
;;
|
||||
|
||||
--)
|
||||
;;
|
||||
|
||||
-*)
|
||||
;;
|
||||
|
||||
*)
|
||||
pos=$(( pos + 1 ))
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Complete positional arguments
|
||||
case "${pos}" in
|
||||
0)
|
||||
# source_dir: directory completion
|
||||
COMPREPLY=( $(compgen -d -- "${cur}") )
|
||||
;;
|
||||
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
complete -o filenames -F _music_check_completion music_check
|
||||
Reference in New Issue
Block a user