2020-03-18 19:33:54 +00:00
|
|
|
import re
|
|
|
|
|
2022-01-24 04:07:52 +00:00
|
|
|
from knowit.core import Rule
|
2020-03-18 19:33:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ClosedCaptionRule(Rule):
|
|
|
|
"""Closed caption rule."""
|
|
|
|
|
|
|
|
cc_re = re.compile(r'(\bcc\d\b)', re.IGNORECASE)
|
|
|
|
|
|
|
|
def execute(self, props, pv_props, context):
|
|
|
|
"""Execute closed caption rule."""
|
2023-03-22 03:15:01 +00:00
|
|
|
if '_closed_caption' in pv_props and self.cc_re.search(pv_props['_closed_caption']):
|
|
|
|
return True
|
|
|
|
|
|
|
|
if 'guessed' in pv_props:
|
|
|
|
guessed = pv_props['guessed']
|
|
|
|
return guessed.get('closed_caption')
|
2022-01-24 04:07:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HearingImpairedRule(Rule):
|
|
|
|
"""Hearing Impaired rule."""
|
|
|
|
|
|
|
|
def execute(self, props, pv_props, context):
|
|
|
|
"""Hearing Impaired."""
|
2023-03-22 03:15:01 +00:00
|
|
|
if 'guessed' in pv_props:
|
|
|
|
guessed = pv_props['guessed']
|
|
|
|
return guessed.get('hearing_impaired')
|