byroot/pysrt — pull request #27 by adrek14 (2013-04-12 12:34:32+00:00)
Title: SubRipFile text_at_time() method

Hi!
First of all, let me say you've done great job on the library, I really like the ease of use.

Few days back I found myself looking for a method to extract subtitle text that, when watching a movie, would appear on the screen at particular time (say, '00:15:42,500'). My motivation is simple: I learn languages (currently French) by watching movies, and I wanted to have a clean way to quickly translate text that appears on the screen. vlc is my weapon of choice; I get the current position (time) via dbus and bam! the translation pops out in translate.google right in my browser.

Anyway, here's the method. Simple as can be; maybe someone else would benefit?

Best regards,
Adrian (adrek14)

btw Two tests failed on my machine; below is the output I got (it's BOM-related):

....F........F...............................................
======================================================================
FAIL: test_utf8 (tests.test_srtfile.TestBOM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/adriansan/projects/pysrt/tests/test_srtfile.py", line 212, in test_utf8
self.__test_encoding('bom-utf-8.srt')
File "/home/adriansan/projects/pysrt/tests/test_srtfile.py", line 208, in __test_encoding
self.assertEquals(len(srt_file), 7)
AssertionError: 6 != 7

======================================================================
FAIL: test_file_with_empty_items (tests.test_srtfile.TestIntegration)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/adriansan/projects/pysrt/tests/test_srtfile.py", line 250, in test_file_with_empty_items
self.assertEquals(len(file), 7)
AssertionError: 6 != 7

----------------------------------------------------------------------
Ran 61 tests in 15.450s

FAILED (failures=2)