mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-08-28 03:26:59 +08:00
fix: 修复充电试看视频下载失败的问题
This commit is contained in:
@@ -114,7 +114,7 @@ impl AudioTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias)?;
|
||||
self.prepare(app, medias);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -170,7 +170,7 @@ impl AudioTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias)?;
|
||||
self.prepare(app, medias);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -226,14 +226,15 @@ impl AudioTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias)?;
|
||||
self.prepare(app, medias);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn prepare(&mut self, app: &AppHandle, mut medias: Vec<MediaForPrepare>) -> anyhow::Result<()> {
|
||||
fn prepare(&mut self, app: &AppHandle, mut medias: Vec<MediaForPrepare>) {
|
||||
if medias.is_empty() {
|
||||
return Err(anyhow!("获取音频地址失败"));
|
||||
self.completed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let quality_priority = app.get_config().read().audio_quality_priority.clone();
|
||||
@@ -278,8 +279,6 @@ impl AudioTask {
|
||||
self.content_length = content_length;
|
||||
self.chunks = chunks;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn mark_uncompleted(&mut self) {
|
||||
|
||||
@@ -66,6 +66,26 @@ impl VideoTask {
|
||||
});
|
||||
}
|
||||
|
||||
for durl in &media_url.durl {
|
||||
let app = app.clone();
|
||||
let id = media_url.quality;
|
||||
let codecid = media_url.video_codecid;
|
||||
|
||||
let mut urls = Vec::new();
|
||||
urls.extend_from_slice(&durl.backup_url);
|
||||
urls.push(durl.url.clone());
|
||||
|
||||
join_set.spawn(async move {
|
||||
let bili_client = app.get_bili_client();
|
||||
let url_with_content_length = bili_client.get_url_with_content_length(urls).await;
|
||||
MediaForPrepare {
|
||||
id,
|
||||
url_with_content_length,
|
||||
codecid,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let mut medias: Vec<MediaForPrepare> = Vec::new();
|
||||
|
||||
while let Some(Ok(media)) = join_set.join_next().await {
|
||||
@@ -213,7 +233,7 @@ impl VideoTask {
|
||||
|
||||
fn prepare(&mut self, app: &AppHandle, mut medias: Vec<MediaForPrepare>) -> anyhow::Result<()> {
|
||||
if medias.is_empty() {
|
||||
return Err(anyhow!("获取音频地址失败"));
|
||||
return Err(anyhow!("获取视频地址失败"));
|
||||
}
|
||||
|
||||
let (video_quality_priority, codec_type_priority) = {
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct NormalMediaUrl {
|
||||
pub video_codecid: i64,
|
||||
pub seek_param: String,
|
||||
pub seek_type: String,
|
||||
pub durl: Vec<DurlInNormal>,
|
||||
pub dash: DashInNormal,
|
||||
pub support_formats: Vec<SupportFormatInNormal>,
|
||||
pub last_play_time: i64,
|
||||
@@ -34,6 +35,18 @@ pub struct DashInNormal {
|
||||
pub flac: Option<Flac>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default)]
|
||||
pub struct DurlInNormal {
|
||||
pub order: i64,
|
||||
pub length: i64,
|
||||
pub size: i64,
|
||||
pub ahead: String,
|
||||
pub vhead: String,
|
||||
pub url: String,
|
||||
pub backup_url: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default)]
|
||||
pub struct Flac {
|
||||
|
||||
Reference in New Issue
Block a user