srt.tools.match

Filter and/or process subtitles’ content that match a particular pattern.

match(subtitles, imports, func_match, func_process, lines)

Passes each matching subtitle-content to a function.

Parameters
  • subtitlesSubtitle objects

  • imports – Modules to import in the context of the function.

  • func_match (str) – The function used to match lines.

  • func_process (str) – The function used to process subtitle content.

  • invert (bool) – Whether to only match lines that return False.

  • per_line – Whether to apply functions to each line of content (as opposed to the whole content string).

Return type

generator of Subtitle objects