MCPcopy Create free account
hub / github.com/Jack-Cherish/python-spider / ReadCommentsAcfun

Function ReadCommentsAcfun

bilibili/xml2ass.py:140–156  ·  view source on GitHub ↗
(f, fontsize)

Source from the content-addressed store, hash-verified

138
139
140def ReadCommentsAcfun(f, fontsize):
141 comment_element = json.load(f)
142 for i, comment in enumerate(comment_element):
143 try:
144 p = str(comment['c']).split(',')
145 assert len(p) >= 6
146 assert p[2] in ('1', '2', '4', '5', '7')
147 size = int(p[3])*fontsize/25.0
148 if p[2] != '7':
149 c = str(comment['m']).replace('\\r', '\n').replace('\r', '\n')
150 yield (float(p[0]), int(p[5]), i, c, {'1': 0, '2': 0, '4': 2, '5': 1}[p[2]], int(p[1]), size, (c.count('\n')+1)*size, CalculateLength(c)*size)
151 else:
152 c = dict(json.loads(comment['m']))
153 yield (float(p[0]), int(p[5]), i, c, 'acfunpos', int(p[1]), size, 0, 0)
154 except (AssertionError, AttributeError, IndexError, TypeError, ValueError):
155 logging.warning(_('Invalid comment: %r') % comment)
156 continue
157
158
159def ReadCommentsBilibili(f, fontsize):

Callers

nothing calls this directly

Calls 2

replaceMethod · 0.80
CalculateLengthFunction · 0.70

Tested by

no test coverage detected