Skip to main content

TrakIt

Guess additional information from track titles

Latest Version

tests

License

PyPI - Python Version

Info

TrakIt is a track name parser. It is a tiny library created to solve a very specific problem. It's very common that video files do not have precise metadata information, where you can have multiple subtitle tracks tagged as Portuguese, but one of them is actually Brazilian Portuguese:

{
  "codec": "SubRip/SRT",
  "id": 19,
  "properties": {
    "codec_id": "S_TEXT/UTF8",
    "codec_private_length": 0,
    "default_track": false,
    "enabled_track": true,
    "encoding": "UTF-8",
    "forced_track": false,
    "language": "por",
    "language_ietf": "pt",
    "number": 20,
    "text_subtitles": true,
    "track_name": "Português",
    "uid": 160224385584803173
  }
}

{
  "codec": "SubRip/SRT",
  "id": 20,
  "properties": {
    "codec_id": "S_TEXT/UTF8",
    "codec_private_length": 0,
    "default_track": false,
    "enabled_track": true,
    "encoding": "UTF-8",
    "forced_track": false,
    "language": "por",
    "language_ietf": "pt",
    "number": 21,
    "text_subtitles": true,
    "track_name": "Português (Brasil)",
    "uid": 1435945803220205
  }
}

Or you have multiple audio tracks in English, but one of them is British English (British English Forced (PGS)) and others are American English (American English (PGS))

Given a track name, TrakIt can guess the language:

>> trakit "Português (Brasil)"
{
  "language": "pt-BR"
}
>> trakit -t filename "foobar.en.sdh.srt"
{
  "language": "en",
  "hearing_impaired": true
}

TrakIt is also able to identify:

  • SDH: Subtitles for the Deaf or Hard of Hearing
  • Forced flag
  • Closed captions
  • Alternate version tracks
  • Commentary tracks
>> trakit "British English (SDH) (PGS)"
{
  "language": "en-GB",
  "hearing_impaired": true
}

>> trakit "English CC (SRT)"
{
  "language": "en",
  "closed_caption": true
}

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

>> trakit "Français Forced (SRT)"
{
  "language": "fr",
  "forced": true
}

All available CLI options:

>> trakit --help
usage: trakit [-h] [-l EXPECTED_LANGUAGE] [--debug] [-y] [--version] value

positional arguments:
  value                 track title to guess

options:
  -h, --help            show this help message and exit

Configuration:
  -l EXPECTED_LANGUAGE, --expected-language EXPECTED_LANGUAGE
                        The expected language to be guessed
  -t, --type TYPE       The input type: trackname or filename. Default is trackname

Output:
  --debug               Print information for debugging trakit and for reporting bugs.
  -y, --yaml            Display output in yaml format

Information:
  --version             show program's version number and exit

TrakIt is not a release parser. Use GuessIt

TrakIt is not a video metadata extractor. Use KnowIt. KnowIt already uses trakit to enhance the extracted information

Installation

TrakIt requires Python 3.10 or later.

TrakIt is a command line tool. The simplest way to run it, with no install step, is uvx (part of uv):

$ uvx trakit "Português (Brasil)"

To install it instead, so it stays available on your PATH:

$ uv tool install trakit

pip is also supported. Use a dedicated virtualenv or the --user flag for a better isolation with your system:

$ pip install --user trakit

TrakIt is also a library. To add it as a dependency to a uv-managed project:

$ uv add trakit

The -y/--yaml option needs the optional yaml extra:

$ uv tool install "trakit[yaml]"

Development

TrakIt uses uv to manage its environment and dependencies.

$ uv sync --all-extras
$ bash scripts/test.sh

This runs ruff (lint and format check), mypy and the test suite.

Data

Metadata

Release files for trakit 0.4.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.4.0
File Size Uploaded
trakit-0.4.0.tar.gz 34.5 kB Details

Built distribution (wheel)

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

Total release size: 54.2 kB

Release files / trakit-0.4.0.tar.gz

Download URL trakit-0.4.0.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bdf04ca6840ce25f60bc31c4496832e8c14167725b9240badf0e2edf38bb7305
BLAKE2b-256 checksum
How to use checksums
4735e2273b5152ff6f77b9dd6449547c4d14bfb170fa00893f64fd785ec67116
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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

Download URL trakit-0.4.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89264b561ef5149c3de4a918e4e4fb80a5a0b6bb40a0ed7fa20732d329ac7508
BLAKE2b-256 checksum
How to use checksums
b8a7cc13f1f16723e5ed9b13a1a196a4ad31e130813218c6ff5c599bce2b6b24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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