From 34c1d6536aab70cafac4ef063b5f54312cdd4cc7 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Fri, 20 Sep 2013 15:00:44 +0800 Subject: [PATCH] Implement Niconico comment converting --- convert.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/convert.py b/convert.py index dec839a..05b958b 100755 --- a/convert.py +++ b/convert.py @@ -79,6 +79,58 @@ def WriteComment(f, c, row, width, height, bottomReserved, fontsize, lifetime): f.write('Dialogue: 3,%(start)s,%(end)s,Default,,0000,0000,0000,,%(styles)s%(text)s\n' % {'start': ConvertTimestamp(c[0]), 'end': ConvertTimestamp(c[0]+lifetime), 'styles': styles, 'text': text}) +def ProbeCommentFormat(f): + f.seek(0) + tmp = f.read(1) + if tmp == '{': + f.seek(0) + return 'Acfun' + elif tmp == '<': + tmp = f.read(39) + f.seek(0) + if tmp == '?xml version="1.0" encoding="UTF-8"?>