Guide / 08
S.O.K Server
Install S.O.K on a NAS or a home server with Docker, and organize your downloads from a web page.
S.O.K Server is the same engine as the app, in a Docker image with a web interface. Install it on a NAS or a home server, point it at your download folders, and organize them from any browser, on a computer, a tablet or a phone: it finds what each file is, shows the new names, and puts everything away at once or row by row. Or let it sort new downloads on its own, and tell Discord, Jellyfin or Plex.
It uses hard links by default: the renamed file and the download are the same file on the disk, so your torrents keep seeding without taking more space.
Try the demo: the real interface in your browser, with an example library. Nothing to install, and no file is renamed.
Install it
S.O.K Server runs on any machine with Docker, on Intel/AMD and ARM (amd64, arm64). Create a docker-compose.yml:
services:
sok-server:
image: ghcr.io/opalehq/sok-server:latest
container_name: sok-server
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Paris
volumes:
- /srv/sok/config:/config
- /mnt/storage:/data
ports:
- 8080:8080
restart: unless-stopped
Then start it with docker compose up -d, and open http://<your-server>:8080.
| Setting | What it does |
|---|---|
/config |
The settings, the database, the history and the logs. Keep it on a disk that is backed up. |
/data (or any folder you want) |
Your downloads and your library, as the server sees them. |
PUID, PGID |
The user and group the server runs as: the files it creates belong to them. Use those of your NAS user (id in a terminal). |
TZ |
Your time zone, for the dates shown. |
8080:8080 |
The port of the interface. Change the first number to use another one. |
Mount one parent folder, for hard links
A hard link only works inside one mount. If your downloads are in /mnt/storage/downloads and your library in /mnt/storage/media, mount /mnt/storage once (/mnt/storage:/data), then use /data/downloads and /data/media in the settings.
Mounting them separately (/mnt/storage/downloads:/downloads and /mnt/storage/media:/media) makes two mounts: hard links fail between them, even on the same disk. The settings tell you when it is the case, before any rename.
First visit
An assistant asks one question at a time:
- Account: a name and a password of 8 characters or more. It is the only account of the server, to come in from any device.
- Downloads: the folders where your torrent or Usenet client puts what it downloads, as the server sees them (
/data/downloads, not the path of your NAS). Pick them in the folders of the server. - Library: where each type goes (movies, TV shows, music, books, games). Click a folder to change it; a type you do not have can stay without a folder.
- The original: hard links (the default), copies or moved.
- Sort on its own: yes or no, and how often (see Automatic sorting).
Then Ready. sums up where the files go, and Start the first analysis opens the interface. Everything can be changed later in the settings.
The interface takes the language of your browser. You stay logged in for 30 days on that browser. After 5 wrong passwords, the next attempts wait 30 seconds.
Forgotten password? Add SOK_RESET_PASSWORD=1 and your new password in SOK_PASSWORD to the environment of the compose file, then restart the container (docker compose up -d). Log in with the new password, then remove both lines. Your settings, history and choices are kept.
The interface
At the top, as in the app: the cube goes to the Analysis, then Movies, TV Shows, Music, Books and Games, each with the number of files it has to sort. At the right, the History, the Settings and the key to log out. On a phone, a menu takes their place.
Analyze your downloads
On the Analysis page, click Analyze. S.O.K sorts the files of your source folders by type, then searches each one; the progress shows live, and you can change pages meanwhile.
The page then says how many files there are to sort, with a line per type: how many are recognized, to pick and not found, and See to open its screen. At the right, your source folders and your disks, with the space used and free.
To check lists the files whose type is a guess (a disc image, a video among episodes…), with the reason: click the right type. The file joins its screen and is searched right away, and the next analyses remember it.
Each new analysis keeps what you chose: the match, the search text and the destination of a row found again.
Review and put away
Each type has its screen: a sentence (9 movies to sort.), filters (All, Ready, To pick, Not found) and the list. Each row has the poster, the title found, what the file was, and the gauge of five notches of how sure S.O.K is. A series is one row with its episodes; click it again to fold or unfold them.
Click a row to see it on the scene at the right: its poster, its size, the file mode, the database it was recognized with, and where it will be put. With several destination folders for the type, click the one it should go to.
| Status | Meaning |
|---|---|
| Ready | One sure match: the title and the year (or the author, the artist) match. |
| To pick | Several results could fit, or a question waits (the folder of a series, the language of a track). The scene shows the results, with their poster: click the right one. |
| Not found | Nothing found. Search another title on the scene, or leave the file where it is. |
That’s not it on the scene searches again for a row that is wrong.
Click Put away the movies (or the episodes, the tracks…), at the bottom, to put away every Ready row. To put away only some of them, Cmd-click or Ctrl-click rows (Shift-click for a range, a long press on a phone), then click Put away the selection. The line under the key says the file mode and where the files go.
Before it starts, the server checks the room on the disks (see Keep free on each disk in Settings), and in hard link mode that the links can work. The rows put away leave the list; a file that could not be put away stays on its row with the reason. At the end, Undo this puts the files back.
A series already in your library
When a series already has a folder in your TV library, its new episodes go there, even when the folder is named differently: S.O.K recognizes it by an id in its name or in its tvshow.nfo, by where it put the series before, or by one of the titles of the series (its original title, another language). The scene says how it found it, and which seasons and episodes are already there. The folder is never renamed, and a new season is named like the others (Season 05 next to Season 01).
When the series has several folders, the row waits: the scene asks Which folder? Pick one, or New folder.
Subtitles
Subtitles follow their video (Movie.fr.srt becomes Dune (2021).fr.srt), as in the app: those of a Subs folder too, and S.O.K reads the text of a subtitle without a language to add it (see Settings → Behavior).
The videos themselves
Three switches of Settings → Behavior change the videos, in Copy or Move mode only: with hard links, the file is the torrent’s and must not change. They are off by default.
Convert videos to MKV
The MP4, M4V, MOV and TS videos become MKV while they are put away. Only the container changes: no quality is lost. The new MKV is checked (its tracks and its duration) before it takes its place; if anything is wrong, the original is untouched and the file stays on its row. In Move mode, the original is deleted once the MKV is in place. AVI videos are not converted.
Fill in track languages
An audio or subtitle track without a language makes Jellyfin, Plex or a TV pick the wrong one. S.O.K reads the tracks of the videos during the analysis, and the scene shows Audio without a language and Subtitles without a language. With the switch on, it writes the languages it is sure of: from the name of the track (French AC3 5.1), from the text of a subtitle, or for a single audio track from the name of the file (FRENCH, VOSTFR…) or the original language of the movie.
Click Audio without a language or Subtitles without a language on the scene to see each track, what S.O.K gives it and why, and choose its language yourself (for a series, one choice covers every episode). Your choices are written even with the switch off.
Unsure language says what happens when a track has no language S.O.K is sure of: Sort anyway (the default), Wait for audio or Wait for all. A row that waits is to pick: the scene asks Which language?, with Choose the languages and Put away without these languages.
Write the information into the files
S.O.K writes the information of the movie or the episode into its video: the title, the year, the directors, the genres, the summary and the poster (for an episode, the series, the season, the number and the title of the episode). A player, Windows Explorer or the Finder then show the real title and the poster instead of the name of the download. It works on MKV and MP4 videos, and replaces the information already there.
Automatic sorting
S.O.K Server can do all of this on its own. In Settings → Automatic sorting, turn on Sort the new files automatically: it asks first, because the Ready rows will be put away without you, those already on the screens too.
- Every 5 minutes (you can change it, from 1 to 1440), the server looks at your source folders.
- A file is taken once its download is finished: the same size as at the look before. Files still downloading (
.part,.!qB,.crdownload…) are left out. - New finished files start an analysis, then the Ready rows are put away. The rows to pick, the ones not found and the files to check wait for you, as after a click on Analyze.
- A row you make Ready yourself (a result picked, a folder chosen, a language given) is put away at the next look, even with no new file.
- The Analysis page says that it is on, and the settings show its last look and what it put away.
Everything it puts away is in the History, marked as made by the automatic sorting, and can be undone like the rest.
Notifications
After each rename, by hand or automatic, S.O.K Server can tell your other apps. Set them in Settings → Notifications: click a line, fill it in, Save, then Test:
| Target | What to give | What it does |
|---|---|---|
| Discord | The address of a webhook of a channel (settings of the channel → Integrations → Webhooks) | Posts the files renamed |
| Jellyfin | Its address (http://jellyfin:8096) and an API key (Dashboard → API Keys) |
Refreshes the libraries |
| Plex | Its address (http://plex:32400) and your Plex token |
Refreshes the libraries |
| Webhook | Any address | Sends the rename as JSON (Home Assistant, n8n…) |
The webhook addresses, the key and the token are never shown again once saved. When the automatic sorting cannot put files away for lack of room, Discord, the webhook and the script are told too.
A script can run after each rename too, with the rename as JSON on its input and SOK_MEDIA_TYPE, SOK_RENAMED and SOK_AUTO in its environment. For safety, it cannot be set from the web page: put the script in a mounted folder and give its path in the environment of the container, for example SOK_AFTER_RENAME=/config/after-rename.sh.
Settings
The settings are one page of blocks, and every change is saved right away. At the right, the live preview shows a file before and after with the name model you edit.
- Folders: your source folders (watched) and the destinations of each type; the first one of a type is its default. Click Browse… to pick a folder of the server.
- Behavior: the file mode (Hard link, the default, Copy or Move), then the same switches as in the app (see Settings), the three switches of the videos, Unsure language and Keep free on each disk (1 GB by default): before putting files away, the server checks that the disks that receive copies keep that room; if not, nothing moves and it says how much is missing. In hard link mode, it checks that the links work between your folders, and says what to change when they do not, with a key to use Copy.
- Automatic sorting and Notifications: see above.
- File names: the name models, the same as in the app (see Settings → File names).
- Sources: the services searched first for each type, and their keys. Unlike the app, the image has no built-in key: TMDB (movies and TV shows) needs your own key, free on themoviedb.org. Deezer, MusicBrainz and Open Library work without one. Click a service, paste the key, Save, then Test. Keys are stored encrypted, and never shown again. Keys given by environment variables, such as
API_KEY_TMDB_V4, show as Set by an environment variable and cannot be changed from the interface. - Appearance: the theme, Dark (the default), Light or System, kept in each browser, and the language of the interface and of the folder names.
- Account and About: who is logged in, the version, the data folder and the documentation.
History and undo
History lists your renames by day, with their time, type, files, where from and where to. Click one to see its files with what each one was: Undo this puts all the files of the rename back, after a confirmation; Put back puts one file only (with its subtitles). After a partial undo, Undo the rest finishes it.
- A hard link or a copy is deleted: the original never moved. A copy converted to MKV, or whose languages or information were written, is deleted too while its original is there.
- A moved file goes back to its old folder.
An undo never replaces a file, as in the app (see History and undo).
Files already processed
With hard links, a renamed file stays in your downloads. S.O.K remembers it and leaves it out of the next analyses, as long as it does not change: the Analysis page says how many are left aside, with Show them. The Already processed list of the History shows them; choose the ones to take back (the mark of a thumbnail, Cmd/Ctrl-click, or a long press) and click Analyze again: the next analysis takes them as if they had just arrived. An undone file is analyzed again too.
Update
docker compose pull
docker compose up -d
Your settings, history and choices are kept in /config.
Behind a reverse proxy
S.O.K Server works behind Nginx, Traefik or Caddy. If your proxy already asks for a login (Authelia, Authentik…), you can turn the login of S.O.K off with SOK_AUTH=none: a banner then reminds you that the proxy protects the server.














