From c1965de87363331b07256ee4e4918d76125c3cf8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Jul 2026 07:01:05 +0000 Subject: [PATCH] Add Spotify to Plex add-on New add-on wrapping the upstream jjdenhertog/spotify-to-plex Docker image (requested in issue #2814). Keeps Spotify playlists synced to Plex. - Wraps the multi-arch upstream image via BUILD_FROM (amd64 + aarch64) - Uses the shared ha_entrypoint framework with 00-global_var.sh so add-on options (Spotify credentials, redirect URI, encryption key) become the environment variables the app expects - 99-run.sh persists /app/config into the add-on config dir, auto-generates and stores a stable ENCRYPTION_KEY when left blank, then hands off to the upstream supervisord - Web UI exposed directly on port 9030 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01NZTfSk3GQRU7oD85TnjsmW --- spotify_to_plex/CHANGELOG.md | 2 + spotify_to_plex/Dockerfile | 135 ++++++++++++++++++ spotify_to_plex/README.md | 75 ++++++++++ spotify_to_plex/build.json | 6 + spotify_to_plex/config.yaml | 34 +++++ .../rootfs/etc/cont-init.d/99-run.sh | 29 ++++ spotify_to_plex/updater.json | 8 ++ 7 files changed, 289 insertions(+) create mode 100644 spotify_to_plex/CHANGELOG.md create mode 100644 spotify_to_plex/Dockerfile create mode 100644 spotify_to_plex/README.md create mode 100644 spotify_to_plex/build.json create mode 100644 spotify_to_plex/config.yaml create mode 100644 spotify_to_plex/rootfs/etc/cont-init.d/99-run.sh create mode 100644 spotify_to_plex/updater.json diff --git a/spotify_to_plex/CHANGELOG.md b/spotify_to_plex/CHANGELOG.md new file mode 100644 index 0000000000..784415f55b --- /dev/null +++ b/spotify_to_plex/CHANGELOG.md @@ -0,0 +1,2 @@ +## 1.0.104 (2026-07-06) +- Initial release: Spotify to Plex add-on based on jjdenhertog/spotify-to-plex diff --git a/spotify_to_plex/Dockerfile b/spotify_to_plex/Dockerfile new file mode 100644 index 0000000000..644d14ed8d --- /dev/null +++ b/spotify_to_plex/Dockerfile @@ -0,0 +1,135 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_FROM + +FROM ${BUILD_FROM} + +################## +# 2 Modify Image # +################## + +# Set S6 wait time +ENV S6_CMD_WAIT_FOR_SERVICES=1 \ + S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \ + S6_SERVICES_GRACETIME=0 + +USER root + +################## +# 3 Install apps # +################## + +# Copy local files +COPY rootfs/ / +RUN find . -type f \( -name "*.sh" -o -name "run" -o -name "finish" \) -print -exec chmod +x {} \; + +# Uses /bin for compatibility purposes +# hadolint ignore=DL4005 +RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \ + if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi + +# Modules +ARG MODULES="00-banner.sh 00-global_var.sh 01-custom_script.sh" + +# Automatic modules download +COPY ha_automodules.sh /ha_automodules.sh +RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh + +# Manual apps +ENV PACKAGES="jq" + +# Automatic apps & bashio +COPY ha_autoapps.sh /ha_autoapps.sh +RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh + +EXPOSE 9030 + +################ +# 4 Entrypoint # +################ + +# Add entrypoint +ENV S6_STAGE2_HOOK=/ha_entrypoint.sh +COPY ha_entrypoint.sh /ha_entrypoint.sh +RUN chmod 777 /ha_entrypoint.sh + +# Install bashio +COPY bashio-standalone.sh /usr/local/lib/bashio-standalone.sh +RUN chmod 0755 /usr/local/lib/bashio-standalone.sh + +ENTRYPOINT [ "/usr/bin/env" ] +CMD [ "/ha_entrypoint.sh" ] + +############ +# 5 Labels # +############ + +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION +ENV BUILD_VERSION="${BUILD_VERSION}" +LABEL \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.title="${BUILD_NAME}" \ + org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Add-ons" \ + org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/alexbelgium" \ + org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ + org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} + +################# +# 6 Healthcheck # +################# + +# Avoid spamming logs +# hadolint ignore=SC2016 +RUN \ + # Handle Apache configuration + if [ -d /etc/apache2/sites-available ]; then \ + for file in /etc/apache2/sites-*/*.conf; do \ + sed -i '/ /etc/nginx/nginx.conf.new && \ + mv /etc/nginx/nginx.conf.new /etc/nginx/nginx.conf; \ + fi + +ENV HEALTH_PORT="9030" \ + HEALTH_URL="" +HEALTHCHECK \ + --interval=5s \ + --retries=5 \ + --start-period=30s \ + --timeout=25s \ + CMD curl -A "HealthCheck: Docker/1.0" -s -f "http://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" &>/dev/null || exit 1 diff --git a/spotify_to_plex/README.md b/spotify_to_plex/README.md new file mode 100644 index 0000000000..e6ba819b0c --- /dev/null +++ b/spotify_to_plex/README.md @@ -0,0 +1,75 @@ +# Home assistant add-on: Spotify to Plex + + +I maintain this and other Home Assistant add-ons in my free time: keeping up with upstream changes, HA changes, and testing on real hardware takes a lot of time (and some money). I use around 5-10 of my >110 addons so regularly I install test machines (and purchase some test services such as vpn) that I don't use myself to troubleshoot and improve the addons + +If this add-on saves you time or makes your setup easier, I would be very grateful for your support! + +[![Buy me a coffee][donation-badge]](https://www.buymeacoffee.com/alexbelgium) +[![Donate via PayPal][paypal-badge]](https://www.paypal.com/donate/?hosted_button_id=DZFULJZTP3UQA) + +## Addon informations + +![Version](https://img.shields.io/badge/dynamic/yaml?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fspotify_to_plex%2Fconfig.yaml) +![Ingress](https://img.shields.io/badge/dynamic/yaml?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fspotify_to_plex%2Fconfig.yaml) +![Arch](https://img.shields.io/badge/dynamic/yaml?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fspotify_to_plex%2Fconfig.yaml) + +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9c6cf10bdbba45ecb202d7f579b5be0e)](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade) +[![GitHub Super-Linter](https://img.shields.io/github/actions/workflow/status/alexbelgium/hassio-addons/weekly-supelinter.yaml?label=Lint%20code%20base)](https://github.com/alexbelgium/hassio-addons/actions/workflows/weekly-supelinter.yaml) +[![Builder](https://img.shields.io/github/actions/workflow/status/alexbelgium/hassio-addons/onpush_builder.yaml?label=Builder)](https://github.com/alexbelgium/hassio-addons/actions/workflows/onpush_builder.yaml) + +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white +[paypal-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee%20Paypal-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white + +_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_ + +[![Stargazers repo roster for @alexbelgium/hassio-addons](https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.github/stars2.svg)](https://github.com/alexbelgium/hassio-addons/stargazers) + +## About + +This addon is based on the [docker image](https://hub.docker.com/r/jjdenhertog/spotify-to-plex) from [jjdenhertog/spotify-to-plex](https://github.com/jjdenhertog/spotify-to-plex). + +It keeps your Spotify playlists synced to Plex automatically: syncing any Spotify playlist (including Spotify-owned ones), supporting multiple Spotify users, scheduled automatic synchronization, smart caching and optional downloading of missing tracks via Lidarr, SLSKD or Tidal. + +## Configuration + +Before starting the add-on you need a Spotify developer application (https://developer.spotify.com/dashboard): + +1. Create an app and note its `Client ID` and `Client Secret`. +1. In the app settings, add the redirect URI `https://jjdenhertog.github.io/spotify-to-plex/callback.html` (this is the default `SPOTIFY_API_REDIRECT_URI`; change it only if you self-host the callback page). + +Fill the add-on options: + +| Option | Description | +|--------|-------------| +| `SPOTIFY_API_CLIENT_ID` | Client ID of your Spotify developer application | +| `SPOTIFY_API_CLIENT_SECRET` | Client secret of your Spotify developer application | +| `SPOTIFY_API_REDIRECT_URI` | OAuth redirect URI (must match the one configured in your Spotify app) | +| `ENCRYPTION_KEY` | Key used to encrypt stored secrets. **Leave empty** to have the add-on generate a random key on first start and persist it in the add-on config folder. Provide your own only if you want to reuse an existing configuration. | + +Use the add-on `env_vars` option to pass any extra upstream environment variables (for example Tidal, SLSKD, Lidarr or Plex settings). See https://github.com/alexbelgium/hassio-addons/wiki/Add-Environment-variables-to-your-Addon-2 for details. + +The configuration and cache are stored in the add-on config folder (`/addon_configs/`), so they survive restarts and updates. + +Webui can be found at `:9030`. + +## Installation + +The installation of this add-on is pretty straightforward and not different in +comparison to installing any other Hass.io add-on. + +1. Add my add-ons repository to your home assistant instance (in supervisor addons store at top right, or click button below if you have configured my HA) + [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons) +1. Install this add-on. +1. Set the required options (Spotify Client ID and Secret). +1. Click the `Save` button to store your configuration. +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Open the webui, where you will finish the setup and connect your Spotify and Plex accounts. + +## Support + +For issues related to the add-on packaging, open an issue on [alexbelgium/hassio-addons](https://github.com/alexbelgium/hassio-addons/issues). +For issues related to the application itself, refer to the [upstream project](https://github.com/jjdenhertog/spotify-to-plex). + +[repository]: https://github.com/alexbelgium/hassio-addons diff --git a/spotify_to_plex/build.json b/spotify_to_plex/build.json new file mode 100644 index 0000000000..f54b721e47 --- /dev/null +++ b/spotify_to_plex/build.json @@ -0,0 +1,6 @@ +{ + "build_from": { + "aarch64": "jjdenhertog/spotify-to-plex:1.0.104", + "amd64": "jjdenhertog/spotify-to-plex:1.0.104" + } +} diff --git a/spotify_to_plex/config.yaml b/spotify_to_plex/config.yaml new file mode 100644 index 0000000000..c5137ce273 --- /dev/null +++ b/spotify_to_plex/config.yaml @@ -0,0 +1,34 @@ +arch: + - amd64 + - aarch64 +description: Sync Spotify playlists to Plex +environment: + STORAGE_DIR: /config +image: ghcr.io/alexbelgium/spotify_to_plex-{arch} +init: false +map: + - addon_config:rw +name: Spotify to Plex +options: + env_vars: [] + SPOTIFY_API_CLIENT_ID: "" + SPOTIFY_API_CLIENT_SECRET: "" + SPOTIFY_API_REDIRECT_URI: "https://jjdenhertog.github.io/spotify-to-plex/callback.html" + ENCRYPTION_KEY: "" +panel_icon: mdi:spotify +ports: + 9030/tcp: 9030 +ports_description: + 9030/tcp: Web interface +schema: + env_vars: + - name: match(^[A-Za-z0-9_]+$) + value: str? + SPOTIFY_API_CLIENT_ID: str? + SPOTIFY_API_CLIENT_SECRET: str? + SPOTIFY_API_REDIRECT_URI: str? + ENCRYPTION_KEY: str? +slug: spotify_to_plex +url: https://github.com/alexbelgium/hassio-addons/tree/master/spotify_to_plex +version: "1.0.104" +webui: "http://[HOST]:[PORT:9030]" diff --git a/spotify_to_plex/rootfs/etc/cont-init.d/99-run.sh b/spotify_to_plex/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 0000000000..c4436ce16b --- /dev/null +++ b/spotify_to_plex/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +bashio::log.info "Starting Spotify to Plex" + +# Persist the app's /app/config into the HA add-on config dir (/config) +CONFIG_TARGET="/config" +mkdir -p "$CONFIG_TARGET" +if [ -d /app/config ] && [ ! -L /app/config ]; then + cp -rn /app/config/. "$CONFIG_TARGET/" 2> /dev/null || true + rm -rf /app/config +fi +ln -sfn "$CONFIG_TARGET" /app/config + +# Auto-generate a persistent ENCRYPTION_KEY when the user leaves it blank +if [ -z "${ENCRYPTION_KEY:-}" ]; then + if [ -f "$CONFIG_TARGET/.encryption_key" ]; then + ENCRYPTION_KEY="$(cat "$CONFIG_TARGET/.encryption_key")" + else + ENCRYPTION_KEY="$(head -c 32 /dev/urandom | base64)" + echo "$ENCRYPTION_KEY" > "$CONFIG_TARGET/.encryption_key" + bashio::log.info "Generated a new ENCRYPTION_KEY (stored in the add-on config dir)" + fi + export ENCRYPTION_KEY +fi + +# Hand off to the upstream supervisord (web + scraper + scheduler) +cd /app || true +exec /docker-entrypoint.sh supervisord -n -c /etc/supervisor/conf.d/supervisord.conf diff --git a/spotify_to_plex/updater.json b/spotify_to_plex/updater.json new file mode 100644 index 0000000000..cf1deb6a8f --- /dev/null +++ b/spotify_to_plex/updater.json @@ -0,0 +1,8 @@ +{ + "last_update": "2026-07-06", + "repository": "alexbelgium/hassio-addons", + "slug": "spotify_to_plex", + "source": "dockerhub", + "upstream_repo": "jjdenhertog/spotify-to-plex", + "upstream_version": "1.0.104" +}