diff options
| author | Ivan K. Boikov <mail@ikboikov.net> | 2025-04-20 17:56:38 +0200 |
|---|---|---|
| committer | Ivan K. Boikov <mail@ikboikov.net> | 2025-04-20 17:56:38 +0200 |
| commit | 16fd8b0ae3f08a75ce0f3c4cc9d917349f7308df (patch) | |
| tree | 6301412176706310ed4e725f24d0311ef850cf96 /scripts/.local/bin/playlist-sync | |
| parent | 9659385b884144dcf7223ec3139fc7debcf05ac7 (diff) | |
playlist-sync: separate export
Diffstat (limited to 'scripts/.local/bin/playlist-sync')
| -rwxr-xr-x | scripts/.local/bin/playlist-sync | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/scripts/.local/bin/playlist-sync b/scripts/.local/bin/playlist-sync index 2d06119..f5a4ea9 100755 --- a/scripts/.local/bin/playlist-sync +++ b/scripts/.local/bin/playlist-sync @@ -2,22 +2,27 @@ DIR="$HOME/audio/playlists" - cd "$DIR" || exit -for playlist_path in "$DIR"/*.m3u; do + +# phone -> desktop +for playlist_path in "$DIR"/phone-export/*; do + playlist="$(basename "$playlist_path")" + # normalize filenames to <playlist name>.m3u + tmp="$(echo $playlist | sed 's/.m3u8$//g' | sed 's/.m3u$//g').m3u" + mv "phone-export/$playlist" "phone-export/$tmp" > /dev/null 2>&1 + # \r\n -> \n + sed -i 's/\r$//g' "phone-export/$tmp" +done +# actual import +for playlist_path in "$DIR"/phone-export/*; do playlist="$(basename "$playlist_path")" # -nt is a bashism - if [ "$DIR/$playlist" -nt "$DIR/phone/$playlist" ]; then - echo "$playlist: desktop > phone" - sed -e 's/^/Music\/library\//g' \ - -e 's/flac$/opus/g' -e 's/mp3$/opus/g' -e 's/wav$/opus/g' \ - "$DIR/$playlist" > "$DIR/phone/$playlist" - else - echo "$playlist: phone > desktop" - sed -e 's/^Music\/library\///g' \ + if [ "$DIR/phone-export/$playlist" -nt "$DIR/$playlist" ]; then + echo "Importing $playlist" + sed -e 's/^primary\/Music\/library\///g' \ -e '/-FLAC\//s/opus$/flac/g' -e '/-MP3\//s/opus$/mp3/g' -e '/-WAVE\//s/opus$/wav/g'\ -e '/^#/d' \ - "$DIR/phone/$playlist" > "$DIR/$playlist" + "$DIR/phone-export/$playlist" > "$DIR/$playlist" git add "$DIR/$playlist" > /dev/null 2>&1 git commit -m "Updated $playlist" > /dev/null 2>&1 fi |
