feat: 添加开关,允许尝试下载未充电的视频 (#666)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2026-02-28 22:55:01 +08:00
committed by GitHub
parent fe13029e84
commit 2bd660efc9
5 changed files with 32 additions and 3 deletions

View File

@@ -50,6 +50,8 @@ pub struct Config {
pub concurrent_limit: ConcurrentLimit,
pub time_format: String,
pub cdn_sorting: bool,
#[serde(default)]
pub try_upower_anyway: bool,
pub version: u64,
}
@@ -131,6 +133,7 @@ impl Default for Config {
concurrent_limit: ConcurrentLimit::default(),
time_format: default_time_format(),
cdn_sorting: false,
try_upower_anyway: false,
version: 0,
}
}

View File

@@ -120,7 +120,12 @@ impl VideoInfo {
/// 填充视频详情时调用,该方法会将视频详情附加到原有的 Model 上
/// 特殊地,如果在检测视频更新时记录了 favtime那么 favtime 会维持原样,否则会使用 pubtime 填充
pub fn into_detail_model(self, base_model: bili_sync_entity::video::Model) -> bili_sync_entity::video::ActiveModel {
/// 如果开启 try_upower_anyway标记视频状态时不再检测是否充电一律进入后面的下载环节
pub fn into_detail_model(
self,
base_model: bili_sync_entity::video::Model,
try_upower_anyway: bool,
) -> bili_sync_entity::video::ActiveModel {
match self {
VideoInfo::Detail {
title,
@@ -154,7 +159,9 @@ impl VideoInfo {
// 2. 都为 false表示视频是非充电视频
// redirect_url 仅在视频为番剧、影视、纪录片等特殊视频时才会有值,如果为空说明是普通视频
// 仅在三种条件都满足时,才认为视频是可下载的
valid: Set(state == 0 && (is_upower_exclusive == is_upower_play) && redirect_url.is_none()),
valid: Set(state == 0
&& (try_upower_anyway || (is_upower_exclusive == is_upower_play))
&& redirect_url.is_none()),
upper_id: Set(upper.mid),
upper_name: Set(upper.name),
upper_face: Set(upper.face),

View File

@@ -150,7 +150,7 @@ pub async fn fetch_video_details(
.map(|p| p.into_active_model(video_model.id))
.collect::<Vec<page::ActiveModel>>();
// 更新 video model 的各项有关属性
let mut video_active_model = view_info.into_detail_model(video_model);
let mut video_active_model = view_info.into_detail_model(video_model, config.try_upower_anyway);
video_source.set_relation_id(&mut video_active_model);
video_active_model.single_page = Set(Some(pages.len() == 1));
video_active_model.tags = Set(Some(tags.into()));

View File

@@ -322,6 +322,7 @@ export interface Config {
concurrent_limit: ConcurrentLimit;
time_format: string;
cdn_sorting: boolean;
try_upower_anyway: boolean;
version: number;
}

View File

@@ -359,6 +359,24 @@
<Switch id="cdn-sorting" bind:checked={formData.cdn_sorting} />
<Label for="cdn-sorting">启用CDN排序</Label>
</div>
<div class="flex items-center space-x-2">
<Switch id="try-upower-anyway" bind:checked={formData.try_upower_anyway} />
<div class="flex items-center gap-1">
<Label for="try-upower-anyway">尝试下载未充电视频</Label>
<Tooltip.Root>
<Tooltip.Trigger>
<InfoIcon class="text-muted-foreground h-3.5 w-3.5" />
</Tooltip.Trigger>
<Tooltip.Content>
<p class="text-xs">
当关闭该开关时,程序仅会下载已充电的视频,未充电的视频直接跳过;开启后不再检查充电状态,一律尝试下载。<br
/>
这可以帮助下载未充电视频的封面等元数据,也应该可以下载未充电视频的试看部分(如果存在的话)。
</p>
</Tooltip.Content>
</Tooltip.Root>
</div>
</div>
</div>
</Tabs.Content>