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