A program suite for separating the frontend and backend of Emby service playback.
- This project is a frontend application for separating Emby media service playback into frontend and backend components. It works in conjunction with the playback backend PiliPili Playback Backend.
- This program is largely based on YASS-Frontend. The original version was implemented in
Python
. To achieve better compatibility, it has been rewritten inGo
and optimized to enhance usability.
- Use a specific
nginx
configuration (refer to nginx.conf) to redirect Emby playback URLs to a designated port. - The program listens for requests arriving at the port and extracts the
MediaSourceId
andItemId
. - Request the corresponding file's relative path (
EmbyPath
) from the Emby service. - Generate a signed URL by encrypting the configuration's
Encipher
value with the expiration time (expireAt
) to create asignature
. - Concatenate the backend playback URL (
backendURL
) with theEmbyPath
andsignature
. - Redirect the playback request to the generated URL for backend handling.
- Compatible with all Emby server versions.
- Supports high concurrency, handling multiple requests simultaneously.
- Support for deploying Emby server with
strm
. - Request caching, enabling fast responses for identical
MediaSourceId
andItemId
requests, reducing playback startup time. - Link signing, where the frontend generates and the backend verifies the signature. Mismatched signatures result in a
401 Unauthorized
error. - Link expiration, with an expiration time embedded in the signature to prevent unauthorized usage and continuous theft via packet sniffing.
# Logging configuration
LogLevel: "INFO" # Log level (e.g., info, debug, warn, error)
# Encryption settings
Encipher: "vPQC5LWCN2CW2opz" # Key used for encryption and obfuscation
# Emby server configuration
Emby:
url: "http://127.0.0.1" # The base URL for the Emby server
port: 8096
apiKey: "6a15d65893024675ba89ffee165f8f1c" # API key for accessing the Emby server
# Frontend related configuration
Frontend:
symlinkBasePath: "/mnt/symlink" # Design for media library for symlink
# Backend streaming configuration
Backend:
url: "https://streamer.xxxxxxxx.com/stream" # The backend URL for streaming service
storageBasePath: "/mnt/anime"
# Streaming configuration
PlayURLMaxAliveTime: 21600 # Maximum lifetime of the play URL in seconds (e.g., 6 hours)
# Server configuration
Server:
port: 60001
# Special medias configuration
SpecialMedias:
# The key values below can be filled as needed. If not required, they can be left empty.
- key: "MediaMissing"
name: "Default media for missing cases"
mediaPath: "specialMedia/mediaMissing"
itemId: "mediaMissing-item-id"
mediaSourceID: "mediaMissing-media-source-id"
- key: "September18"
name: "September 18 - Commemorative Media"
mediaPath: "specialMedia/september18"
itemId: "september18-item-id"
mediaSourceID: "september18-media-source-id"
- key: "October1"
name: "October 1 - National Day Media"
mediaPath: "specialMedia/october1"
itemId: "october1-item-id"
mediaSourceID: "october1-media-source-id"
- key: "December13"
name: "December 13 - Nanjing Massacre Commemoration"
mediaPath: "specialMedia/december13"
itemId: "december13-item-id"
mediaSourceID: "december13-media-source-id"
- key: "ChineseNewYearEve"
name: "Chinese New Year's Eve Media"
mediaPath: "specialMedia/chinesenewyeareve"
itemId: "chinesenewyeareve-item-id"
mediaSourceID: "chinesenewyeareve-media-source-id"
-
LogLevel: The log level for printing logs
WARN
: Displays all logs unless enablingDEBUG
does not meet the needs; generally, this log level is not recommended.DEBUG
: Displays logs at theDEBUG
/INFO
/ERROR
levels; if debugging is needed, it is recommended to use this level.INFO
: Displays logs at theINFO
/ERROR
levels; this level is usually sufficient under normal circumstances.ERROR
: If the system is stable enough and has reached an unattended stage, this level can be used to reduce the number of logs.
-
Encipher: The encryption factor, which is a 16-character string used for signature obfuscation. The frontend and backend must remain consistent.
-
Emby:
- url: The address where the Emby service is deployed. If the frontend application and the Emby service are on the same machine,
http://127.0.0.1
can be used. - port: The port where the Emby service is deployed, usually
8096
. Configure as needed. - apikey: The
APIKey
for the Emby service, used to retrieve media file URLs from the Emby service.
- url: The address where the Emby service is deployed. If the frontend application and the Emby service are on the same machine,
-
Frontend:
- symlinkBasePath: Design for media library for strm.
-
Backend:
- url: The URL for remote streaming.
- If using
http
, the port number must be included, e.g.,http://ip:port
. - If using
https
on port443
, the port number can be omitted, e.g.,https://streamer.xxxxxxxx.com/stream
.
- If using
- storageBasePath:
- Prerequisite: The frontend needs to map the storage path in the Emby service to the actual storage file path on the backend.
- The relative path of the directory to be hidden, relative to the remote mounted directory. For example: If the local
EmbyPath
is/mnt/anime/动漫/海贼王 (1999)/Season 22/37854 S22E1089 2160p.B-Global.mkv
, but you want to hide the/mnt
part, enter/mnt
in the frontend'sstorageBasePath
. Correspondingly, in the backend configuration, setStorageBasePath
to/mnt
. - In other words, the part of the path you want to hide must be configured in the backend.
- url: The URL for remote streaming.
-
PlayURLMaxAliveTime: The expiration time for playback links, in seconds. Typically, 6 hours (set to
21600
) is sufficient to prevent malicious packet capturing, which could otherwise allow the same link to be watched or downloaded indefinitely. -
Server:
- port: The port to be listened on. If there are no special requirements, the default value
60001
can be used.
- port: The port to be listened on. If there are no special requirements, the default value
-
SpecialMedias: Used to redirect media with special significance, such as content related to Chinese traditional holidays or historical events. Currently supported events include (There's no need for that. Just set it to null.):
- MediaMissing: Redirects to a default media file if the server file is missing.
- September18: Commemorates the "Mukden Incident" of September 18, a significant historical date for China, promoting remembrance of history, peace, and perseverance.
- October1:Celebrates October 1, China's National Day.
- December13: Commemorates China's National Memorial Day on December 13, urging remembrance of history, peace, and perseverance.
mkdir -p /data/docker/pilipili_frontend
cd /data/docker/pilipili_frontend
mkdir -p config && cd config
Copy config.yaml to the config
folder and edit it as needed.
Navigate back to the /data/docker/pilipili_frontend
directory, and copy docker-compose.yml to this directory.
docker-compose pull && docker-compose up -d
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
# Expected output: go version go1.23.5 linux/amd64
Clone the repository into a directory, e.g., /data/emby_fronted
.
git clone https://github.com/hsuyelin/PiliPili_Frontend.git /data/emby_fronted
Edit the config.yaml
file in the repository to match your setup.
Run the program in the background:
nohup go run main.go config.yaml > stream.log 2>&1 &