3 set -e; .
/usr
/local
/lib
/bash-bear
; set +e
5 source /a
/bin
/ds
/beet-data
6 source /b
/bash_unpublished
/source-semi-priv
9 for g
in ${all_genres[@]}; do
13 # these options are mainly for debugging / developing quickly.
27 echo "error. unexpected arg read script"
35 printf "%s\n" "$*" >&2
50 # the code here is duplicated later for non ssh context.
51 if [[ $HOSTNAME != kd
]]; then
53 ssh b8.nz bash
-s "$(md5sum </a/bin/ds/beet-data)" <<'EOF' | tar xz
54 if [[ $1 != "$(md5sum </a/bin/ds/beet-data)" ]]; then
55 echo error: old beet-data on kd
58 install -m 700 -d /tmp/nav2beet
60 /a/bin/ds/nav2beet-local
61 tar cz -C /tmp nav2beet
65 /a
/bin
/ds
/nav2beet-local
71 if ! $plist_only; then
72 echo begin star rating import from navidrome to beets
73 for r
in 1 2 3 4 5; do
74 while read -r path
; do
75 beetpath
="/i/m${path#/i/converted}"
76 flac
="${beetpath%.mp3}.flac"
77 if [[ ${flacs[$flac]} ]]; then
80 navirating
[$beetpath]=$r
84 for r
in 1 2 3 4 5; do
85 # shellcheck disable=SC2016 # expected beets arg
86 m beet
ls -f '$path' rating
:$r >$tmpf
87 while read -r path
; do
92 for path
in "${!navirating[@]}"; do
93 r
="${navirating[$path]}"
94 if [[ ! "${beetrating[$path]}" ]]; then
95 if [[ -e $path ]]; then
96 echo "$0: ERROR: $path exists but we have no rating for it"
99 echo "$0: WARNING: $path exists in navidrome but not beets"
103 if [[ $r != "${beetrating[$path]}" ]]; then
104 echo "$r != ${beetrating[$path]}, beet modify -y path:$path rating=$r"
105 beet modify
-y "path:$path" "rating=$r"
108 # end star rating import from navidrome to beets:
111 echo begin import navidrome playlists as flexible attribute with value t.
114 for path
in 2genre
/*/*; do
117 filename
="${path##*/}"
118 tmp
="${filename%%[^0-9-]*}"
119 genre
="${filename#"$tmp"}"
120 if [[ ${genre_a[$genre]} ]]; then
123 # Some playlists we create with random names to remind us to do something
124 # with these tracks later once we are at a computer.
127 while read -r path
; do
128 flac
="${path%.mp3}.flac"
129 if [[ ${flacs[$flac]} ]]; then
133 m beet modify
-y "path:$path" "genre=$genre"
135 m beet modify
-y "path:$path" "$genre=t"
138 # how i figured this out:
139 # s tcpdump -i any -w /tmp/tcpdump port 4533
140 # then delete a test playlist in client.
141 # made some sense out of it with: http://www.subsonic.org/pages/api.jsp
142 # open file in wireshard, right click "Hypertext Transfer Protocol", copy, as printable text, put into file /tmp/headers
143 # /a/opt/h2c/h2c </tmp/headers
144 # change from https to http.
145 # then tested out removing stuff i suspected was not important,
146 # and added https and host so it would work remotely.
147 m curl
--http1.1
--user "iank:$navidrome_pw" "https://b8.nz/rest/deletePlaylist.view?u=iank&s=sb219dvv7egnoe4i47k75cli0m&t=1c8f5575cd0fdf03deb971187c9c88b1&v=1.2.0&c=DSub&id=$id"
151 for plist
in ${nav_tags[@]}; do
152 echo "processing $plist"
153 # shellcheck disable=SC2016 # expected beets arg
154 beet
ls -f '$path' $plist:t
$nav_convert_query |
sort |
sed 's,\.flac$,.mp3,'> p
155 while read -r path
; do
156 flac
="${path%.mp3}.flac"
157 if [[ ${flacs[$flac]} ]]; then
160 m beet modify
-y "path:$path" "$plist!"
161 # files unique to tmpf are in beets not navidrome
162 done < <(comm -23 p
$plist)
163 while read -r path
; do
164 flac
="${path%.mp3}.flac"
165 if [[ ${flacs[$flac]} ]]; then
168 m beet modify
-y "path:$path" $plist=t
169 # files unique to plist are in navidrome not beets
170 done < <(comm -13 p
$plist)