lots of fixes, new music stuff
[distro-setup] / navidrome-playlist-export
1 #!/bin/bash
2
3 f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f
4
5
6
7 # begin star rating import from navidrome to beets:
8 declare -A navirating
9 for r in 1 2 3 4 5; do
10 while read -r path; do
11 beetpath="/i/m${path#/i/converted}"
12 navirating[$beetpath]=$r
13 done < <(sqlite3 /i/navidrome/navidrome.db "select path from annotation inner join media_file on item_id = id where rating = $r;")
14 done
15 declare -A beetrating
16 for r in 1 2 3 4 5; do
17 while read -r path; do
18 beetrating[$path]=$r
19 done < <(beet ls -f '$path' rating:$r)
20 done
21
22 for path in "${!navirating[@]}"; do
23 r="${navirating[$path]}"
24 if [[ $r != "${beetrating[$path]}" ]]; then
25 # note: this assumes there are no cases like filea.mp3 filea.mp3.mp3, which would affect both files.
26 echo "$r != ${beetrating[$path]}, beet modify -y path:$path rating=$r"
27 beet modify -y "path:$path" "rating=$r"
28 fi
29 done
30 # end star rating import from navidrome to beets:
31
32
33 beet subsonicplaylist
34
35 while read -r id plists; do
36 plists="${plists#;}"
37 e beet modify -y "id:$id" ${plists//;/=t }
38 done < <(beet ls -f '$id $subsonic_playlist' subsonic_playlist::.)