A program suite for separating the frontend and backend of Emby service playback.
- This project is the backend application for separating Emby media service playback into frontend and backend components. It is designed to work with the playback frontend PiliPili Playback Frontend.
- This program is largely based on YASS-Backend, with optimizations made for improved usability.
-
Use a specific
nginx
configuration (refer to nginx.conf to listen on a designated port for redirected playback links from the frontend. -
Parse the
path
andsignature
from the playback link. -
Decrypt the
signature
to extractmediaId
andexpireAt
:- If decryption succeeds, log the
mediaId
for debugging and validate the expiration time (expireAt
). If valid, authentication passes; otherwise, return a401 Unauthorized
error. - If decryption fails, immediately return a
401 Unauthorized
error.
- If decryption succeeds, log the
-
Combine the
StorageBasePath
from the configuration file with the parsedpath
to generate a local file path. -
Retrieve file information:
- If retrieval fails, return a
500 Internal Server Error
. - If successful, proceed to the next step.
- If retrieval fails, return a
-
Extract the
Content-Range
from the client's request headers:
- If present, resume playback from the specified range and stream the file in chunks.
- If absent, start streaming from the beginning of the file.
- Compatible with all Emby server versions.
- Supports high-concurrency requests.
- Supports signature decryption and blocks expired playback links.
# Configuration for PiliPili Backend
# LogLevel defines the level of logging (e.g., INFO, DEBUG, ERROR)
LogLevel: "INFO"
# EncryptionKey is used for encryption and obfuscation of data.
Encipher: "vPQC5LWCN2CW2opz"
# StorageBasePath is the base directory where files are stored. This is a prefix for the storage paths.
StorageBasePath: "/mnt/anime/"
# Server configuration
Server:
port: "60002" # Port on which the server will listen
LogLevel
: Logging verbosity levels:
WARN
: Minimal logging unless debugging is insufficient.DEBUG
: LogsDEBUG
,INFO
, andERROR
. Recommended for debugging.INFO
: LogsINFO
andERROR
. Suitable for regular operations.ERROR
: For stable, unattended setups, minimizes log entries.Encipher
: A 16-character encryption key for signature obfuscation. Must match between frontend and backend.StorageBasePath
:- Ensures consistency between the frontend's Emby storage path mapping and the backend's actual file paths.
- Example:
- Frontend
EmbyPath
:/mnt/anime/OnePiece/Season 22/file.mkv
. - If
/mnt
should be hidden, setStorageBasePath: "/mnt"
. - Ensure the same path is configured in the frontend.
Server
Configuration:
- Frontend
port
: Listening port, default is60002
.
- Example:
mkdir -p /data/docker/pilipili_backend
cd /data/docker/pilipili_backend
mkdir -p config && cd config
Copy config.yaml to the config
folder and edit it as needed.
Navigate back to the /data/docker/pilipili_backend
directory, and copy docker-compose.yml to this directory.
docker-compose pull && docker-compose up -d
Forcefully remove any existing Go installation to ensure version compatibility.
rm -rf /usr/local/go
wget -q -O /tmp/go.tar.gz https://go.dev/dl/go1.23.5.linux-amd64.tar.gz && tar -C /usr/local -xzf /tmp/go.tar.gz && rm /tmp/go.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc && source ~/.bashrc
go version # If the output is "go version go1.23.5 linux/amd64," the installation was successful.
For example, to clone it to the /data/emby_backend
directory:
git clone https://github.com/hsuyelin/PiliPili_Backend.git /data/emby_backend
# Configuration for PiliPili Backend
# LogLevel defines the level of logging (e.g., INFO, DEBUG, ERROR)
LogLevel: "INFO"
# EncryptionKey is used for encryption and obfuscation of data.
Encipher: "vPQC5LWCN2CW2opz"
# StorageBasePath is the base directory where files are stored. This is a prefix for the storage paths.
StorageBasePath: "/mnt/anime/"
# Server configuration
Server:
port: "60002" # Port on which the server will listen
nohup go run main.go config.yaml > streamer.log 2>&1 &