GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ratoaq2/trakit: Identify a track from its title

BranchesTags
Open more actions menu

Latest commit

 

History

234 Commits
234 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude
.claude
 
 
.github
.github
 
 
docs
docs
 
 
scripts
scripts
 
 
tests
tests
 
 
trakit
trakit
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.python-version
.python-version
 
 
CLAUDE.md
CLAUDE.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

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

  • The languages are the languages of Diaoul/babelfish.
  • The country names in many languages come from mledoze/countries.
  • The language names in many languages come from mozilla/language-mapping-list.
  • The official languages of each country come from Unicode CLDR (territoryInfo.json).

Contributing

See CONTRIBUTING.md.

License

MIT.

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

About

Identify a track from its title

Resources

Readme
MIT license

Contributing

Contributing
Activity

Stars

4 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.