Skip to content

Commit

Permalink
Merge pull request #15 from weirongxu/fix/danmu-sort
Browse files Browse the repository at this point in the history
修复弹幕顺序导致判断遮挡错误从而丢失弹幕
  • Loading branch information
gwy15 authored May 16, 2024
2 parents 3ede48b + caedf13 commit 16ae89f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/canvas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Canvas {
crate::danmu::DanmuType::Bottom
| crate::danmu::DanmuType::Top
| crate::danmu::DanmuType::Reverse => {
// 不喜欢底部弹幕,直接转成 Bottom
// 不喜欢底部弹幕,直接转成 Float
// 这是 feature 不是 bug
danmu.r#type = crate::danmu::DanmuType::Float;
Ok(self.draw_float(danmu))
Expand Down
10 changes: 8 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
cmp::Ordering,
collections::HashSet,
fs::File,
io::{StdoutLock, Write},
Expand Down Expand Up @@ -396,8 +397,13 @@ where
let mut canvas = canvas_config.canvas();
let t = std::time::Instant::now();

for danmu in data_provider {
let danmu = danmu?;
let mut danmus = data_provider.collect::<Result<Vec<_>>>()?;
danmus.sort_by(|a, b| {
a.timeline_s
.partial_cmp(&b.timeline_s)
.unwrap_or(Ordering::Equal)
});
for danmu in danmus {
if let Some(denylist) = denylist.as_ref() {
if denylist.iter().any(|s| danmu.content.contains(s)) {
continue;
Expand Down

0 comments on commit 16ae89f

Please sign in to comment.