fix: 修复某些收藏夹视频的 valid 判断 (#648)
This commit is contained in:
@@ -73,6 +73,7 @@ pub struct VideoInfo {
|
|||||||
pub bvid: String,
|
pub bvid: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub upper_name: String,
|
pub upper_name: String,
|
||||||
|
pub valid: bool,
|
||||||
pub should_download: bool,
|
pub should_download: bool,
|
||||||
#[serde(serialize_with = "serde_video_download_status")]
|
#[serde(serialize_with = "serde_video_download_status")]
|
||||||
pub download_status: u32,
|
pub download_status: u32,
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ pub async fn clear_and_reset_video_status(
|
|||||||
let mut video_info = video_info.into_active_model();
|
let mut video_info = video_info.into_active_model();
|
||||||
video_info.single_page = Set(None);
|
video_info.single_page = Set(None);
|
||||||
video_info.download_status = Set(0);
|
video_info.download_status = Set(0);
|
||||||
|
video_info.valid = Set(true);
|
||||||
let video_info = video_info.update(&txn).await?;
|
let video_info = video_info.update(&txn).await?;
|
||||||
page::Entity::delete_many()
|
page::Entity::delete_many()
|
||||||
.filter(page::Column::VideoId.eq(id))
|
.filter(page::Column::VideoId.eq(id))
|
||||||
@@ -193,6 +194,7 @@ pub async fn clear_and_reset_video_status(
|
|||||||
bvid: video_info.bvid,
|
bvid: video_info.bvid,
|
||||||
name: video_info.name,
|
name: video_info.name,
|
||||||
upper_name: video_info.upper_name,
|
upper_name: video_info.upper_name,
|
||||||
|
valid: video_info.valid,
|
||||||
should_download: video_info.should_download,
|
should_download: video_info.should_download,
|
||||||
download_status: video_info.download_status,
|
download_status: video_info.download_status,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ impl VideoInfo {
|
|||||||
let default = bili_sync_entity::video::ActiveModel {
|
let default = bili_sync_entity::video::ActiveModel {
|
||||||
id: NotSet,
|
id: NotSet,
|
||||||
created_at: NotSet,
|
created_at: NotSet,
|
||||||
|
should_download: NotSet,
|
||||||
// 此处不使用 ActiveModel::default() 是为了让其它字段有默认值
|
// 此处不使用 ActiveModel::default() 是为了让其它字段有默认值
|
||||||
..bili_sync_entity::video::Model::default().into_active_model()
|
..bili_sync_entity::video::Model::default().into_active_model()
|
||||||
};
|
};
|
||||||
@@ -49,7 +50,7 @@ impl VideoInfo {
|
|||||||
pubtime: Set(pubtime.naive_utc()),
|
pubtime: Set(pubtime.naive_utc()),
|
||||||
favtime: Set(fav_time.naive_utc()),
|
favtime: Set(fav_time.naive_utc()),
|
||||||
download_status: Set(0),
|
download_status: Set(0),
|
||||||
valid: Set(attr == 0),
|
valid: Set(attr == 0 || attr == 4),
|
||||||
upper_id: Set(upper.mid),
|
upper_id: Set(upper.mid),
|
||||||
upper_name: Set(upper.name),
|
upper_name: Set(upper.name),
|
||||||
upper_face: Set(upper.face),
|
upper_face: Set(upper.face),
|
||||||
|
|||||||
@@ -57,11 +57,16 @@
|
|||||||
|
|
||||||
function getOverallStatus(
|
function getOverallStatus(
|
||||||
downloadStatus: number[],
|
downloadStatus: number[],
|
||||||
shouldDownload: boolean
|
shouldDownload: boolean,
|
||||||
|
valid: boolean
|
||||||
): {
|
): {
|
||||||
text: string;
|
text: string;
|
||||||
style: string;
|
style: string;
|
||||||
} {
|
} {
|
||||||
|
if (!valid) {
|
||||||
|
// 视频属性表明已失效,或由于各种条件判断(充电视频等)判定为无效的情况
|
||||||
|
return { text: '无效', style: 'bg-gray-100 text-gray-700' };
|
||||||
|
}
|
||||||
if (!shouldDownload) {
|
if (!shouldDownload) {
|
||||||
// 被过滤规则排除,显示为“跳过”
|
// 被过滤规则排除,显示为“跳过”
|
||||||
return { text: '跳过', style: 'bg-gray-100 text-gray-700' };
|
return { text: '跳过', style: 'bg-gray-100 text-gray-700' };
|
||||||
@@ -90,7 +95,7 @@
|
|||||||
return defaultTaskNames[index] || `任务${index + 1}`;
|
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;
|
$: completed = video.download_status.filter((status) => status === 7).length;
|
||||||
$: total = video.download_status.length;
|
$: total = video.download_status.length;
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export interface VideoInfo {
|
|||||||
bvid: string;
|
bvid: string;
|
||||||
name: string;
|
name: string;
|
||||||
upper_name: string;
|
upper_name: string;
|
||||||
|
valid: boolean;
|
||||||
should_download: boolean;
|
should_download: boolean;
|
||||||
download_status: [number, number, number, number, number];
|
download_status: [number, number, number, number, number];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user