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

docs: add slskd example to readme #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lucas-dclrcq
Copy link

slskd recently allowed to run a script whenever a directory download is completed. The implementation is quite basic but it works nicely with betanin.

Comment on lines +234 to +235
read -t5 -r line
path=$(echo "$line" | awk -F'"localDirectoryName":"' '{print $2}' | awk -F'"' '{print $1}' | awk '{printf "%s", $0}')
Copy link
Owner

@sentriz sentriz Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i haven't tested, but would this work? just incase a filename has quotes in it

Suggested change
read -t5 -r line
path=$(echo "$line" | awk -F'"localDirectoryName":"' '{print $2}' | awk -F'"' '{print $1}' | awk '{printf "%s", $0}')
path="$(jq -r ".localDirectoryName")"

no need for read either since jq will receive stdin

might need to add jq to the docker image too

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it looks like the json comes as an argument to the script, not stdin

Copy link
Author

@lucas-dclrcq lucas-dclrcq Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a lot of trial and error to make it work using only the tools included in the official docker image

Copy link
Owner

@sentriz sentriz Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but I think adding jq as a dependency here https://github.com/sentriz/betanin/blob/master/Dockerfile#L38 would be fine. i think it's worth it to parse the json properly incase the directory path includes special chars like "

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think adding jq to the betanin docker image would help ^^

(the script is run by slskd)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could make a pr on the slskd Dockerfile : https://github.com/slskd/slskd/blob/master/Dockerfile
But I don't know if it would be accepted.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhaha oh yes, you're right, ofc 😁

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

2 participants