From 980f74a242411e803a4f6cdef07985b218928149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Sun, 15 Feb 2026 15:09:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=A4=B9=E8=A7=86=E9=A2=91=E7=9A=84=20valid?= =?UTF-8?q?=20=E5=88=A4=E6=96=AD=20(#648)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/bili_sync/src/api/response.rs | 1 + crates/bili_sync/src/api/routes/videos/mod.rs | 2 ++ crates/bili_sync/src/utils/convert.rs | 3 ++- web/src/lib/components/video-card.svelte | 9 +++++++-- web/src/lib/types.ts | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/bili_sync/src/api/response.rs b/crates/bili_sync/src/api/response.rs index eba227d..0dc9a77 100644 --- a/crates/bili_sync/src/api/response.rs +++ b/crates/bili_sync/src/api/response.rs @@ -73,6 +73,7 @@ pub struct VideoInfo { pub bvid: String, pub name: String, pub upper_name: String, + pub valid: bool, pub should_download: bool, #[serde(serialize_with = "serde_video_download_status")] pub download_status: u32, diff --git a/crates/bili_sync/src/api/routes/videos/mod.rs b/crates/bili_sync/src/api/routes/videos/mod.rs index 0c1f9d3..a1ffa1d 100644 --- a/crates/bili_sync/src/api/routes/videos/mod.rs +++ b/crates/bili_sync/src/api/routes/videos/mod.rs @@ -174,6 +174,7 @@ pub async fn clear_and_reset_video_status( let mut video_info = video_info.into_active_model(); video_info.single_page = Set(None); video_info.download_status = Set(0); + video_info.valid = Set(true); let video_info = video_info.update(&txn).await?; page::Entity::delete_many() .filter(page::Column::VideoId.eq(id)) @@ -193,6 +194,7 @@ pub async fn clear_and_reset_video_status( bvid: video_info.bvid, name: video_info.name, upper_name: video_info.upper_name, + valid: video_info.valid, should_download: video_info.should_download, download_status: video_info.download_status, }, diff --git a/crates/bili_sync/src/utils/convert.rs b/crates/bili_sync/src/utils/convert.rs index c1d0a40..47a64bc 100644 --- a/crates/bili_sync/src/utils/convert.rs +++ b/crates/bili_sync/src/utils/convert.rs @@ -10,6 +10,7 @@ impl VideoInfo { let default = bili_sync_entity::video::ActiveModel { id: NotSet, created_at: NotSet, + should_download: NotSet, // 此处不使用 ActiveModel::default() 是为了让其它字段有默认值 ..bili_sync_entity::video::Model::default().into_active_model() }; @@ -49,7 +50,7 @@ impl VideoInfo { pubtime: Set(pubtime.naive_utc()), favtime: Set(fav_time.naive_utc()), download_status: Set(0), - valid: Set(attr == 0), + valid: Set(attr == 0 || attr == 4), upper_id: Set(upper.mid), upper_name: Set(upper.name), upper_face: Set(upper.face), diff --git a/web/src/lib/components/video-card.svelte b/web/src/lib/components/video-card.svelte index 54a28a4..0379545 100644 --- a/web/src/lib/components/video-card.svelte +++ b/web/src/lib/components/video-card.svelte @@ -57,11 +57,16 @@ function getOverallStatus( downloadStatus: number[], - shouldDownload: boolean + shouldDownload: boolean, + valid: boolean ): { text: string; style: string; } { + if (!valid) { + // 视频属性表明已失效,或由于各种条件判断(充电视频等)判定为无效的情况 + return { text: '无效', style: 'bg-gray-100 text-gray-700' }; + } if (!shouldDownload) { // 被过滤规则排除,显示为“跳过” return { text: '跳过', style: 'bg-gray-100 text-gray-700' }; @@ -90,7 +95,7 @@ return defaultTaskNames[index] || `任务${index + 1}`; } - $: overallStatus = getOverallStatus(video.download_status, video.should_download); + $: overallStatus = getOverallStatus(video.download_status, video.should_download, video.valid); $: completed = video.download_status.filter((status) => status === 7).length; $: total = video.download_status.length; diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index e46a229..cfd7917 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -31,6 +31,7 @@ export interface VideoInfo { bvid: string; name: string; upper_name: string; + valid: boolean; should_download: boolean; download_status: [number, number, number, number, number]; }