Ejemplo n.º 1
0
    def test_it_read_a_subtitle_file(self):
        mstdout = mock.Mock()
        sys.stdout = mstdout

        file = open("legenda_test.srt")
        reader = SubtitleReader(file)
        reader.read()
        
        mstdout.write.assert_any_call("1\r\n")
        mstdout.write.assert_any_call("00:03:00,000 --> 00:04:00,000\r\n")
        mstdout.write.assert_any_call("blah blah blah\r\n")
        mstdout.write.assert_any_call("\r\n")
Ejemplo n.º 2
0
from subtitle import SubtitleReader
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-f", "--file", dest="filename", help="Subtitle file to read.", metavar="FILE")
parser.add_option("-u", "--time-unit", dest="unit", help="Time unit to work with. Options: [minutes,seconds]. Default: 'seconds'", metavar="NUMBER")
parser.add_option("-p", "--plus", dest="plus", help="Units to be added in subtitle timings.", metavar="NUMBER")
parser.add_option("-m", "--minus", dest="minus", help="Units to be removed from sutitle timings.", metavar="NUMBER")
parser.add_option("-s", "--start-number", dest="start", help="Subtitle number which will be the first to change.", metavar="NUMBER")
(options, args) = parser.parse_args()

reader = SubtitleReader(open(options.filename), plus=options.plus)
reader.read()