Files
sm-emby-share/lib/core/media/danmaku_comment_pipeline.dart
T
2026-07-14 11:11:36 +08:00

36 lines
904 B
Dart

import '../contracts/danmaku.dart';
import 'danmaku_comment_merger.dart';
List<DanmakuComment> processDanmakuComments(
List<DanmakuComment> comments, {
required List<String> blockedKeywords,
required bool mergeDuplicates,
}) {
final visible = blockedKeywords.isEmpty
? comments
: comments
.where((c) => blockedKeywords.every((kw) => !c.text.contains(kw)))
.toList();
final processed = mergeDuplicates
? mergeDuplicateDanmakuComments(visible)
: List<DanmakuComment>.of(visible);
processed.sort((a, b) => a.time.compareTo(b.time));
return processed;
}
int lowerBoundByTime(List<DanmakuComment> sortedByTime, double posSec) {
var lo = 0;
var hi = sortedByTime.length;
while (lo < hi) {
final mid = (lo + hi) >> 1;
if (sortedByTime[mid].time < posSec) {
lo = mid + 1;
} else {
hi = mid;
}
}
return lo;
}