"Fossies" - the Fresh Open Source Software Archive 
Member "burncdda-1.8.3/checkm3u.func" (17 May 2011, 3282 Bytes) of package /linux/privat/old/burncdda-1.8.3.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #!/usr/bin/env bash
2 #------------------------------------------------------------------------------
3 # burnCDDA is a shell script for burning Audio-CDs with
4 # cdrdao and cdrecord.
5 #
6 # (C) 2001 by Thorsten Muehlfelder <thenktor@gmx.de>
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License (version 2)
10 # as published by the Free Software Foundation;
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #------------------------------------------------------------------------------
21
22 # errormessage of checkm3u
23 function checkerror()
24 {
25 CORRUPTED=$CORRUPTED+1
26 echo -e "\nThis File is${RED} corrupted${NOCOLOR} and can cause bad sound quality!"
27 echo -e "${BLUE}Press any key${NOCOLOR}"
28 read -n1
29 echo ""
30 continue
31 }
32
33
34 # check m3u playlist function
35 function checkm3u()
36 {
37 N=0
38 LN=1
39 CORRUPTED=0
40 NOTSUPPORTED=0
41 NOTREADABLE=0
42 while [ $LN -le $MAXLN ]; do
43 LINE=`$HEAD -$LN "$PLAYLIST" | $TAIL -1 | $SED s/$'\r'//`
44 # check if first character of the line is "#" and if yes skip the line
45 EXTENDED=`echo "$LINE" | $HEAD -c 1`
46 if [ "$EXTENDED" = "#" ]; then
47 LN=$LN+1
48 continue
49 fi
50 # correct some errors caused by drag and drop from the file manager
51 FILEMANAGER=`echo "$LINE" | $HEAD -c 8`
52 if [ "$FILEMANAGER" = "file:///" ]; then
53 # use # instead of / as separator and substitude file:/// with /
54 # substitude %20 with ' '
55 # WARNING: there are many errors with special characters left
56 # don't know how to fix it in a simple way
57 LINE=`echo "$LINE" | $SED s#^file:///#/# | $SED s/%20/' '/g`
58 fi
59 echo "File: $LINE"
60 # cut the part after the "." and set it as TYP
61 TYP=`echo "$LINE" | $GAWK 'BEGIN { FS = "." } {if (NF > 1) print $NF}' | $TR [:upper:] [:lower:]`
62 N=$N+1
63 LN=$LN+1
64 if [ -r "$LINE" ]; then
65 if [ "$TYP" = "mp3" ]; then
66 echo "mp3_check..."
67 $MP3_CHECK "$LINE" 2> /dev/null 1> /dev/null || checkerror
68 echo -e "${GREEN} OK${NOCOLOR}"
69 elif [ "$TYP" = "ogg" ]; then
70 echo "ogginfo..."
71 $OGGINFO "$LINE" | $GREP "Corrupted ogg" && checkerror
72 echo -e "${GREEN} OK${NOCOLOR}"
73 elif [ "$TYP" = "mpc" ]; then
74 echo "Musepack file. No check possible!"
75 elif [ "$TYP" = "flac" ]; then
76 echo "flac --test..."
77 $FLACCHK --totally-silent --test "$LINE" || checkerror
78 echo -e "${GREEN} OK${NOCOLOR}"
79 elif [ "$TYP" = "wav" ]; then
80 echo "WAV file. No check possible!"
81 elif [ "$TYP" = "" ]; then
82 echo "File format could not be detected. No check possible!"
83 else
84 echo "$TYP file. No check possible!"
85 fi
86 else
87 echo "$LINE does not exist or is not readable."
88 echo -e "${YELLOW}Failed${NOCOLOR}"
89 NOTREADABLE=$NOTREADABLE+1
90 fi
91 echo -e "\n"
92 done
93 echo -e "\nChecked $MAXN files in '$PLAYLIST':"
94 echo -e "mp3_check/ogginfo found${RED} $CORRUPTED ${NOCOLOR}corrupted files!"
95 echo -e "${YELLOW}$NOTREADABLE ${NOCOLOR}files did not exist or were not readable."
96 }