3 #-------------------------------------------------------------------------------
4 ## Script to convert the database of paraslash 0.2.x to version 0.3.x.
7 ## - para_server 0.2.x is running and the mysql selector is active
8 ## - para_server 0.3.x is running on another port
9 ## - The database of paraslash 0.3.x has been initialized (i.e.
10 ## para_client init has successfully been executed)
11 ## - All audio files in the mysql database of paraslash 0.2.x. have
12 ## already been added to the 0.3.x database (execute para_client add
13 ## /my/audio/file/dir to do that)
15 ## The script converts the attribute table, the set attributes for each audio
16 ## file, the image table and all image ids, and finally the lastplayed and the
19 ## However, it does not convert the paraslash stream definitions from 0.2.x to
20 ## the moods of 0.3.x. You'll have to do this by hand.
21 #-------------------------------------------------------------------------------
23 # Call this script without arguments to see usage info
25 # How to connect to para_server 0.2.x.
26 client02
=/usr
/local
/bin
/para_client
30 # How to connect to para_server 0.3.x.
31 client03
=.
/para_client
35 # Unset this to deactivate messages
39 client02_cmd
="$client02 -p $port02 -i $host02"
40 client03_cmd
="$client03 -p $port03 -i $host03"
44 if test $debug -eq 1; then
51 info_log
"$client02_cmd -- $@"
52 result
="$($client02_cmd -- "$@
")"
57 info_log
"$client03_cmd -- $@"
58 result
="$($client03_cmd -- "$@
")"
61 convert_attribute_table
()
66 info_log
"creating attributes: $atts"
67 exec_client03_cmd addatt
$atts
72 local att atts current_atts cmd query
="select dir.dir, dir.name"
76 query
="$query, data.$att"
78 query
="$query from dir,data where dir.name=data.name"
79 exec_client02_cmd verb
"$query"
80 echo "$result" |
while read dir name current_atts
; do
83 if test "${current_atts#0}" = "$current_atts"; then
85 current_atts
=${current_atts#1 }
87 current_atts
=${current_atts#0 }
90 if test "$cmd" = "setatt "; then
93 exec_client03_cmd
$cmd "$dir/$name"
97 convert_lastplayed_numplayed
()
99 local query
="select dir.dir, dir.name, unix_timestamp(data.lastplayed), data.numplayed from dir,data where data.name=dir.name"
100 local lp np data dir name
101 exec_client02_cmd verb
"$query"
103 echo "$result" |
while read dir name
lp np
; do
104 cmd
="touch -n$np -l$lp $dir/$name"
105 exec_client03_cmd
$cmd
109 convert_image_table
()
112 exec_client02_cmd piclist
;
113 echo "$result" |
while read num size name
; do
114 info_log
"converting $name"
115 $client02_cmd -- pic
"#$num" |
$client03_cmd -- addimg
"$name"
121 local query
="select dir.dir, dir.name, pics.name from dir,data,pics where data.name=dir.name and pics.id=data.pic_id"
122 local img_ids_03 dir name img id
123 exec_client03_cmd lsimg
-l
125 exec_client02_cmd verb
"$query"
126 echo "$result" |
while read dir name img
; do
127 id
="$(echo "$img_ids_03" | grep " $img\$
" | cut -f 1)"
128 exec_client03_cmd
touch "-i$id" "$dir/$name"
135 grep '^##' $0 |
sed -e 's/^## *//'
139 command is one of the following:
141 attribute_table: create attributes
142 attributes: convert attributes for each audio file
143 lastplayed_numplayed: convert numplayed and lastplayed
144 data of each audio file
145 image_table: retrieve images from mysql and add them to the database
147 image_ids: convert image id of each audio file.
148 all: Do all of the above.
150 Edit the top of the script to customize some options.
154 if test $# -ne 1; then
161 convert_attribute_table
166 lastplayed_numplayed
)
167 convert_lastplayed_numplayed
176 convert_attribute_table
178 convert_lastplayed_numplayed