~perroquet-team/perroquet/1.0

« back to all changes in this revision

Viewing changes to perroquetlib/subtitles_loader.py

  • Committer: Fred
  • Date: 2010-01-11 23:43:12 UTC
  • Revision ID: fred@fred-desktop-20100111234312-5xu9v35afcwvj0xn
fix bug #506154. Thanks to OAO for the patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
                        state = SubtitlesLoader.LOOK_FOR_TEXT
97
97
            elif state == SubtitlesLoader.LOOK_FOR_TEXT:
98
98
                if len(line) > 0:
99
 
                    line = line.replace("|","\n")
100
99
                    if len(current.GetText()) == 0:
101
100
                        current.SetText(line)
102
101
                    else:
140
139
        return self.id
141
140
 
142
141
    def SetText(self,text):
 
142
        # | mean new line in some srt files
 
143
        text = text.replace("|","\n")
 
144
        #Some subs have <i>...</i> or {]@^\`}. We need to delete them.
 
145
        text = re.sub("(<" "[^>]*" ">)"
 
146
                      "|"
 
147
                      "(\{" "[^\}]*" "\})"
 
148
                      , "", text)
143
149
        self.text = text
144
150
 
 
151
 
145
152
    def SetTimeBegin(self,timeBegin):
146
153
        self.timeBegin = timeBegin
147
154