Skip to content

Instantly share code, notes, and snippets.

@pbogre
Last active December 19, 2024 21:00
Show Gist options
  • Save pbogre/80656086586c1523c892b7086e3eee4a to your computer and use it in GitHub Desktop.
Save pbogre/80656086586c1523c892b7086e3eee4a to your computer and use it in GitHub Desktop.
Slskd + Betanin Integration Script

Slskd + Betanin Integration

This script aims to use slskd's recent EventBus update to send import requests to betanin whenever a directory has completed downloading.

Using this Script with Docker

  1. Place this script wherever you want in your host

/home/user/slskd_to_betanin.sh

  1. Give execution permission to the script

chmod +x /home/user/slskd_to_betanin.sh

  1. Add a volume that gives access to the script to the slskd container
# ...
volumes:
  - /home/user/slskd_to_betanin.sh:/slskd_to_betanin.sh:ro
# ...
  1. Create an slskd integration that runs this script by editing your slskd config
integration:
  scripts:
    to_betanin:
      on:
        - DownloadDirectoryComplete
      run: /bin/sh /slskd_to_betanin.sh '$DATA'
  1. Restart your slskd container, and everything should work

Troubleshooting

  • The assumed slskd download path is /downloads/complete. If yours is different you should update the sed command used in the first line to match it (remember to escape backslashes)

    e.g., if your slskd path is /music/downloads, then the sed command becomes sed 's/.*"localDirectoryName":"\/music\/downloads\/\([^"]*\)".*/\1/'

  • The assumed betanin download path is /downloads. If yours is different, simply change the value of the post data in the wget command, specifically the path variable.

#!/bin/bash
name=$(echo "$1" | sed 's/.*"localDirectoryName":"\/downloads\/complete\/\([^"]*\)".*/\1/')
wget -q -O/dev/null \
--post-data "name=$name&path=/downloads" \
--header="X-API-KEY: $BETANIN_API_KEY" \
--header="User-Agent: slskd_to_betanin.sh" \
http://$BETANIN_IP:$BETANIN_PORT/api/torrents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment