def file_to_subtitles(filename):
 with open(filename, 'r') as f:
  lines = f.readlines()
 times_texts = []
 (current_times, current_text) = (None, '')
 for line in lines:
  times = re.findall('([0-9]*:[0-9]*:[0-9]*,[0-9]*)', line)
  if (times != []):
   current_times = map(cvsecs, times)
  elif (line.strip() == ''):
   times_texts.append((current_times, current_text.strip('\n')))
   (current_times, current_text) = (None, '')
  elif (current_times is not None):
   current_text = (current_text + line)
 return times_texts

def file_to_subtitles ( filename ) : with open ( filename , 'r' ) as f : lines = f . readlines ( ) times_texts = [ ] ( current_times , current_text ) = ( None , '' ) for line in lines : times = re . findall ( '([0-9]*:[0-9]*:[0-9]*,[0-9]*)' , line ) if ( times != [ ] ) : current_times = map ( cvsecs , times ) elif ( line . strip ( ) == '' ) : times_texts . append ( ( current_times , current_text . strip ( '\n' ) ) ) ( current_times , current_text ) = ( None , '' ) elif ( current_times is not None ) : current_text = ( current_text + line ) return times_texts
converts a srt file into subtitles .