mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-09-09 01:27:27 +08:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5839a7f5b | ||
|
|
d1ef3a87be | ||
|
|
f394ae68e7 |
@@ -327,6 +327,7 @@ pub mod v1 {
|
||||
pub part_title: Option<String>,
|
||||
pub part_order: Option<i64>,
|
||||
pub episode_title: String,
|
||||
pub episode_title_in_collection: Option<String>,
|
||||
pub episode_order: i64,
|
||||
pub up_name: Option<String>,
|
||||
pub up_uid: Option<i64>,
|
||||
|
||||
Generated
+16
@@ -315,6 +315,7 @@ dependencies = [
|
||||
"tauri-plugin-dialog",
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-os",
|
||||
"tauri-plugin-window-state",
|
||||
"tauri-specta",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@@ -4463,6 +4464,21 @@ dependencies = [
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-window-state"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d5f6fe3291bfa609c7e0b0ee3bedac294d94c7018934086ce782c1d0f2a468e"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime"
|
||||
version = "2.7.0"
|
||||
|
||||
@@ -22,6 +22,7 @@ tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-os = "2"
|
||||
tauri-plugin-dialog = "2"
|
||||
tauri-plugin-window-state = "2"
|
||||
dlopen2 = { version = "0.8.2" }
|
||||
bilibili-video-downloader-plugin-api = { path = "../src-plugin/plugin-api" }
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ use crate::{
|
||||
bangumi_info::BangumiInfo,
|
||||
cheese_info::CheeseInfo,
|
||||
codec_type::CodecType,
|
||||
get_normal_info_params::GetNormalInfoParams,
|
||||
normal_info::{NormalInfo, UgcSeason},
|
||||
video_quality::VideoQuality,
|
||||
},
|
||||
@@ -54,6 +55,7 @@ pub struct DownloadProgress {
|
||||
pub part_title: Option<String>,
|
||||
pub part_order: Option<i64>,
|
||||
pub episode_title: String,
|
||||
pub episode_title_in_collection: Option<String>,
|
||||
pub episode_order: i64,
|
||||
pub up_name: Option<String>,
|
||||
pub up_uid: Option<i64>,
|
||||
@@ -129,6 +131,7 @@ impl DownloadProgress {
|
||||
part_title: None,
|
||||
part_order: None,
|
||||
episode_title: episode.show_title.clone().unwrap_or(episode.title.clone()),
|
||||
episode_title_in_collection: None,
|
||||
episode_order,
|
||||
up_name,
|
||||
up_uid,
|
||||
@@ -179,6 +182,7 @@ impl DownloadProgress {
|
||||
part_title: None,
|
||||
part_order: None,
|
||||
episode_title: episode.title.clone(),
|
||||
episode_title_in_collection: None,
|
||||
episode_order: episode.index,
|
||||
up_name: Some(info.up_info.uname.clone()),
|
||||
up_uid: Some(info.up_info.mid),
|
||||
@@ -338,6 +342,18 @@ impl DownloadProgress {
|
||||
let audio_selected = self.audio_task.selected;
|
||||
let audio_completed = self.audio_task.completed;
|
||||
|
||||
// 通过合集批量创建的任务时,合集接口只提供视频在合集内的标题
|
||||
// 所以在创建任务阶段,episode_title暂时用它占位
|
||||
// 在真正开始下载前,需要重新获取视频的真实标题
|
||||
if self.episode_type == EpisodeType::Normal && self.episode_title_in_collection.is_some() {
|
||||
let bili_client = app.get_bili_client();
|
||||
let info = bili_client
|
||||
.get_normal_info(GetNormalInfoParams::Aid(self.aid))
|
||||
.await
|
||||
.wrap_err("获取视频信息失败")?;
|
||||
self.episode_title = info.title;
|
||||
}
|
||||
|
||||
if (!video_selected && !audio_selected) || (video_completed && audio_completed) {
|
||||
// 如果视频和音频都没有选中,或者都已经完成,则更新需要格式化的字段就返回
|
||||
self.update_fmt_fields(app)
|
||||
@@ -352,6 +368,7 @@ impl DownloadProgress {
|
||||
let Some(bvid) = &self.bvid else {
|
||||
return Err(eyre!("progress中的bvid为None,无法获取视频链接"));
|
||||
};
|
||||
|
||||
let media_url = bili_client
|
||||
.get_normal_url(bvid, self.cid)
|
||||
.await
|
||||
@@ -442,6 +459,7 @@ impl DownloadProgress {
|
||||
pub_ts: self.pub_ts,
|
||||
collection_title: self.collection_title.clone(),
|
||||
episode_title: self.episode_title.clone(),
|
||||
episode_title_in_collection: self.episode_title_in_collection.clone(),
|
||||
episode_order: self.episode_order,
|
||||
part_title: self.part_title.clone(),
|
||||
part_order: self.part_order,
|
||||
@@ -526,6 +544,7 @@ fn create_normal_progresses_for_single(
|
||||
part_title: Some(page.part.clone()),
|
||||
part_order: Some(page.page),
|
||||
episode_title: info.title.clone(),
|
||||
episode_title_in_collection: None,
|
||||
episode_order: 1,
|
||||
up_name: Some(info.owner.name.clone()),
|
||||
up_uid: Some(info.owner.mid),
|
||||
@@ -564,6 +583,7 @@ fn create_normal_progresses_for_single(
|
||||
part_title: None,
|
||||
part_order: None,
|
||||
episode_title: info.title.clone(),
|
||||
episode_title_in_collection: None,
|
||||
episode_order: 1,
|
||||
up_name: Some(info.owner.name.clone()),
|
||||
up_uid: Some(info.owner.mid),
|
||||
@@ -602,6 +622,7 @@ fn create_normal_progresses_for_single(
|
||||
part_title: Some(page.part.clone()),
|
||||
part_order: Some(page.page),
|
||||
episode_title: info.title.clone(),
|
||||
episode_title_in_collection: None,
|
||||
episode_order: 1,
|
||||
up_name: Some(info.owner.name.clone()),
|
||||
up_uid: Some(info.owner.mid),
|
||||
@@ -653,6 +674,10 @@ fn create_normal_progresses_for_season(
|
||||
|
||||
let tasks = Tasks::new(config, &ep.arc.pic);
|
||||
|
||||
// 合集接口返回的只有在合集内的标题,视频标题先用它占位,到prepare时再按aid获取真实标题
|
||||
let episode_title = ep.title.clone();
|
||||
let episode_title_in_collection = Some(ep.title.clone());
|
||||
|
||||
let create_ts = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs();
|
||||
|
||||
if let Some(cid) = cid {
|
||||
@@ -672,7 +697,8 @@ fn create_normal_progresses_for_season(
|
||||
collection_title: ugc_season.title.clone(),
|
||||
part_title: Some(page.part.clone()),
|
||||
part_order: Some(page.page),
|
||||
episode_title: ep.title.clone(),
|
||||
episode_title: episode_title.clone(),
|
||||
episode_title_in_collection: episode_title_in_collection.clone(),
|
||||
episode_order,
|
||||
up_name: Some(info.owner.name.clone()),
|
||||
up_uid: Some(info.owner.mid),
|
||||
@@ -710,7 +736,8 @@ fn create_normal_progresses_for_season(
|
||||
collection_title: ugc_season.title.clone(),
|
||||
part_title: None,
|
||||
part_order: None,
|
||||
episode_title: ep.title.clone(),
|
||||
episode_title: episode_title.clone(),
|
||||
episode_title_in_collection: episode_title_in_collection.clone(),
|
||||
episode_order,
|
||||
up_name: Some(info.owner.name.clone()),
|
||||
up_uid: Some(info.owner.mid),
|
||||
@@ -749,7 +776,8 @@ fn create_normal_progresses_for_season(
|
||||
collection_title: ugc_season.title.clone(),
|
||||
part_title: Some(page.part.clone()),
|
||||
part_order: Some(page.page),
|
||||
episode_title: ep.title.clone(),
|
||||
episode_title: episode_title.clone(),
|
||||
episode_title_in_collection: episode_title_in_collection.clone(),
|
||||
episode_order,
|
||||
up_name: Some(info.owner.name.clone()),
|
||||
up_uid: Some(info.owner.mid),
|
||||
|
||||
@@ -130,6 +130,7 @@ impl DownloadTask {
|
||||
ep_id = progress.ep_id,
|
||||
collection_title = progress.collection_title,
|
||||
episode_title = progress.episode_title,
|
||||
episode_title_in_collection = progress.episode_title_in_collection,
|
||||
episode_order = progress.episode_order,
|
||||
part_title = progress.part_title,
|
||||
part_order = progress.part_order,
|
||||
@@ -278,6 +279,7 @@ impl DownloadTask {
|
||||
ep_id = self.trace_fields.ep_id,
|
||||
collection_title = self.trace_fields.collection_title,
|
||||
episode_title = self.trace_fields.episode_title,
|
||||
episode_title_in_collection = self.trace_fields.episode_title_in_collection,
|
||||
episode_order = self.trace_fields.episode_order,
|
||||
part_title = self.trace_fields.part_title,
|
||||
part_order = self.trace_fields.part_order,
|
||||
@@ -484,6 +486,7 @@ impl DownloadTask {
|
||||
ep_id = self.trace_fields.ep_id,
|
||||
collection_title = self.trace_fields.collection_title,
|
||||
episode_title = self.trace_fields.episode_title,
|
||||
episode_title_in_collection = self.trace_fields.episode_title_in_collection,
|
||||
episode_order = self.trace_fields.episode_order,
|
||||
part_title = self.trace_fields.part_title,
|
||||
part_order = self.trace_fields.part_order,
|
||||
@@ -546,6 +549,7 @@ pub struct DownloadTaskTraceFields {
|
||||
pub ep_id: Option<i64>,
|
||||
pub collection_title: String,
|
||||
pub episode_title: String,
|
||||
pub episode_title_in_collection: Option<String>,
|
||||
pub episode_order: i64,
|
||||
pub part_title: Option<String>,
|
||||
pub part_order: Option<i64>,
|
||||
@@ -564,6 +568,7 @@ impl From<&DownloadProgress> for DownloadTaskTraceFields {
|
||||
ep_id: progress.ep_id,
|
||||
collection_title: progress.collection_title.clone(),
|
||||
episode_title: progress.episode_title.clone(),
|
||||
episode_title_in_collection: progress.episode_title_in_collection.clone(),
|
||||
episode_order: progress.episode_order,
|
||||
part_title: progress.part_title.clone(),
|
||||
part_order: progress.part_order,
|
||||
|
||||
@@ -25,6 +25,7 @@ pub struct FmtParams {
|
||||
pub pub_ts: i64,
|
||||
pub collection_title: String,
|
||||
pub episode_title: String,
|
||||
pub episode_title_in_collection: Option<String>,
|
||||
pub episode_order: i64,
|
||||
pub part_title: Option<String>,
|
||||
pub part_order: Option<i64>,
|
||||
|
||||
@@ -106,6 +106,7 @@ pub fn run() {
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
pub mod audio_quality;
|
||||
pub mod available_media_formats;
|
||||
pub mod bangumi_follow_info;
|
||||
@@ -36,3 +38,12 @@ pub mod user_info;
|
||||
pub mod user_video_info;
|
||||
pub mod video_quality;
|
||||
pub mod watch_later_info;
|
||||
|
||||
fn deserialize_null_default<'de, D, T>(deserializer: D) -> Result<T, D::Error>
|
||||
where
|
||||
T: Default + Deserialize<'de>,
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let opt = Option::deserialize(deserializer)?;
|
||||
Ok(opt.unwrap_or_default())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
|
||||
use super::deserialize_null_default;
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
@@ -30,6 +32,7 @@ pub struct PlayerInfo {
|
||||
pub online_count: i64,
|
||||
pub need_login_subtitle: bool,
|
||||
pub subtitle: SubtitleInPlayerInfo,
|
||||
#[serde(default, deserialize_with = "deserialize_null_default")]
|
||||
pub view_points: Vec<ViewPoint>,
|
||||
pub preview_toast: String,
|
||||
pub options: Options,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"height": 600,
|
||||
"minWidth": 800,
|
||||
"minHeight": 600,
|
||||
"visible": false,
|
||||
"decorations": false,
|
||||
"theme": "Light"
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"height": 600,
|
||||
"minWidth": 800,
|
||||
"minHeight": 600,
|
||||
"visible": false,
|
||||
"hiddenTitle": true,
|
||||
"titleBarStyle": "Overlay",
|
||||
"theme": "Light"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"height": 600,
|
||||
"minWidth": 800,
|
||||
"minHeight": 600,
|
||||
"visible": false,
|
||||
"decorations": false,
|
||||
"shadow": true,
|
||||
"theme": "Light"
|
||||
|
||||
+1
-1
@@ -329,7 +329,7 @@ export type Dimension = { width: number; height: number; rotate: number }
|
||||
export type DimensionInBangumi = { height: number; rotate: number; width: number }
|
||||
export type DimensionInWatchLater = { width: number; height: number; rotate: number }
|
||||
export type DownloadEvent = { event: "Speed"; data: { speed: string } } | { event: "TaskCreate"; data: { state: DownloadTaskState; progress: DownloadProgress } } | { event: "TaskStateUpdate"; data: { task_id: string; state: DownloadTaskState } } | { event: "TaskSleeping"; data: { task_id: string; remaining_sec: number } } | { event: "TaskDelete"; data: { task_id: string } } | { event: "ProgressPreparing"; data: { task_id: string } } | { event: "ProgressUpdate"; data: { progress: DownloadProgress } }
|
||||
export type DownloadProgress = { task_id: string; episode_type: EpisodeType; aid: number; bvid: string | null; cid: number; ep_id: number | null; duration: number; pub_ts: number; collection_title: string; part_title: string | null; part_order: number | null; episode_title: string; episode_order: number; up_name: string | null; up_uid: number | null; up_avatar: string | null; episode_dir: string; filename: string; video_task: VideoTask; audio_task: AudioTask; video_process_task: VideoProcessTask; subtitle_task: SubtitleTask; danmaku_task: DanmakuTask; cover_task: CoverTask; nfo_task: NfoTask; json_task: JsonTask; create_ts: number; completed_ts: number | null; is_drm: boolean; is_preview: boolean }
|
||||
export type DownloadProgress = { task_id: string; episode_type: EpisodeType; aid: number; bvid: string | null; cid: number; ep_id: number | null; duration: number; pub_ts: number; collection_title: string; part_title: string | null; part_order: number | null; episode_title: string; episode_title_in_collection: string | null; episode_order: number; up_name: string | null; up_uid: number | null; up_avatar: string | null; episode_dir: string; filename: string; video_task: VideoTask; audio_task: AudioTask; video_process_task: VideoProcessTask; subtitle_task: SubtitleTask; danmaku_task: DanmakuTask; cover_task: CoverTask; nfo_task: NfoTask; json_task: JsonTask; create_ts: number; completed_ts: number | null; is_drm: boolean; is_preview: boolean }
|
||||
export type DownloadTaskState = "Pending" | "Downloading" | "Paused" | "Completed" | "Failed"
|
||||
export type Ed = { end: number; start: number }
|
||||
export type EpInBangumi = { aid: number; badge: string; badge_info: BadgeInfoInBangumi; badge_type: number | null; bvid: string | null; cid: number; cover: string; dimension: DimensionInBangumi | null; duration: number | null; enable_vt: boolean; ep_id: number; from: string | null; id: number; is_view_hide: boolean; link: string; link_type: string | null; long_title: string | null; pub_time: number; pv: number; release_date: string | null; rights: RightsInBangumiEp | null; section_type: number; share_copy: string | null; share_url: string | null; short_link: string | null; showDrmLoginDialog: boolean; show_title: string | null; skip: Skip | null; status: number; subtitle: string | null; title: string; vid: string | null; icon_font: IconFont | null }
|
||||
|
||||
@@ -56,13 +56,17 @@ function AvailableFmtFields() {
|
||||
<div>
|
||||
<span class="rounded bg-gray-500 px-1 select-all">collection_title</span>
|
||||
<span class="ml-2">
|
||||
合集名称,
|
||||
<span class="text-blue">对于单独(没有合集)的视频,合集名称就是视频名称</span>
|
||||
合集标题,
|
||||
<span class="text-blue">对于单独(没有合集)的视频,合集标题就是视频标题</span>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="rounded bg-gray-500 px-1 select-all">episode_title</span>
|
||||
<span class="ml-2">视频名称</span>
|
||||
<span class="ml-2">视频标题</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="rounded bg-gray-500 px-1 select-all">episode_title_in_collection</span>
|
||||
<span class="ml-2">视频在合集内的标题</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="rounded bg-gray-500 px-1 select-all">episode_order</span>
|
||||
@@ -83,7 +87,7 @@ function AvailableFmtFields() {
|
||||
</div>
|
||||
<div>
|
||||
<span class="rounded bg-gray-500 px-1 select-all">part_title</span>
|
||||
<span class="ml-2">分P名称</span>
|
||||
<span class="ml-2">分P标题</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="rounded bg-gray-500 px-1 select-all">part_order</span>
|
||||
|
||||
Reference in New Issue
Block a user