Skip to content

Latest commit

 

History

History
49 lines (40 loc) · 2.05 KB

README.md

File metadata and controls

49 lines (40 loc) · 2.05 KB

plex-auto-subs

Created in T3 Code.

Automatic subtitles

plex-autosubs.py does what the Search button in Plex's subtitle picker does, for every movie and episode that is missing subtitles. It uses Plex's own on-demand subtitles (OpenSubtitles).

  • Languages: SUB_LANGUAGES, default en,nl. Each language is downloaded if Plex can find a match.
  • Skipped: items that already have a full (non-forced) subtitle in that language, and items Plex hasn't matched to a title.
  • Auth: PLEX_TOKEN in ~/.config/plex-autosubs/env (mode 600), or allow 127.0.0.1/32 without auth in Plex's network settings.
  • English is mandatory. The run exits with an error (visible as a failed unit in the journal) if any item still lacks English. Dutch is optional: if there's no match, it's skipped.
  • One download per item: Plex keeps only one downloaded subtitle per item, and a second language replaces the first. The download goes to English unless English is built in. Where English uses it, Dutch is saved as a sidecar file next to the video (Movie.nl.srt). Plex can only serve a subtitle it has downloaded, so the script downloads Dutch, saves it, then downloads English again. It keeps a copy of the English first and writes it as Movie.en.srt if the re-download fails.
  • Needs write access to the media folders, for the sidecar files.
  • Verified: after each download the script re-reads the item to make sure the track is there. If it isn't (the provider sometimes returns an empty file while the request still succeeds), the run stops and the next run carries on. MAX_DOWNLOADS (default 100) is only a safety cap.

Run by hand:

python3 plex-autosubs.py --dry-run   # show what it would download
python3 plex-autosubs.py

Runs nightly at about 04:00 via a systemd user timer:

cp systemd/plex-autosubs.* ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now plex-autosubs.timer
journalctl --user -u plex-autosubs.service   # logs