URLCustomDiscsAPI is the remote service that powers the URLCustomDiscs Minecraft plugin. It is hosted on a dedicated Hetzner VPS, ensuring reliable performance and full control over all backend operations.
When a Minecraft server makes its first request to the API, it is registered and receives a unique token. This token links the server to its own isolated resource pack, which is dynamically generated and updated based on audio URLs submitted by players.
The API manages the entire process:
- It downloads audio from supported URLs using yt-dlp (with authentication cookie when required),
- Converts the audio into Minecraft’s compatible format using FFmpeg,
- Injects or removes tracks from the server's dedicated resource pack,
- And finally, uploads this updated resource pack to Cloudflare R2, a highly scalable cloud storage service used to securely host and distribute the packs.
This setup allows each server to have a private, persistent resource pack stored in the cloud, enabling it to serve custom audio discs in real time without manual uploads, server restarts, or the need to host external tools like a HTTP server for serving the resource pack or installing and managing yt-dlp and FFmpeg locally.
The URLCustomDiscs.jar plugin is available for download in the Releases section of the URLCustomDiscs GitHub repository.
It is also available on Modrinth.
This API uses the following external tools:
- Deno, from the Deno GitHub repository, licensed under the MIT License
- yt-dlp, from the yt-dlp GitHub repository, licensed under the Unlicense
- FFmpeg, from the FFmpeg Static Builds, licensed under the GNU General Public License version 3 (GPLv3)
- Deno is used by yt-dlp to interpret YouTube’s JavaScript and decrypt its signature cipher, which is required to extract and download audio data from YouTube.
- yt-dlp downloads MP3 audio files from YouTube URLs.
- FFmpeg converts MP3 files to Ogg Vorbis format for Minecraft compatibility.
- Token-based server isolation: Each Minecraft server is assigned a unique token, linking it to its own private and isolated resource pack.
- Dynamic disc management: Servers can add or remove custom audio discs at any time using the API, without restarts or manual uploads.
- Audio processing pipeline: Audio is downloaded via yt-dlp (with an authentication cookie if needed), then converted to Ogg Vorbis using FFmpeg for Minecraft compatibility.
- Automatic deno and yt-dlp updates: Keeps deno and yt-dlp up to date to maintain compatibility with platforms like YouTube.
- Cloud-based storage: Resource packs are uploaded and served from Cloudflare R2, ensuring fast and scalable delivery.
- Scalable and reliable infrastructure: Hosted on a dedicated Hetzner VPS with full control over processing and storage.
- Size limitations: Enforces a maximum resource pack size of 80 MB, a limit of 10 custom discs per server, and a maximum duration of 5 minutes per audio track.
- Concurrent request management: Only 2 server tokens can have active creation or deletion requests at a time, reducing memory usage and avoiding overload.
- Rate limiting: Each token is limited to 6 requests per minute to prevent abuse and ensure system stability.
- Request queuing per token: Ensures safe and ordered processing by handling one request at a time per server token.
- Automatic cleanup of inactive servers: Tokens and resource packs are deleted after 90 days of inactivity to free up resources.
- Robust error handling: Clear JSON responses and meaningful HTTP status codes are returned for all success and failure cases.
Every request to the API must include a token that uniquely identifies a registered Minecraft server.
- Purpose: The token ensures that each Minecraft server has isolated access to its own resource pack and data.
- Usage: The token must be included in the JSON body of the request.
- Generated by: A unique token is generated and assigned when a Minecraft server registers for the first time by creating a custom disc.
- Required for:
- Identifying the Minecraft server and its associated resource pack.
- Uploading or removing custom discs in the resource pack.
- Enforcing active tokens concurrency limit for creation and deletion requests.
- Applying rate limiting and managing request queues per token.
- Tracking Minecraft servers activity to enable automatic cleanup of unused tokens and resource packs.
To prevent request spamming, the API enforces rate limiting per token:
- Maximum 6 requests per minute per token.
- If this limit is exceeded, the API doesn't add the request to the request queue.
To reduce memory usage, the API allows a maximum of 2 active tokens (Minecraft servers) at the same time for custom disc creation and deletion requests.
- Only 2 different server tokens can have pending requests being processed concurrently.
- If more than 2 tokens send requests simultaneously, excess requests are ignored until one of the active tokens finishes.
This prevents overload from too many concurrent audio conversions and resource pack updates.
To avoid conflicts when modifying resource packs, the API processes requests sequentially per token using a request queue:
- Requests for the same token are enqueued and processed in order.
This ensures resource pack consistency and prevents race conditions.
To keep the API and storage clean, the system automatically removes inactive Minecraft server tokens and their corresponding resource pack from Cloudflare R2 if unused for over 3 months.
- Activity includes: disc creation or deletion using the token.
- If no activity is detected on a token after 90 days, the following cleanup occurs:
- The token is unregistered from the system.
- The Minecraft server’s resource pack is deleted from Cloudflare R2.
- This cleanup runs automatically every Monday at 3:00 AM (America / New York timezone) using a scheduled cron job.
This ensures that storage and server-side resources are used efficiently, and that inactive Minecraft servers don’t retain unnecessary data indefinitely.
The API returns clear JSON responses indicating success or failure for each request.
Errors such as rate limit exceeded, invalid tokens, or internal server issues are properly handled and communicated with appropriate HTTP status codes and messages.
Create a Cloudflare R2 bucket and Account API Token. Create your own .env with .env.example, then:
npm init -y
npm install express cors body-parser uuid @aws-sdk/client-s3 dotenv tar lzma-native extract-zip adm-zip node-cron
npm start
npm init -y
npm install express cors body-parser
npm install uuid
# SDK AWS S3
npm install @aws-sdk/client-s3
npm install dotenv
npm install tar
npm install lzma-native
npm install extract-zip
npm install adm-zip
npm install node-cron
npm install multer
npm install unzipper
sudo npm start
node scripts/setupBinaries.js
node scripts/cleanupInactiveTokens.js