3 #-------------------------------------------------------------------------------
4 ## Script to convert the database of paraslash 0.3.5 to version 0.4.x.
7 ## - para_server 0.3.5 is running
8 ## - "para_client check" reports no errors
9 ## - para_server 0.4.x is running, listens on another port and uses a
10 ## different afs database and a different afs socket
11 ## - The database of paraslash 0.4.x has been initialized (i.e.
12 ## para_client init has successfully been executed)
13 ## - All audio files in the 0.3.x database have already been added to
14 ## the 0.4.x database (execute para_client add /my/audio/file/dir to
17 #-------------------------------------------------------------------------------
19 # Call this script without arguments to see usage info
21 # How to connect to para_server 0.3.x.
22 client03
=/usr
/local
/bin
/para_client
25 database03
=$HOME/.paraslash
/afs_database
27 # How to connect to para_server 0.4.x.
28 client04
=$
(pwd)/para_client
31 database04
=$HOME/.paraslash
/afs_database-0.4
33 # Any character that does not occur in any filename of an audio file
37 client03_cmd
="$client03 -p $port03 -i $host03"
38 client04_cmd
="$client04 -p $port04 -i $host04"
42 result
="$($client03_cmd -- "$@
")"
47 result
="$($client04_cmd -- "$@
")"
50 convert_attribute_table
()
54 echo "converting attribute table"
55 exec_client03_cmd lsatt
57 exec_client04_cmd addatt
$atts
62 local OIFS
="$IFS" a p att atts
64 printf "converting attributes: "
65 $client03_cmd -- ls -p -lv \
66 |
grep '^path:\|^attributes_txt:' \
67 |
sed -e "/^path:/N;s/\n/$sep/1" \
72 a
=${a#attributes_txt:}
79 [[ -n "$atts" ]] && $client04_cmd -- setatt
$atts "$p"
90 local OIFS
="$IFS" p l n a
92 printf "converting last_played, num_played, amplification values: "
93 $client03_cmd -- ls -p -d -lv \
94 |
grep '^path:\|^last_played: \|^num_played: \|^amplification: ' \
95 |
sed -e "/^path:/N;N;N;s/\n/$sep/g" \
98 while read p l n a
; do
99 #echo "p: $p, l:$l, n:$n a:$a"
103 a
=${a#amplification: }
105 $client04_cmd -- touch "-l$l" "-n$n" "-a$a" "$p"
118 for blob
in img lyr mood pl
; do
119 printf "converting $blob table: "
120 exec_client03_cmd
ls$blob
121 echo "$result" |
while read name
; do
122 $client03_cmd -- cat$blob "$name" |
$client04_cmd -- add
$blob "$name"
131 local OIFS
="$IFS" p i y iopts yopts
133 printf "converting image and lyrics ids: "
134 $client03_cmd -- ls -p -lv \
135 |
grep '^path:\|^image_name: \|^lyrics_name: ' \
136 |
sed -e "/^path:/N;N;s/\n/$sep/g" \
146 if [[ "$i" != '(none)' ]]; then
147 exec_client04_cmd lsimg
-l "$i"
148 iopts
="-i${result%% *}"
150 if [[ "$l" != '(none)' ]]; then
151 exec_client04_cmd lslyr
-l "$l"
152 yopts
="-y${result%% *}"
154 if [[ -n "$iopts" && -n "$yopts" ]]; then
155 $client04_cmd -- touch "$iopts" "$yopts" "$p"
156 elif [[ -n "$iopts" ]]; then
157 $client04_cmd -- touch "$iopts" "$p"
158 elif [[ -n "$yopts" ]]; then
159 $client04_cmd -- touch "$yopts" "$p"
172 grep '^##' $0 |
sed -e 's/^## *//'
176 command is one of the following:
178 attribute_table: create attributes
179 attributes: convert attributes for each audio file
180 lna: convert the last_played/num_played/amplification values
181 blobs: convert the image/lyrics/moods/playlists tables
182 ids: convert image and the lyrics id of each audio file.
183 all: Do all of the above.
185 Edit the top of the script to customize some options.
189 if test $# -ne 1; then
196 convert_attribute_table
211 convert_attribute_table