Documentation
¶
Overview ¶
Package classify provides subtitle classification (forced/HI) and language resolution utilities consumed by provider sub-packages.
Index ¶
- Variables
- func Alpha2FromAlpha3(code string) string
- func IsForced(comment string) bool
- func IsHearingImpaired(commentary, filename string) bool
- func LookupLangCode(name string, overrides map[string]string) string
- func LookupLangName(code string, overrides map[string]string) string
- func SanitizeImdbID(id string) string
Constants ¶
This section is empty.
Variables ¶
var LangRegistry = map[string]string{ "en": "English", "fr": "French", "es": "Spanish", "de": "German", "it": "Italian", "pt": "Portuguese", "nl": "Dutch", "ru": "Russian", "ar": "Arabic", "ja": "Japanese", "zh": "Chinese", "ko": "Korean", "sv": "Swedish", "no": "Norwegian", "da": "Danish", "fi": "Finnish", "pl": "Polish", "cs": "Czech", "hu": "Hungarian", "ro": "Romanian", "tr": "Turkish", "el": "Greek", "he": "Hebrew", "th": "Thai", "vi": "Vietnamese", "id": "Indonesian", "bg": "Bulgarian", "hr": "Croatian", "sr": "Serbian", "sl": "Slovenian", "sk": "Slovak", "uk": "Ukrainian", "ca": "Catalan", "eu": "Basque", "gl": "Galician", "fa": "Persian", "ms": "Malay", "sq": "Albanian", "bs": "Bosnian", "hy": "Armenian", "az": "Azerbaijani", "bn": "Bengali", "mk": "Macedonian", "hi": "Hindi", "ta": "Tamil", "te": "Telugu", "ml": "Malayalam", "kn": "Kannada", "mr": "Marathi", "ur": "Urdu", "ne": "Nepali", "si": "Sinhalese", "af": "Afrikaans", "sw": "Swahili", "lt": "Lithuanian", "lv": "Latvian", "et": "Estonian", "is": "Icelandic", "ga": "Irish", "cy": "Welsh", "ka": "Georgian", "mn": "Mongolian", "km": "Khmer", "lo": "Lao", "my": "Burmese", langcode.BrazilianPortuguese: "Brazilian Portuguese", }
LangRegistry is the canonical ISO 639-1 → English language name mapping. Provider sub-packages use this as the single source of truth, applying per-provider overrides only for non-standard names (e.g. "Brazillian Portuguese" for SubSource API compat).
Functions ¶
func Alpha2FromAlpha3 ¶
Alpha2FromAlpha3 resolves any published language code onto subflux's internal code space: ISO 639-1 two-letter codes plus "pb" for Brazilian Portuguese.
It accepts ISO 639-1, both ISO 639-2 variants, ISO 639-3 and BCP 47 tags, in any letter case. It returns "" for anything that names no language subflux can represent, which includes a language with no ISO 639-1 assignment (Cantonese, Filipino) — a three-letter code in a two-letter namespace matches nothing.
Two behaviours are worth knowing at the call sites, because a hand-written table used to decide them differently. A region is consulted before it is discarded, so "pt-BR" resolves to "pb" rather than "pt". And an unrecognized two-letter input is now rejected rather than passed through: the old table returned any two letters unchanged, which let "xx" pose as a language.
The name is kept for its committed fuzz corpus (testdata/fuzz/FuzzAlpha2FromAlpha3) even though the function now resolves more than alpha-3.
func IsForced ¶
IsForced returns true if the comment string indicates a forced or foreign-parts subtitle track.
func IsHearingImpaired ¶
IsHearingImpaired reports whether commentary or a filename indicates a hearing-impaired / SDH / closed-caption subtitle. A filename containing "_hi_" short-circuits to true regardless of commentary. Negative rules ("non hi", "non sdh", etc.) win over positive ones. The filename is optional: providers without a filename field should pass "".
func LookupLangCode ¶
LookupLangCode returns the ISO-2 code for an English language name, applying provider-specific overrides if provided. Returns empty string if the name is unknown.
func LookupLangName ¶
LookupLangName returns the English language name for an ISO-2 code, applying provider-specific overrides if provided. Returns empty string if the code is unknown.
func SanitizeImdbID ¶
SanitizeImdbID strips the "tt" prefix and leading zeros from an IMDB ID, returning the bare numeric string expected by most subtitle APIs.
Types ¶
This section is empty.