Skip to content

Instantly share code, notes, and snippets.

@likecyber
Last active November 11, 2025 12:03
Show Gist options
  • Select an option

  • Save likecyber/cefdb6a87b654ce0e8456dbd4affd071 to your computer and use it in GitHub Desktop.

Select an option

Save likecyber/cefdb6a87b654ce0e8456dbd4affd071 to your computer and use it in GitHub Desktop.
Script for Synology DSM's Emby Server to update and patch itself with free Emby Premiere.
#!/bin/bash
# The script must be executed as the root user, or it will fail.
# You must have "Container Manager" installed before running this script.
# Additionally, "Emby Server" must be running or the script will do nothing.
# Manually run the script once to apply free Emby Premiere patch.
# Make sure to update the ASSET_PREFIX and ASSET_SUFFIX based on your Synology model.
# Check your asset prefix and suffix from here: https://github.com/MediaBrowser/Emby.Releases/releases/latest
# CAUTION: Tested only on emby-server-synology72_4.8.10.0_x86_64.spk. Compatibility with other versions is no guarantee.
CONTAINER="emby-premiere"
IMAGE="docker-emby-premiere"
WORKDIR="/volume1/docker-emby-premiere"
ASSET_PREFIX="emby-server-synology72_"
ASSET_SUFFIX="_x86_64.spk"
HOSTNAME="mb3admin.com"
HOSTS="/etc/hosts"
PKG="EmbyServer"
SPK="emby-server.spk"
if [ "$(synopkg status "$PKG" | jq -r ".aspect.active.status")" != "running" ]; then
exit 0
fi
if [ ! -d "$WORKDIR/certs" ]; then
mkdir -p "$WORKDIR/certs"
fi
cd "$WORKDIR"
if [ ! -f "certs/emby.crt" ] || [ ! -f "certs/emby.key" ]; then
openssl req -x509 -newkey rsa:2048 -days 36525 -nodes -subj '/CN=mb3admin.com' -addext "subjectAltName = DNS:www.mb3admin.com, DNS:mb3admin.com" -out "certs/emby.crt" -keyout "certs/emby.key"
fi
if [ ! -f "certs/ssl-dhparams.pem" ]; then
curl -sSL "https://ssl-config.mozilla.org/ffdhe2048.txt" > "certs/ssl-dhparams.pem"
fi
if [ -z "$(docker images --quiet "$IMAGE")" ]; then
if [ ! -f "nginx.conf" ]; then
echo -e "events {\n\tworker_connections 4096;\n}\n\nhttp {\n\tserver {\n\t\tlisten 443 ssl http2;\n\t\tlisten [::]:443 ssl http2;\n\t\tserver_name mb3admin.com;\n\n\t\tssl_certificate /certs/emby.crt;\n\t\tssl_certificate_key /certs/emby.key;\n\t\tssl_session_timeout 1d;\n\t\tssl_session_cache shared:SSL:10m;\n\t\tssl_session_tickets off;\n\n\t\tssl_dhparam /certs/ssl-dhparams.pem;\n\n\t\tssl_protocols TLSv1.2 TLSv1.3;\n\t\tssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;\n\t\tssl_prefer_server_ciphers off;\n\n\t\tlocation / {\n\t\t\tresolver 1.1.1.1 ipv6=off;\n\t\t\tset \$target https://mb3admin.com;\n\t\t\tproxy_pass \$target;\n\t\t\tproxy_set_header Host \$host;\n\t\t\tproxy_set_header X-Real-IP \$remote_addr;\n\t\t\tproxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\n\t\t\tproxy_set_header X-Forwarded-Proto \$scheme;\n\t\t}\n\n\t\tlocation /admin/service/registration/validateDevice {\n\t\t\tdefault_type application/json;\n\t\t\treturn 200 '{\"cacheExpirationDays\":3650,\"message\":\"Device Valid (limit not checked)\",\"resultCode\":\"GOOD\"}';\n\t\t}\n\n\t\tlocation /admin/service/registration/validate {\n\t\t\tdefault_type application/json;\n\t\t\treturn 200 '{\"featId\":\"\",\"registered\":true,\"expDate\":\"2099-01-01\",\"key\":\"\"}';\n\t\t}\n\n\t\tlocation /admin/service/registration/getStatus {\n\t\t\tdefault_type application/json;\n\t\t\treturn 200 '{\"planType\":\"Lifetime\",\"deviceStatus\":0,\"subscriptions\":[]}';\n\t\t}\n\n\t\tlocation /admin/service/appstore/register {\n\t\t\tdefault_type application/json;\n\t\t\treturn 200 '{\"featId\":\"\",\"registered\":true,\"expDate\":\"2099-01-01\",\"key\":\"\"}';\n\t\t}\n\n\t\tadd_header Access-Control-Allow-Origin * always;\n\t\tadd_header Access-Control-Allow-Headers * always;\n\t\tadd_header Access-Control-Allow-Method * always;\n\t\tadd_header Access-Control-Allow-Credentials true always;\n\t}\n}" > "nginx.conf"
fi
if [ ! -f "Dockerfile" ]; then
echo -e "FROM nginx\nCOPY nginx.conf /etc/nginx/nginx.conf" > "Dockerfile"
fi
docker build --no-cache --tag "$IMAGE" .
fi
if ! docker ps --filter "name=$CONTAINER" --format "{{.Names}}" | grep -qx "$CONTAINER"; then
if docker ps --all --filter "name=$CONTAINER" --format "{{.Names}}" | grep -qx "$CONTAINER"; then
docker rm "$CONTAINER"
fi
docker run --name "$CONTAINER" --volume "$WORKDIR/certs:/certs" --restart "unless-stopped" --detach "$IMAGE:latest"
fi
container_ip=$(docker inspect --format "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" "$CONTAINER")
if ! grep -qx "$container_ip $HOSTNAME" "$HOSTS"; then
if grep -qw "$HOSTNAME" "$HOSTS"; then
sed -i "/$HOSTNAME/c\\$container_ip $HOSTNAME" "$HOSTS"
else
echo "$container_ip $HOSTNAME" >> "$HOSTS"
fi
fi
current_build=$(synopkg version "$PKG")
current_version=$(echo $current_build | cut -d'-' -f1)
latest_release=$(curl -sSL "https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest")
latest_version=$(echo $latest_release | jq -r ".name")
if [ "$current_version" != "$latest_version" ]; then
curl -sSL -o "$SPK" "$(echo $latest_release | jq -r ".assets[] | select(.name | startswith(\"$ASSET_PREFIX\") and endswith(\"$ASSET_SUFFIX\")) | .browser_download_url")"
latest_build=$(synopkg query "$SPK" | grep -oP "Package version:\s+\K[^\s]+")
if [ "$current_build" != "$latest_build" ]; then
synopkg stop "$PKG"
install_result=$(synopkg install "$SPK")
if [ "$(echo $install_result | jq -r '.success')" != "true" ]; then
echo "$SPK Installation Error!"
echo "$install_result"
exit 1
fi
fi
rm -f "$SPK"
fi
if [ ! -f "/var/packages/$PKG/target/patched" ]; then
synopkg stop "$PKG"
cat "certs/emby.crt" >> "/var/packages/$PKG/target/etc/ssl/certs/ca-certificates.crt"
echo "window.originalFetch=window.fetch,window.fetch=function(t,e){return t.startsWith('https://$HOSTNAME/admin/service/registration/validateDevice')?Promise.resolve({status:200,json:()=>({cacheExpirationDays:3650,message:'Device Valid (limit not checked)',resultCode:'GOOD'})}):t.startsWith('https://$HOSTNAME/admin/service/registration/getStatus')?Promise.resolve({status:200,json:()=>({planType:'Lifetime',deviceStatus:0,subscriptions:[]})}):originalFetch(t,e)};" >> "/var/packages/$PKG/target/system/dashboard-ui/apploader.js"
touch "/var/packages/$PKG/target/patched"
synopkg start "$PKG"
fi
@thebaskos
Copy link

thebaskos commented Feb 4, 2025

Just put any numbers in to the "key" field and press registration button

did, wrote "your emby premiere key has been updated" then a loading circle and nothing happens

P.S. I don't know how it happened, but now the server is activated. Thank you so much

@0v3rCl0cKeR
Copy link

Works fine with emby-server-synology72_4.8.11.0_x86_64.spk

@apexcz1
Copy link

apexcz1 commented Aug 19, 2025

arm8 working

@apexcz1
Copy link

apexcz1 commented Aug 19, 2025

patch working but if i want play video from ios problem with premium still there

@likecyber
Copy link
Author

patch working but if i want play video from ios problem with premium still there

Emby Premiere patch only works on the web version, as all other platform clients check for the license on the client side.

@kinslayer1982
Copy link

patch working but if i want play video from ios problem with premium still there

Emby Premiere patch only works on the web version, as all other platform clients check for the license on the client side.

Had a patch for Emby Premiere for quite some time, but github deleted it. There was a way to make it work with mobile devices (at least Android worked) by running a fake mb3admin.com website using for example nginx in docker. But I don't have the exact details anymore.

@likecyber
Copy link
Author

patch working but if i want play video from ios problem with premium still there

Emby Premiere patch only works on the web version, as all other platform clients check for the license on the client side.

Had a patch for Emby Premiere for quite some time, but github deleted it. There was a way to make it work with mobile devices (at least Android worked) by running a fake mb3admin.com website using for example nginx in docker. But I don't have the exact details anymore.

That is exactly how my script works for the web client platform.
It can indeed be done on the client platforms, but it's a bit trickier.
It is worth mentioning that this patch will break when the developer of Emby releases a new version.
I believe some other developers have found a new method for free Emby Premiere. But for me, that may be for another time.

@likecyber
Copy link
Author

The developer has just released Emby 4.9.1.80 about an hour ago.

This update is expected to break my Emby Premiere patch.
However, they have not yet released the installer with the "emby-server-synology*" prefix.
Even when it becomes available, I will likely be too busy to update immediately.

I recommend that everyone using this script temporarily stop until the update is tested, to avoid breaking your Emby setup.

@Mihrutkin
Copy link

Mihrutkin commented Oct 14, 2025

Hello, please help:

sudo -i /volume1/downloads/EmbyUpdateWithPatch.sh
{"action":"stop","beta":false,"error":{"code":0},"finished":true,"language":"enu","last_stage":"stopped","package":"EmbyServer","pid":2884,"scripts":[{"code":0,"message":"","type":"stop"}],"stage":"stopped","status":"stop","status_code":324,"status_description":"translate from systemd status","success":true,"username":"","version":"4.8.11.0-724081100"}
{"action":"prepare","error":{"code":0},"stage":"prepare","success":true}
{"action":"start","beta":false,"error":{"code":0},"finished":true,"language":"enu","last_stage":"started","package":"EmbyServer","pid":4432,"scripts":[{"code":0,"message":"","type":"start"}],"stage":"started","status":"running","success":true,"username":"","version":"4.9.1.80-724090180"}

Dont crack

@OUARZA
Copy link

OUARZA commented Nov 11, 2025

Hello, is it possible to have the version without docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment