3 f
=/usr
/local
/lib
/err
;test -r $f ||
{ echo "error: $0 no $f" >&2;exit 1;}; .
$f
6 # these are useful tags
10 # these are normal playlists
19 # these options are mainly for debugging / developing quickly.
33 echo "error. unexpected arg read script"
41 printf "%s\n" "$*" >&2
42 if $dry_run && [[ $1 == beet
&& $2 == modify
]]; then
56 if [[ $HOSTNAME != kd
]]; then
57 ssh b8.nz bash
-s <<EOF | tar xz
58 install -m 700 -d /tmp/nav2beet
60 for r in 1 2 3 4 5; do
61 sqlite3 /i/navidrome/navidrome.db ".output \$r" "select path from annotation inner join media_file on item_id = id where rating = \$r;"
63 find /i/m -type f -name '*.flac' >flacs
64 for plist in ${plists[@]}; do
65 sqlite3 /i/navidrome/navidrome.db "select path from media_file inner join playlist_tracks on media_file.id = media_file_id where playlist_id = (select id from playlist where name = '\$plist');" | sed 's,^/i/converted,/i/m,' | sort >\$plist
67 tar cz -C /tmp nav2beet
72 for r
in 1 2 3 4 5; do
73 sqlite3
/i
/navidrome
/navidrome.db
".output $r" "select path from annotation inner join media_file on item_id = id where rating = $r;"
75 find /i
/m
-type f
-name '*.flac' >flacs
76 for plist
in ${plists[@]}; do
77 sqlite3
/i
/navidrome
/navidrome.db
"select path from media_file inner join playlist_tracks on media_file.id = media_file_id where playlist_id = (select id from playlist where name = '$plist');" |
sed 's,^/i/converted,/i/m,' |
sort >$plist
84 if ! $plist_only; then
85 echo begin star rating import from navidrome to beets
86 # todo: consider if this is a problem: file removed/renamed in main
87 # collection, but not yet updated navidrome, we want to skip it not
90 for r
in 1 2 3 4 5; do
91 while read -r path
; do
92 beetpath
="/i/m${path#/i/converted}"
93 flac
="${beetpath%.mp3}.flac"
94 if [[ ${flacs[$flac]} ]]; then
97 navirating
[$beetpath]=$r
100 declare -A beetrating
101 for r
in 1 2 3 4 5; do
102 m beet
ls -f '$path' rating
:$r >$tmpf
103 while read -r path
; do
108 for path
in "${!navirating[@]}"; do
109 r
="${navirating[$path]}"
110 if [[ $r != "${beetrating[$path]}" ]]; then
111 # note: this assumes there are no cases like filea.mp3 filea.mp3.mp3, which would affect both files.
112 echo "$r != ${beetrating[$path]}, beet modify -y path:$path rating=$r"
113 beet modify
-y "path:$path" "rating=$r"
116 # end star rating import from navidrome to beets:
120 echo begin import navidrome playlists as flexible attribute with value t.
121 # These are only the playlists listed in the beets config.yaml
122 # "subsonicplaylist:" and then duplicated here:
127 for plist
in ${plists[@]}; do
128 echo "processing $plist"
129 beet
ls -f '$path' $plist:t ^genre
:spoken-w ^genre
:skit ^rating
:1 |
sort |
sed 's,\.flac$,.mp3,'> p
130 while read -r path
; do
131 flac
="${path%.mp3}.flac"
132 if [[ ${flacs[$flac]} ]]; then
135 m beet modify
-y "path:$path" "$plist!"
136 # files unique to tmpf are in beets not navidrome
137 done < <(comm -23 p
$plist)
138 while read -r path
; do
139 flac
="${path%.mp3}.flac"
140 echo "flac=$flac path=$path ${flacs[$flac]} ${flacs[flac]}"
141 if [[ ${flacs[$flac]} ]]; then
144 m beet modify
-y "path:$path" $plist=t
145 # files unique to plist are in navidrome not beets
146 done < <(comm -13 p
$plist)