Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OR / Fallback Between two metadata keys #142

Closed
ghost opened this issue Jun 17, 2019 · 2 comments
Closed

OR / Fallback Between two metadata keys #142

ghost opened this issue Jun 17, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 17, 2019

The usecase is to be able to select xesam:albumArtist when it exists, and fallback to xesam:artist if it does not.

Currently I work around this using the below:

IFS='|' read -ra METADATA <<< "$(playerctl metadata --format '{{xesam:albumArtist}}|{{artist}}|{{title}}' 2>/dev/null)"

if [ "${METADATA[0]}" ]; then
	echo "${METADATA[0]} - ${METADATA[2]}"

elif [ "${METADATA[1]}" ]; then
	echo "${METADATA[1]} - ${METADATA[2]}"

fi
@acrisci
Copy link
Member

acrisci commented Jun 17, 2019

How about a default function?

{{default(xesam:albumArtist, xesam:artist)}}

@ghost
Copy link
Author

ghost commented Jun 17, 2019

Yep, that'd work perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant