From 77ef4b23924ce82876d74121fb368dc942c2bed5 Mon Sep 17 00:00:00 2001 From: ivan-boikov Date: Sat, 13 Jan 2024 20:25:51 +0100 Subject: playlist sync --- scripts/.local/bin/playlist-sync | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/.local/bin/playlist-sync diff --git a/scripts/.local/bin/playlist-sync b/scripts/.local/bin/playlist-sync new file mode 100755 index 0000000..2d06119 --- /dev/null +++ b/scripts/.local/bin/playlist-sync @@ -0,0 +1,24 @@ +#!/bin/bash + +DIR="$HOME/audio/playlists" + + +cd "$DIR" || exit +for playlist_path in "$DIR"/*.m3u; 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' \ + -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" + git add "$DIR/$playlist" > /dev/null 2>&1 + git commit -m "Updated $playlist" > /dev/null 2>&1 + fi +done -- cgit v1.2.3