def __init__(self, index=0, start=None, end=None, text='', position=''): try: self.index = int(index) except (TypeError, ValueError): # try to cast as int, but it's not mandatory self.index = index self.start = SubRipTime.coerce(start or 0) self.end = SubRipTime.coerce(end or 0) self.position = str(position) self.text = str(text)
def __init__(self, index=0, start=None, end=None, text=u'', position=u''): try: self.index = int(index) except ValueError: raise InvalidIndex(repr(index)) self.start = SubRipTime.coerce(start or 0) self.end = SubRipTime.coerce(end or 0) self.position = unicode(position) self.text = unicode(text)
def text_at_time(self, time): """ text_at_time() Get text that, according to subtitles, should appear on screen exactly at given time. """ time = SubRipTime.coerce(time) for item in self: if item.start <= time and time <= item.end: return item.text
def __init__(self, index=0, start=None, end=None, text=u'', position=u''): self.index = int(index) self.start = SubRipTime.coerce(start or 0) self.end = SubRipTime.coerce(end or 0) self.position = unicode(position) self.text = unicode(text)