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
- type Rule
Constants ¶
This section is empty.
Variables ¶
var ForcedRules = []Rule{ {"forced", true}, {"foreign", true}, }
ForcedRules is the declarative table for forced/foreign-parts classification. All entries are positive (any match confirms forced status).
var HearingImpairedRules = []Rule{ {"hi remove", false}, {"non hi", false}, {"nonhi", false}, {"non-hi", false}, {"non-sdh", false}, {"non sdh", false}, {"nonsdh", false}, {"sdh remove", false}, {"_hi_", true}, {" hi ", true}, {".hi.", true}, {"_cc_", true}, {" cc ", true}, {".cc.", true}, {"sdh", true}, {"closed caption", true}, }
HearingImpairedRules is the declarative table for HI/SDH/CC classification. Negative entries (Polarity=false) deny HI status and take precedence over positive entries. The first matching entry determines the result.
var LangNameToISO2 map[string]string
LangNameToISO2 is the reverse of LangRegistry: English name → ISO-2 code. Built once at init time from LangRegistry.
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", "pb": "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 converts an ISO 639-2/3 code to ISO 639-1. Returns the input unchanged if it is already 2 characters. Returns empty string if the code is unknown.
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.