/usr/bin/dir2vclt is in vclt-tools 0.1.4-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | #!/bin/bash
# Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2012
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3
# as published by the Free Software Foundation.
#
# It 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 software; see the file COPYING.gplv3. If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# The next two will be filled later.
DIR="";
OUT="";
MODE_FIND='ext';
MODE_TYPE='guess';
MODE_PATH='keep';
METADATA=true;
LENGTH=true;
CMD_VORBISCOMMENT='vorbiscomment';
CMD_OGGZ_COMMENT='oggz-comment';
CMD_OGGZ_INFO='oggzinfo';
CMD_METAFLAC='metaflac';
CMD_RAUM_INFO='raum-info';
CMD_ID3TOOL='id3tool';
CMD_MP32VCLT='mp32vclt';
CMD_METAFLAC2TIME='metaflac2time';
CMD_TEMPFILE='tempfile'
EXTS='ogg mp3 wav flac spx oga raum mid midi aac opus';
export NX_COMMANDS='';
PACKAGE_LIST=''
PACKAGE_INSTALL_COMMAND='';
# WARNING:
# This is a a big hack. Do not try this at home!
# Passing by tempfile is done as bash does not allow
# to modify vars in error handlers in non-local way.
_isinnx() {
echo " $NX_COMMANDS " | if grep " $1 " 2> /dev/null > /dev/null
then
return 0
else
return 1
fi
}
on_startup() {
NX_COMMANDS_FILE=`$CMD_TEMPFILE`
}
on_exit() {
NX_COMMANDS=`cat "$NX_COMMANDS_FILE"`
rm -f "$NX_COMMANDS_FILE" 2> /dev/null
if [ "$NX_COMMANDS" != '' ]
then
{
echo
echo 'Warning: The following commands have not been found.'
echo ' Playlist meta data may not be complet.'
_pkgs=''
for _cmd in $NX_COMMANDS
do
_pkg=''
for _i in $PACKAGE_LIST
do
_n=`echo "$_i" | cut -d: -f1`
_p=`echo "$_i" | cut -d: -f2`
[ "$_p" = '' ] && _p="$_n"
if [ "$_n" = "$_cmd" ]
then
_pkg="$_p"
break
fi
done
if [ "$_pkg" = '' ]
then
_pkg_text=''
else
_pkgs="$_pkg $_pkgs"
_pkg_text=" (can be found in package $_pkg)"
fi
echo " * $_cmd$_pkg_text"
done
if [ "$_pkgs" != '' -a "$PACKAGE_INSTALL_COMMAND" != '' ]
then
echo 'To correct those problems try to run the following command as root:'
printf " $PACKAGE_INSTALL_COMMAND\n" "$_pkgs"
fi
} >&2
fi
}
#command_not_found_handle=command_not_found_handle
command_not_found_handle() {
cmd="$1"
NX_COMMANDS=`cat "$NX_COMMANDS_FILE"`
if _isinnx "$cmd"
then
:; # ignore
else
NX_COMMANDS="$NX_COMMANDS $cmd"
fi
echo "$NX_COMMANDS" > "$NX_COMMANDS_FILE"
return 0;
}
if [ -f /etc/dir2vclt.conf ]; then
. /etc/dir2vclt.conf
fi
if [ -f ~/.dir2vclt.conf ]; then
. ~/.dir2vclt.conf
fi
while [ "$1" != '' ]
do
_p="$1"
shift;
case "$_p" in
'--metadata')
METADATA=true
;;
'--no-metadata')
METADATA=false
;;
'--length')
LENGTH=true
;;
'--no-length')
LENGTH=false
;;
'--path-mode=keep')
MODE_PATH='keep';
;;
'--path-mode=absolute')
MODE_PATH='absolute';
;;
'--path-mode='*)
echo "Unknown print mode."
exit 1;
;;
'--help'|'-h')
echo "Usage: $0 [OPTIONS] {dir|file} [output]"
echo
echo "Options:"
echo "-h --help - Print this help."
echo " --metadata - Add meta data to playlist."
echo " --no-metadata - Do not add meta data to playlist."
echo " --length - Add playback length to playlist."
echo " --no-length - Do not add playback length to playlist."
echo " --path-mode=keep - Keep filenames as they are."
echo " --path-mode=absolute - Try to make filenames absolute."
exit 0
;;
*)
if [ "$DIR" = '' ]
then
DIR="$_p"
elif [ "$OUT" = '' ]
then
OUT="$_p"
else
echo "Too many parameters."
exit 1;
fi
;;
esac
done
[ "$DIR" = '' ] && DIR='.'
[ "$OUT" = '' -o "$OUT" = '-' ] && OUT='/dev/stdout';
on_startup
{
{
case "$MODE_FIND" in
'ext')
_ext="`echo $EXTS | sed 's/ */\\\|/g'`";
find "$DIR" \( -type f -o -type l \) -iregex ".*\($_ext\)$"
;;
*)
exit 1;
;;
esac;
} | \
sort | \
while read _file
do
_type='unknown';
case "$MODE_TYPE" in
'guess')
case "$_file" in
*.ogg) _type='ogg_vorbis'; ;;
*.wav) _type='riff_wave'; ;;
*.spx) _type='ogg_speex'; ;;
*.flac) _type='flac'; ;;
*.raum) _type='raum'; ;;
*.mid) _type='midi_file'; ;;
*.midi) _type='midi_file'; ;;
*.mp3) _type='id3'; ;;
*.opus) _type='ogg_opus'; ;;
esac;
;;
*)
exit 1;
;;
esac;
_codec="$_type";
{
if $METADATA
then
case "$_type" in
'ogg_vorbis')
$CMD_VORBISCOMMENT -l "$_file" 2> /dev/null
;;
'ogg_speex')
$CMD_OGGZ_COMMENT -l "$_file" | \
tail -n +3 | \
sed 's/^\t*//; s/: /=/'
;;
'flac')
$CMD_METAFLAC --list --block-type=VORBIS_COMMENT "$_file" | \
grep '^ *comment\[' | \
sed 's/^.*: //'
;;
'raum')
$CMD_RAUM_INFO "$_file" | \
grep '^pkg [0-9]*: Stream #[0-9]*: Meta ' | \
sed 's/^pkg [0-9]*: Stream #[0-9]*: Meta //'
;;
'id3')
$CMD_ID3TOOL "$_file" 2> /dev/null | \
sed 's/:\t\t*/:/' | \
sed 's/ *$//' | \
while IFS=':' read _t _d
do
_t=`echo $_t | tr a-z A-Z`
case "$_t" in
'SONG TITLE')
echo "TITLE=$_d"
;;
# 1:1 mapping:
'ARTIST'|'ALBUM'|'YEAR')
echo "$_t=$_d"
;;
'NOTE')
echo "COMMENT=$_d"
;;
'GENRE')
_d=`echo "$_d" | cut -d' ' -f1`
echo "GENRE=$_d"
;;
# ignore the rest at the moment
esac;
done
;;
esac;
fi
if $LENGTH
then
case "$_type" in
# *.wav) _type='riff_wave'; ;;
'flac')
$CMD_METAFLAC --list --block-type=STREAMINFO "$_file" | \
$CMD_METAFLAC2TIME
_codec='unknown'; # suppres output of SIGNALINFO
;;
# *.raum) _type='raum'; ;;
# *.mid) _type='midi_file'; ;;
# *.midi) _type='midi_file'; ;;
'ogg_vorbis'|'ogg_speex')
$CMD_OGGZ_INFO -l "$_file" | \
grep '^Content-Duration: ' | \
sed 's/^Content-Duration: /LENGTH=/'
;;
'id3')
$CMD_MP32VCLT --no-del "$_file"
_codec='unknown'; # suppres output of SIGNALINFO
;;
esac;
fi
case "$MODE_PATH" in
'keep')
echo 'FILENAME='"$_file";
;;
'absolute')
echo "$_file" | if grep "^/" 2> /dev/null > /dev/null
then
echo 'FILENAME='"$_file";
else
# make semi abselute
_file="`pwd`/$_file"
# strip all //
_file=`echo "$_file" | sed 's#//#/#g'`
# strip all .../a/../...
while echo "$_file" | grep '/\.\./' > /dev/null
do
_file=`echo "$_file" | sed 's#/[^/][^/]*/../#/#'`
done
echo 'FILENAME='"$_file";
fi
;;
esac
if [ "$_codec" != 'unknown' ]
then
echo 'SIGNALINFO=codec:'"$_codec";
fi
echo '=='
}
done
} > "$OUT";
on_exit
#ll
|