]> git.pld-linux.org Git - packages/subconv.git/commitdiff
- enhacements when dealing with format variations.
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Sat, 17 Jan 2009 20:38:53 +0000 (20:38 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    subconv-pld.patch -> 1.1

subconv-pld.patch [new file with mode: 0644]

diff --git a/subconv-pld.patch b/subconv-pld.patch
new file mode 100644 (file)
index 0000000..a045067
--- /dev/null
@@ -0,0 +1,54 @@
+--- subconv    2003-05-18 13:09:28.000000000 +0200
++++ subconv    2009-01-17 15:55:58.339800634 +0100
+@@ -38,7 +38,7 @@
+       sys.stderr.write("FPS guessing, here are approximate length of file for several FPS :\n")
+       most_current=[23.976,25.0,29.0]
+       
+-      re_mdvd = re.compile("^\{(\d+)\}\{(\d*)\}\s*(.*)")
++      re_mdvd = re.compile("^[\{\[](\d+)[\}\]][\{\[](\d*)[\}\]]\s*(.*)")
+       count = len(list) - 1
+       m = re_mdvd.match(list[count])
+       while not m:
+@@ -68,7 +68,7 @@
+       returns: format (srt, tmp, mdvd) or "" if unknown
+       """
+       sys.stderr.write("Guessing subs format .")
+-      re_mdvd = re.compile("^\{(\d+)\}\{(\d*)\}\s*(.*)")
++      re_mdvd = re.compile("^[\{\[](\d+)[\}\]][\{\[](\d*)[\}\]]\s*(.*)")
+       re_srt = re.compile("^(\d+):(\d+):(\d+),\d+\s*-->.*")
+       re_tmp = re.compile("^(\d+):(\d+):(\d+):(.*)")
+       re_sub2 = re.compile("^(\d+):(\d+):(\d+)\.\d+\s*\,.*")
+@@ -96,14 +96,28 @@
+       input: contents of a file as list
+       returns: list of subtitles in form: [[time_start in secs, time_end in secs, line1, ...],....]
+       """
+-      re1 = re.compile("^\{(\d+)\}\{(\d*)\}\s*(.*)")
++      re1 = re.compile("^[\{\[](\d+)[\}\]][\{\[](\d*)[\}\]]\s*(.*)")
++
+       subtitles = []
+       while len(list)>0:
+-              m = re1.match(list.pop(0), 0)
++              x = list.pop(0)
++              m = re1.match(x, 0)
+               if m:
+-                      subt = [int(m.group(1)) / float(fps)]
+-                      subt.append(int(m.group(2)) / float(fps))
+-                      subt.extend(m.group(3).strip().split("|"))
++                      time1 = int(m.group(1))
++                      subt = [int(time1) / float(fps)]
++                      time2 = m.group(2)
++                      if time2 == '':
++                              time2 = int(time1) + 20
++                      subt.append(int(time2) / float(fps))
++                      texts = m.group(3).strip().split("|")
++                      for i in range(len(texts)):
++                              text = texts[i]
++                              if text.lower().startswith('{c:') or text.lower().startswith('{y:'):
++                                      end_marker = text.index('}')
++                                      if end_marker:
++                                              text = text[end_marker + 1:]
++                                              texts[i] = text
++                      subt.extend(texts)
+                       subtitles.append(subt)
+       return subtitles
This page took 0.107754 seconds and 4 git commands to generate.