scripts / get_cover.conf /
Newer Older
59 lines | 2.401kb
publie config
Sébastien MARQUE authored on 2023-01-14
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
fix pour les images
Sébastien MARQUE authored on 2023-05-17
16
    elif test ${SCAN:-3} -eq 1 -o ${SCAN:-3} -gt 3; then
publie config
Sébastien MARQUE authored on 2023-01-14
17
        echo sync
18
        sync
19
        if test ${SCAN:-3} -gt 3; then
20
            echo scan complet
21
            local full="-f"
22
            local _files=15571 # automatiquement mis à jour
23
            local _eta=1780    # automatiquement mis à jour
24
            local files=$(find $medias -type f -printf x 2>/dev/null | wc -m)
25
            local eta=$(( files * _eta / _files ))
26
            (
27
                while test $eta -gt 0; do
28
                    printf "\r\033[Kfin scan complet prévue dans %d:%d" $((eta/60)) $((eta%60))
29
                    sleep 1
30
                    let eta--
31
                done
32
                printf "\r\033[K"
33
            )&
34
            local pid_tc=$!
35
            _eta=$(date +%s)
36
        else
37
            echo scan simple
38
        fi
39
    fi
40
    if test ${SCAN:-3} -gt 4; then
41
        _eta=$(( $(date +%s) - $_eta ))
42
        sed -ri "s/^(\s*local\s+_eta=)[0-9]+/\1$_eta/; s/^(\s*local\s+_files=)[0-9]+/\1$files/" ${BASH_SOURCE[0]}
43
        if test -e /proc/$pid_tc/stat && stat=($(</proc/$pid_tc/stat)) && test ${stat[3]} -eq $$; then
44
            kill $pid_tc
45
            printf "\r\033[K"
46
        fi
47
        sudo mount -o remount,ro $medias
48
        exit
49
    fi
fix pour les images
Sébastien MARQUE authored on 2023-05-17
50
    sudo -u navidrome ~navidrome/navidrome -c $navidrome/navidrome.toml --datafolder $navidrome/ -n --musicfolder $medias scan $full
publie config
Sébastien MARQUE authored on 2023-01-14
51
    sudo mount -o remount,rw $medias
52
}
53
post_get_cover () {
54
    sudo mount -o remount,ro $medias
55
    if test ${SCAN:-3} -eq 2 -o ${SCAN:-3} -eq 3; then
56
        echo scan de fin
57
        sudo -u navidrome ~navidrome/navidrome -c $navidrome/navidrome.toml --datafolder $navidrome/ -n --musicfolder $medias scan
58
    fi
59
}