samp.directory
← Scripts and libraries

Shazanxz/autoplay

MP3 playlist generator with a direct link for SA:MP audiostream.

Tool★ 0updated 2 days agoMITJavaScript
Open on GitHub

README.md

Autoplay

MP3 playlist generator with a direct link for SA-MP audiostream.
Upload up to 10 songs, pick a link name and get a URL ready to use on your server.

🇧🇷 Português · 🇺🇸 English

Getting started · Configuration · API · Structure · License


What is it?

Autoplay merges several audio tracks into a single .mp3 file and gives you a link like http://your-site/name.mp3, ready to be used with SA:MP audiostream.

Features

  • Merges up to 10 tracks (MP3, WAV, M4A, OGG, FLAC, AAC, OPUS and WEBM) into one 192 kbps stereo .mp3, with no gaps between them
  • Custom link: you choose the playlist name, and the site checks whether it is available
  • Per-user library: listen to, copy the link of and delete playlists
  • Limits and protection: playlist and storage quotas per user, a conversion queue and rate limiting
  • No external services: SQLite database (better-sqlite3) and bundled ffmpeg (ffmpeg-static)

Getting started

Show step by step

Requires Node.js 20 or higher. ffmpeg is bundled, so there is nothing else to install.

git clone https://github.com/shazanxz/autoplay.git
cd autoplay
npm install
cp .env.example .env
npm run gen-secret

Paste the generated value into JWT_SECRET in your .env and start the server:

npm start

Open http://localhost:3000. During development, use npm run dev (restarts on save).

When running locally without a reverse proxy, set TRUST_PROXY=0 in your .env.

Configuration (.env)

Show environment variables
VariableDefaultDescription
NODE_ENVdevelopmentIn production, JWT_SECRET becomes required
PORT / HOST3000 / 0.0.0.0Server address
JWT_SECRETgenerated in data/ (dev only)JWT secret, at least 32 characters
PASSWORD_PEPPERemptyExtra secret mixed into the Argon2 hash. Set it before registering users: changing it later invalidates existing passwords
TRUST_PROXY1Number of trusted proxies in front of the app (0 if none)
STREAM_PROTOCOLhttpProtocol of generated links (SA-MP requires http)
PUBLIC_HOSTrequest hostFixed domain used in links
MAX_PLAYLISTS_PER_USER20Playlist limit per user
USER_QUOTA_MB300Storage per user
MAX_CONCURRENT_JOBS2Simultaneous audio conversions
ARGON2_MEMORY_KIB / ARGON2_TIME_COST / ARGON2_PARALLELISM19456 / 2 / 1Argon2id cost
ARGON2_MAX_CONCURRENT2Simultaneous password hashes

Limits

ItemValue
Tracks per playlist10
Duration per track6 minutes
Size per file20 MB
Playlists per user20 (configurable)
Storage per user300 MB (configurable)
Password8 to 128 characters

Project structure

Show folder structure
autoplay/
├── .github/workflows/ci.yml     Automated tests (Node 20 and 22)
├── src/
│   ├── config/                  Environment variables and JWT secret
│   ├── db/                      SQLite connection, schema, legacy migration and repositories
│   ├── auth/                    Sessions and auth middleware
│   ├── middleware/              Language, security (CSP), rate limit, upload, quota and errors
│   ├── services/                Audio conversion (ffmpeg), job queue and playlist rules
│   ├── routes/                  API routes
│   ├── i18n/                    Server messages (pt-BR and en)
│   └── utils/                   Helpers
├── public/
│   ├── index.html
│   ├── icons/sprite.svg         SVG icons
│   ├── css/
│   └── js/                      ES modules: features/, ui/, utils/ and locales/
├── scripts/                     Utilities (gen-secret)
├── test/                        Integration tests (node:test)
├── .env.example
├── package.json
├── README.md
├── README.pt-BR.md
└── LICENSE

API

All routes live under /api. The language of error messages comes from the X-Lang header.

RouteAuthDescription
POST /api/registernoCreates an account
POST /api/loginnoSigns in and returns the token
POST /api/logoutyesEnds the session
GET /api/meyesCurrent user data
GET /api/check-slug/:slugnoChecks whether a link name is available
POST /api/create-playlistyesUploads tracks and generates the playlist
GET /api/playlist/:slugnoPlaylist data
GET /api/my/playlistsyesThe user's playlists
DELETE /api/playlist/:slugyesDeletes a playlist

Generated playlists are served at /{slug}.mp3.

Languages

The front end uses the dictionaries in public/js/locales/ and the server uses src/i18n/locales/. The client sends its language in the X-Lang header, and API error messages come back already translated. To add a language, create the file in both folders and register it in public/js/i18n.js and src/i18n/index.js.

Migrating from old versions

If data/users.json and data/playlists.json exist (the JSON-file version), they are imported into SQLite on first run and renamed to .migrated. Accounts with legacy (scrypt) passwords keep working and are converted to Argon2id on their next login.

Deployment

In production, set NODE_ENV=production and JWT_SECRET, and keep the data/ and streams/ folders on persistent disk.

License

Distributed under the MIT license. You may use, copy, modify and distribute it, keeping the copyright notice.

audiostreamaudiostreamgeneratoropenmpplaylistsamp

This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing

Shazanxz/autoplay: SA-MP Tool | samp.directory