From 36513b8db60c5f8877f54f414dd8ebb9c859d713 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Wed, 1 Feb 2023 17:55:28 -0500 Subject: [PATCH] I think there's now decent error detection for posting music. --- ratatoskr.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ratatoskr.sh b/ratatoskr.sh index 4c4222a..23fe98d 100755 --- a/ratatoskr.sh +++ b/ratatoskr.sh @@ -103,6 +103,14 @@ scrobble_music() { # Post music with -M flag requires playerctl. post_music() { local text="$(playerctl metadata -f 'Now playing "{{title}}" by "{{artist}}" from "{{album}}" via "{{playerName}}"')" + text="${text//Now playing \"\"/Now Playing}" + text="${text// by \"\"/}" + text="${text// from \"\"/}" + if [[ "${text}" =~ ^"Now playing via" ]]; then + echo "Error, no music was detected. Maybe it is not properly tagged?" + play_sound error + exit 1 + fi local link="$(playerctl metadata -f '{{xesam:url}}')" if [[ "${link}" =~ ^file:// ]]; then link="https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b)" @@ -230,7 +238,6 @@ done mkdir -p "${configPath}/soundpacks" # Keep track of the backgrounded loop -bgLoop=1 # Associative array of command line parameters and short description of what they do. declare -A command=( @@ -272,8 +279,6 @@ done # Main loops # Display timelines and requested information. -# Important, set bgLoop to 0 or this loop will not close with the program -bgLoop=0 while : ; do show_timeline sleep "${interval:-300}"