Showing 1 changed files with 60 additions and 0 deletions
+60
get_cover.conf
... ...
@@ -0,0 +1,60 @@
1
+medias=/media/musique
2
+navidrome=/var/lib/navidrome
3
+pre_get_cover () {
4
+    if test ${SCAN:-3} -eq 2 -o ${SCAN:-3} -eq 3; then
5
+        local nouveautes=$(mktemp --dry-run /dev/shm/XXXXXXXX)
6
+        find $medias -name 'lost+found' -prune -o -type d -links 2 -print > $nouveautes
7
+        sqlite3 $navidrome/navidrome.db <<< "select path from media_file" | sed -r 's,/[^/]+$,,' | sort -u >> $nouveautes
8
+        sed -ri "/^${medias//\//\\\/}\/?$/d" $nouveautes
9
+        local IFS=$'\n'
10
+        for d in $(sort $nouveautes | uniq -u); do
11
+            compgen -G "$d/cover.*" > /dev/null \
12
+            || test -e "$d/.no_cover" \
13
+            || albums[${#albums[@]}]=":$d"
14
+        done
15
+        rm $nouveautes
16
+    fi
17
+    if test ${SCAN:-3} -eq 1 -o ${SCAN:-3} -gt 3; then
18
+        echo sync
19
+        sync
20
+        if test ${SCAN:-3} -gt 3; then
21
+            echo scan complet
22
+            local full="-f"
23
+            local _files=15571 # automatiquement mis à jour
24
+            local _eta=1780    # automatiquement mis à jour
25
+            local files=$(find $medias -type f -printf x 2>/dev/null | wc -m)
26
+            local eta=$(( files * _eta / _files ))
27
+            (
28
+                while test $eta -gt 0; do
29
+                    printf "\r\033[Kfin scan complet prévue dans %d:%d" $((eta/60)) $((eta%60))
30
+                    sleep 1
31
+                    let eta--
32
+                done
33
+                printf "\r\033[K"
34
+            )&
35
+            local pid_tc=$!
36
+            _eta=$(date +%s)
37
+        else
38
+            echo scan simple
39
+        fi
40
+        sudo -u navidrome ~navidrome/navidrome -c $navidrome/navidrome.toml --datafolder $navidrome/ -n --musicfolder $medias scan $full
41
+    fi
42
+    if test ${SCAN:-3} -gt 4; then
43
+        _eta=$(( $(date +%s) - $_eta ))
44
+        sed -ri "s/^(\s*local\s+_eta=)[0-9]+/\1$_eta/; s/^(\s*local\s+_files=)[0-9]+/\1$files/" ${BASH_SOURCE[0]}
45
+        if test -e /proc/$pid_tc/stat && stat=($(</proc/$pid_tc/stat)) && test ${stat[3]} -eq $$; then
46
+            kill $pid_tc
47
+            printf "\r\033[K"
48
+        fi
49
+        sudo mount -o remount,ro $medias
50
+        exit
51
+    fi
52
+    sudo mount -o remount,rw $medias
53
+}
54
+post_get_cover () {
55
+    sudo mount -o remount,ro $medias
56
+    if test ${SCAN:-3} -eq 2 -o ${SCAN:-3} -eq 3; then
57
+        echo scan de fin
58
+        sudo -u navidrome ~navidrome/navidrome -c $navidrome/navidrome.toml --datafolder $navidrome/ -n --musicfolder $medias scan
59
+    fi
60
+}