From: Arkadiusz Miƛkiewicz Date: Sat, 17 Jan 2009 20:38:53 +0000 (+0000) Subject: - enhacements when dealing with format variations. X-Git-Tag: auto/th/subconv-0_2_2-2~1 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=99455584619015787213974d794a37c950c143a6;p=packages%2Fsubconv.git - enhacements when dealing with format variations. Changed files: subconv-pld.patch -> 1.1 --- diff --git a/subconv-pld.patch b/subconv-pld.patch new file mode 100644 index 0000000..a045067 --- /dev/null +++ b/subconv-pld.patch @@ -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 +