Skip to main content

parse_languages

Function parse_languages 

Source
pub fn parse_languages(title: &str) -> Vec<Language>
Expand description

Public entry point. Mirrors C# LanguageParser.ParseLanguages (lines 38-215).

Algorithm (read top-to-bottom in the C# source):

  1. Apply CleanSeriesTitleRegex to strip any leading show-title.
  2. Twenty-six substring checks against the lowercased title, in source order. Each hit appends a Language to the list.
  3. Append the regex-pass results (case-sensitive LT/CZ/PL/BG/SK first, then case-insensitive LanguageRegex).
  4. If the lowercased title contains “english”, append Language::English.
  5. If the list is empty, append Language::Unknown.
  6. If the list now contains exactly [Language::German], apply the DL/ML special handling (DL adds Original; ML adds Original and English).
  7. Dedup by Language as i32, preserving first-seen order. C# uses DistinctBy(l => (int)l) which is order-preserving; Rust mirrors this with a HashSet<i32> discriminator and an in-place filter.