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

v0.6.0 event vars missing \n delimiter #1391

Open
moodeaudio opened this issue Nov 4, 2024 · 2 comments
Open

v0.6.0 event vars missing \n delimiter #1391

moodeaudio opened this issue Nov 4, 2024 · 2 comments
Labels

Comments

@moodeaudio
Copy link

Hi,

I'm processing the track metadata in a bash event script and noticed that the env vars ARTISTS, ALBUM_ARTISTS and COVERS which should be \n delimited according to the wiki don't appear to contain these delimiters but instead are delimited by space.

Config
pi-5
PiOS bookworm
librespot v0.6.0
moOde 9.1.4 (latest)

Event script

if [[ $PLAYER_EVENT == "track_changed" ]]; then
	echo -e $ARTISTS > /home/pi/tim.txt
	echo -e $ALBUM_ARTISTS >> /home/pi/tim.txt
	echo -e $COVERS >> /home/pi/tim.txt
fi

Example Output
The two artists are: "softy" and "Dimension 32" and appear as "softy, Dimension 32" in the IOS app. The album artist is "softy".

pi@moode9:~ $ cat ./tim.txt
softy Dimension 32
softy
https://i.scdn.co/image/ab67616d0000b273f7b85abe57aba92059088752 https://i.scdn.co/image/ab67616d00001e02f7b85abe57aba92059088752 https://i.scdn.co/image/ab67616d00004851f7b85abe57aba92059088752

Output should be

pi@moode9:~ $ cat ./tim.txt
softy
Dimension 32
softy
https://i.scdn.co/image/ab67616d0000b273f7b85abe57aba92059088752
https://i.scdn.co/image/ab67616d00001e02f7b85abe57aba92059088752
https://i.scdn.co/image/ab67616d00004851f7b85abe57aba92059088752
@moodeaudio moodeaudio added the bug label Nov 4, 2024
@photovoltex
Copy link
Member

Sorry for the late response, but I can confirm the behavior on my side. Interestingly enough tho the string that is set as env_var has a \n to delimit the artists/cover but later in the env_var it's a whitespace. Just out of curiosity, this did work at some point right? I would suspect so, but just wanted to clear that up first :)

[2025-01-18T21:19:54Z DEBUG librespot::player_event_handler] Running /home/photovoltex/repos/forks/librespot/test-env.sh with environment variables:
    {
        "TRACK_ID": "2rOUaQ1TGj7wZdHdn9UgTL",
        "ITEM_TYPE": "Track",
        "LANGUAGE": "ja",
        "NAME": "ReawakeR (feat. Felix of Stray Kids)",
        "ALBUM": "ReawakeR (feat. Felix of Stray Kids)",
        "ARTISTS": "LiSA\nFelix of Stray Kids",
        "COVERS": "https://i.scdn.co/image/ab67616d0000b2737b93b5102e1c9de480078e9f\nhttps://i.scdn.co/image/ab67616d00001e027b93b5102e1c9de480078e9f\nhttps://i.scdn.co/image/ab67616d000048517b93b5102e1c9de480078e9f",
        "ALBUM_ARTISTS": "LiSA\nFelix of Stray Kids",
        "IS_EXPLICIT": "false",
        "DISC_NUMBER": "1",
        "NUMBER": "1",
        "PLAYER_EVENT": "track_changed",
        "DURATION_MS": "184993",
        "POPULARITY": "73",
        "URI": "spotify:track:2rOUaQ1TGj7wZdHdn9UgTL",
    }
[2025-01-18T21:19:54Z DEBUG librespot::player_event_handler] Running /home/photovoltex/repos/forks/librespot/test-env.sh with environment variables:
    {
        "PLAYER_EVENT": "playing",
        "TRACK_ID": "2rOUaQ1TGj7wZdHdn9UgTL",
        "POSITION_MS": "0",
    }

@photovoltex
Copy link
Member

Ah it seems like a pretty simple fix to your script. It seems to work when you wrap the env_vars with quotation marks and then echo seems to parse it correctly. I tested the following with zsh and it has some interesting behaviors... not what you might expect. Let me know if that worked for you :D

Warning

Doesn't work

TEST=some\ntesting; echo -e $TEST
somentesting

Tip

Works

TEST="some\ntesting"; echo -e $TEST
some
testing

Warning

Funnily enough also doesn't work

TEST=some\ntesting; echo -e "$TEST"
somentesting

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

No branches or pull requests

2 participants