I think there's now decent error detection for posting music.
This commit is contained in:
parent
870cf0e4fd
commit
36513b8db6
11
ratatoskr.sh
11
ratatoskr.sh
@ -103,6 +103,14 @@ scrobble_music() {
|
|||||||
# Post music with -M flag requires playerctl.
|
# Post music with -M flag requires playerctl.
|
||||||
post_music() {
|
post_music() {
|
||||||
local text="$(playerctl metadata -f 'Now playing "{{title}}" by "{{artist}}" from "{{album}}" via "{{playerName}}"')"
|
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}}')"
|
local link="$(playerctl metadata -f '{{xesam:url}}')"
|
||||||
if [[ "${link}" =~ ^file:// ]]; then
|
if [[ "${link}" =~ ^file:// ]]; then
|
||||||
link="https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b)"
|
link="https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b)"
|
||||||
@ -230,7 +238,6 @@ done
|
|||||||
mkdir -p "${configPath}/soundpacks"
|
mkdir -p "${configPath}/soundpacks"
|
||||||
|
|
||||||
# Keep track of the backgrounded loop
|
# Keep track of the backgrounded loop
|
||||||
bgLoop=1
|
|
||||||
|
|
||||||
# Associative array of command line parameters and short description of what they do.
|
# Associative array of command line parameters and short description of what they do.
|
||||||
declare -A command=(
|
declare -A command=(
|
||||||
@ -272,8 +279,6 @@ done
|
|||||||
|
|
||||||
# Main loops
|
# Main loops
|
||||||
# Display timelines and requested information.
|
# Display timelines and requested information.
|
||||||
# Important, set bgLoop to 0 or this loop will not close with the program
|
|
||||||
bgLoop=0
|
|
||||||
while : ; do
|
while : ; do
|
||||||
show_timeline
|
show_timeline
|
||||||
sleep "${interval:-300}"
|
sleep "${interval:-300}"
|
||||||
|
Loading…
Reference in New Issue
Block a user