Skip to main content

trakit: Identify a track from its title

trakit reads a track title or a file name and guesses the language and the track flags: SDH, forced, closed caption, commentary, audio description, and alternate version.

PyPI version Python versions Tests License

trakit guesses the language and the flags of three track titles

Why trakit

The language tag of a track in a video file is often not precise. Two subtitle tracks can both have the tag por, but one title says Português and the other says Português (Brasil). The track title often has more information than the tags: SDH, forced, commentary. trakit reads the title, so that your tools can select the correct track.

Track title Language tag trakit
Português por language: pt
Português (Brasil) por language: pt-BR
British English (SDH) (PGS) eng language: en-GB, hearing_impaired: true

What trakit detects

Key Meaning Example title
language The language, with the country or the region when the title has one Español (LA) Forced gives es-419
hearing_impaired Subtitles for the deaf or hard of hearing (SDH) British English (SDH) (PGS)
forced Forced subtitles, also signs and songs tracks English Signs & Songs (ASS)
closed_caption Closed captions English CC (SRT)
commentary A commentary track Cast and Crew Commentary (English AC3 Stereo)
descriptive Audio description English (Audio Description)
version An alternate version (alternate) Alternate Score Version (English DTS-HD MA 5.1)

The result has only the keys that trakit finds. The full reference is in docs/usage.md.

Quick start

Run trakit with no install step, with uvx:

$ uvx trakit "Português (Brasil)"
...
{
  "language": "pt-BR"
}

Read the name of an external subtitle file:

$ uvx trakit -t filename "movie.pt-BR.cc.commentary.srt"
...
{
  "language": "pt-BR",
  "closed_caption": true,
  "commentary": true
}

Use it in Python:

from trakit import trakit

trakit('British English (SDH) (PGS)')
# MatchesDict({'language': <Language [en-GB]>, 'hearing_impaired': True})

Installation

trakit needs Python 3.11 or later.

To Run
Run the CLI with no install uvx trakit "<title>"
Install the CLI uv tool install trakit
Add the library to a project uv add trakit
Install with pip pip install trakit

The -y (YAML) option needs the yaml extra, for example uv tool install "trakit[yaml]".

Usage

A track title:

$ trakit "Cast and Crew Commentary (English AC3 Stereo)"
...
{
  "commentary": true,
  "language": "en"
}

A file name. trakit reads the language codes and the flags between the dots:

$ trakit -t filename "movie.en.forced.srt"
...
{
  "language": "en",
  "forced": true
}

The expected language. A title can name a person or a place that is also a language. Give the language that you expect, for example the language tag of the track:

$ trakit -l en "Commentary by director John Français (EU) (English PGS)"
...
{
  "commentary": true,
  "language": "en"
}

YAML output:

$ trakit -y "British English (SDH) (PGS)"
...
British English (SDH) (PGS):
  language: en-GB
  hearing_impaired: true

The Python API. The options keys are the same as the CLI options:

from trakit import trakit

trakit('movie.en.sdh.srt', {'type': 'filename'})
# MatchesDict({'language': <Language [en]>, 'hearing_impaired': True})

info = trakit('Commentary by director John Français (EU) (English PGS)', {'expected_language': 'en'})
str(info['language'])  # 'en'

Main options

Option Use
-t filename Read a file name. The default is trackname.
-l <language> The expected language, as an IETF tag (en, pt-BR).
-y YAML output.
--debug Print the debug information. Add it to a bug report.

All the options, the output keys, TrakItApi, and the babelfish Language values are in docs/usage.md.

What trakit is not

  • trakit is not a release name parser. Use GuessIt.
  • trakit does not read media files. Use knowit. knowit uses trakit to read the track titles.

FAQ

trakit gives {}. Why? The title has no word that trakit knows, for example a release name. If the title has a language or a flag, report it.

trakit gives the wrong language. What can I do? Give the expected language with -l. Then report the title.

Does trakit read the media file? No. It reads only the string that you give. Use knowit to read the tracks of a file.

Which languages does trakit know? The languages of babelfish, with their names in many languages. See Data sources.

Report a bug

Open an issue with:

  • The track title or the file name.
  • The result that you expect.
  • The output of trakit --debug "<title>".

Data sources

Contributing

See CONTRIBUTING.md.

License

MIT.

The trakit name, logo, and icon are not covered by the MIT license. All rights reserved.

Metadata

Release files for trakit 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trakit 0.6.0
File Size Uploaded Provenance Actions
trakit-0.6.0.tar.gz 46.9 kB Without provenance Details for trakit-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trakit 0.6.0
File Interpreter ABI Platform Actions
trakit-0.6.0-py3-none-any.whl Python 3 none any Details for trakit-0.6.0-py3-none-any.whl

Total release size: 71.3 kB

Release files / trakit-0.6.0.tar.gz

Download URL trakit-0.6.0.tar.gz
Size 46.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1cbc188313e45cd2a9ee6bb8590a9d10f94c7a96104e103aeed8e114d405bc34
BLAKE2b-256 checksum
How to use checksums
6b41b79e900ab273bc9615604e273a184212b89db18aac2bf849add45c0894e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / trakit-0.6.0-py3-none-any.whl

Download URL trakit-0.6.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
861d6afc661eb5df9c799b22319c4bfd586bfa6db56756c7b896583b504b001b
BLAKE2b-256 checksum
How to use checksums
01f0ec901d5cff5a974435a0688b18032322dc5365b8b2089cb70009d8371891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for trakit 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page