Browse Source

Importing music from a directory

Bob Mottram 7 years ago
parent
commit
c60aea3580
1 changed files with 62 additions and 1 deletions
  1. 62
    1
      src/freedombone-app-koel

+ 62
- 1
src/freedombone-app-koel View File

@@ -156,10 +156,71 @@ function reconfigure_koel {
156 156
     echo -n ''
157 157
 }
158 158
 
159
-function configure_interactive_koel {
159
+function koel_import_from_directory {
160
+    data=$(tempfile 2>/dev/null)
161
+    dialog --title "test" --dselect /home/$MY_USERNAME/ 30 60 2> $data
162
+    selected_dir=$(cat $data)
163
+    rm $data
164
+    if [[ "$selected_dir" == '/music' ]]; then
165
+        return
166
+    fi
167
+    if [ ! -d $selected_dir ]; then
168
+        return
169
+    fi
170
+    if [[ "$selected_dir" == "/home/$MY_USERNAME/" ]]; then
171
+        return
172
+    fi
173
+    if [[ "$selected_dir" == "/home/$MY_USERNAME/."* ]]; then
174
+        return
175
+    fi
176
+    if [[ "$selected_dir" == *"/Maildir" || "$selected_dir" == *"/Sync" ]]; then
177
+        return
178
+    fi
179
+
180
+    dialog --title $"Import music directory" \
181
+           --backtitle $"Freedombone Control Panel" \
182
+           --defaultno \
183
+           --yesno $"\nImport the directory:\n\n  $selected_dir" 12 75
184
+    sel=$?
185
+    case $sel in
186
+        1) return;;
187
+        255) return;;
188
+    esac
189
+
190
+    mv $selected_dir /music
191
+
192
+    dialog --title $"Import music directory" \
193
+           --msgbox $"Import success. You may need to re-sync within Koel." 6 40
194
+}
195
+
196
+function koel_import_from_usb {
160 197
     echo -n ''
161 198
 }
162 199
 
200
+function configure_interactive_koel {
201
+    while true
202
+    do
203
+        data=$(tempfile 2>/dev/null)
204
+        trap "rm -f $data" 0 1 2 5 15
205
+        dialog --backtitle $"Freedombone Control Panel" \
206
+               --title $"Koel" \
207
+               --radiolist $"Choose an operation:" 13 70 3 \
208
+               1 $"Import music from directory" off \
209
+               2 $"Import music from USB drive" off \
210
+               3 $"Exit" on 2> $data
211
+        sel=$?
212
+        case $sel in
213
+            1) break;;
214
+            255) break;;
215
+        esac
216
+        case $(cat $data) in
217
+            1) koel_import_from_directory;;
218
+            2) koel_import_from_usb;;
219
+            3) break;;
220
+        esac
221
+    done
222
+}
223
+
163 224
 function upgrade_koel {
164 225
     if grep -q "koel domain" $COMPLETION_FILE; then
165 226
         KOEL_DOMAIN_NAME=$(get_completion_param "koel domain")