This commit is contained in:
Star Brilliant 2013-11-17 09:10:12 +08:00
parent a599141084
commit fa0e3681bf

View File

@ -217,6 +217,7 @@ CommentFormatMap = {None: None, 'Niconico': ReadCommentsNiconico, 'Acfun': ReadC
def WriteCommentBilibiliPositioned(f, c, width, height, styleid): def WriteCommentBilibiliPositioned(f, c, width, height, styleid):
BiliPlayerSize = (672, 437) BiliPlayerSize = (672, 437)
BiliPlayerAspect = 672/437 BiliPlayerAspect = 672/437
def GetZoomFactor(TargetSize): def GetZoomFactor(TargetSize):
try: try:
if TargetSize == GetZoomFactor.Cached_TargetSize: if TargetSize == GetZoomFactor.Cached_TargetSize:
@ -238,7 +239,9 @@ def WriteCommentBilibiliPositioned(f, c, width, height, styleid):
except ZeroDivisionError: except ZeroDivisionError:
GetZoomFactor.Cached_Result = (1, 0, 0) GetZoomFactor.Cached_Result = (1, 0, 0)
return GetZoomFactor.Cached_Result return GetZoomFactor.Cached_Result
ZoomFactor = GetZoomFactor((width, height)) ZoomFactor = GetZoomFactor((width, height))
def GetPosition(InputPos, isHeight): def GetPosition(InputPos, isHeight):
isHeight = int(isHeight) # True -> 1 isHeight = int(isHeight) # True -> 1
if isinstance(InputPos, int): if isinstance(InputPos, int):
@ -254,6 +257,7 @@ def WriteCommentBilibiliPositioned(f, c, width, height, styleid):
except ValueError: except ValueError:
InputPos = float(InputPos) InputPos = float(InputPos)
return GetPosition(InputPos, isHeight) return GetPosition(InputPos, isHeight)
try: try:
comment_args = safe_list(json.loads(c[3])) comment_args = safe_list(json.loads(c[3]))
text = str(comment_args[4]).replace('\\', '\\\\').replace('/n', '\\N').replace('{', '\\{').replace('}', '\\}') text = str(comment_args[4]).replace('\\', '\\\\').replace('/n', '\\N').replace('{', '\\{').replace('}', '\\}')