From eb1e3a17da2c3aabbc773eb311f3778c2fc9b37f Mon Sep 17 00:00:00 2001 From: DeaDvey <deadvey@deadvey.com> Date: Sun, 3 Nov 2024 19:54:30 +0000 Subject: [PATCH] initial commit --- example_config.sh | 2 ++ mpvmusic.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 example_config.sh create mode 100755 mpvmusic.sh diff --git a/example_config.sh b/example_config.sh new file mode 100644 index 0000000..eddfaf2 --- /dev/null +++ b/example_config.sh @@ -0,0 +1,2 @@ +webpage_path="" # HTML file to write music data to for the webui (can be ommitted) +playlist_path="/mount/deadvey/Music/" # File location for the playlist (required) diff --git a/mpvmusic.sh b/mpvmusic.sh new file mode 100755 index 0000000..076207a --- /dev/null +++ b/mpvmusic.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Dependencies: +# MPV +# exiftool +# jq +# +#set -x + +config_path="$HOME/.config/mpvmusic/config.sh" +if [ -f $config_path ]; then + echo "config exists" +else + install -Dv example_config.sh $config_path +fi +source $config_path +previous_songs_path="" +#find $playlist_path -type f > song_list.txt + +mpv --shuffle --really-quiet $playlist_path --input-ipc-server=/tmp/mpvsocket & +sleep 1 + +while [ 1 == 1 ]; do + path=$(echo '{ "command": ["get_property", "path"] }' | socat - "/tmp/mpvsocket" | jq -r '.data') + if [[ $path != $previous_songs_path ]]; then + clear + name=$(exiftool -Title "$path" | awk -F: '{print $2}') + artist=$(exiftool -Artist "$path" | awk -F: '{print $2}') + + echo Song name: $name + echo Artist: $artist + + if [ -z $webpage_path ]; then + echo "<h1>Currently listening to:</h1>" > $webpage_path + echo Name: $name"<br/>" >> $webpage_path + echo Artist: $artist"<br/>" >> $webpage_path + echo "<form action='/music/prev' id='media-control' method='post'><button>previous</button></form>" >> $webpage_path + echo "<form action='/music/playpause' id='media-control' method='post'><button>play/pause</button></form>" >> $webpage_path + echo "<form action='/music/next' id='media-control' method='post'><button>next</button></form>" >> $webpage_path + fi + fi + previous_songs_path=$path + sleep 0.5 +done