(f, fontsize)
| 138 | |
| 139 | |
| 140 | def 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 | |
| 159 | def ReadCommentsBilibili(f, fontsize): |
nothing calls this directly
no test coverage detected