# @inner-dj/client

<img src="https://codeberg.org/sanin/inner-dj/raw/branch/master/packages/server/assets/images/svg/logo.svg" width="128" height="128" alt="inner-dj logo"/>

[![NPM](https://nodei.co/npm/@inner-dj/client.svg?data=n,v,u,d,s)](https://www.npmjs.com/package/@inner-dj/client)

This is the client (or player) component for [inner-dj](https://codeberg.org/sanin/inner-dj).

## Requirements

- yt-dlp
- ffplay

## Deployment

The inner-dj client is available via [npm](https://www.npmjs.com/package/@inner-dj/client).

### npm

```sh
npx @inner-dj/client
```

### pnpm

```sh
pnpm dlx @inner-dj/client
```

### single executable

Download the AMD64 Linux binary from [releases](https://codeberg.org/sanin/inner-dj/releases/latest).

```sh
chmod +x inner-dj-client_x86_64
./inner-dj-client_x86_64
```

## Configuration

By default, inner-dj client will attempt to load a configuration file at `config/config.yaml` (relative to the current working directory).
To use a custom config path, set environment variable `CONFIG`.

### Config Root

Note that comma-separated values are accepted for environment variables.

| YAML key               | Environment Var     | Type     | Description                                                                                                                                                                          | Default                          |
|------------------------|---------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| clientId               | CLIENTID            | string   | ID of your choice to identify the client to the server as                                                                                                                            | REQUIRED                         |
| server                 | SERVER              | string   | URL of the inner-dj server                                                                                                                                                           | REQUIRED                         |
| jwtSecret              | JWTSECRET           | string   | Secret for communications between client and server. Only share with server.                                                                                                         | REQUIRED                         |
| cookies                | COOKIES             | string   | Optional path to Netscape-formatted file to read cookies from. See [ how do I pass cookies to yt-dlp? ]( https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp ) | null                             |
| forceDownloadViaServer | FORCESERVERDOWNLOAD | boolean  | If true, download missing songs via the server. Otherwise download locally first and fall back to server if something goes wrong                                                     | false                            |
| downloadDir            | DOWNLOADDIR         | string   | Where audio files are stored.                                                                                                                                                        | ./downloads/ next to config file |
| maxLength              | MAXLENGTH           | number   | How long in ms to wait during each track before skipping to the next track. Set to 0 to play audio files in their entirety.                                                          | 0                                |
| standbyPool            | STANDBYPOOL         | string[] | List of songs (YouTube URLs) to shuffle through if there are no requests in the queue.                                                                                               | []                               |
| blocked                | BLOCKED             | string[] | List of YouTube URLs to reject requests for.                                                                                                                                         | []                               |

## Supplying Files

You can supply your own higher-quality audio files. Perfect for standby queue items, popular songs, or just if you've got more time than sense.

1. Find the YouTube video(s) that correspond with the song and note their ID's
1. Place the file in the downloads folder. Rename it to `<video ID>.<track name>.<file extension>`
1. Make sure no other files that match that video ID exist in the downloads folder

This process can also be used to add standby queue items for songs that do not exist on YouTube. Just choose a random 11-character video ID or borrow one from an obscure video of your choice.
