mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-09-05 23:57:23 +08:00
chore: 清理clippy的警告
This commit is contained in:
+1
-1
@@ -1,3 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
tauri_build::build();
|
||||
}
|
||||
|
||||
@@ -832,10 +832,10 @@ impl BiliClient {
|
||||
let request = self.content_length_client.read().head(media_url);
|
||||
let http_resp = request.send().await?;
|
||||
let status = http_resp.status();
|
||||
if status == StatusCode::OK {
|
||||
if let Ok(content_length) = parse_content_length(http_resp.headers()) {
|
||||
return Ok(content_length);
|
||||
}
|
||||
if status == StatusCode::OK
|
||||
&& let Ok(content_length) = parse_content_length(http_resp.headers())
|
||||
{
|
||||
return Ok(content_length);
|
||||
}
|
||||
|
||||
// 部分 upos/CDN 对 HEAD 支持不完整(尤其是高码率/高帧率流),这里降级用 Range 请求探测总大小
|
||||
|
||||
@@ -53,7 +53,7 @@ impl DownloadChunkTask {
|
||||
sleep(Duration::from_millis(100)).await;
|
||||
if let Some(permit) = permit.take() {
|
||||
drop(permit);
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ impl DownloadTask {
|
||||
download_task_option = None;
|
||||
if let Some(permit) = permit.take() {
|
||||
drop(permit);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
() = self.acquire_task_permit(&mut permit), if state_is_pending => {},
|
||||
@@ -333,7 +333,7 @@ impl DownloadTask {
|
||||
tracing::debug!("ID为`{task_id}`的下载任务已暂停");
|
||||
if let Some(permit) = permit.take() {
|
||||
drop(permit);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,16 +95,16 @@ impl FmtParams {
|
||||
|
||||
#[allow(clippy::cast_possible_wrap)]
|
||||
fn format_time_fields(json_map: &mut Map<String, Value>, time_fmt: &str) {
|
||||
if let Some(ts) = json_map.get("pub_ts").and_then(Value::as_i64) {
|
||||
if let Some(ts_string) = ts_to_string(ts, time_fmt) {
|
||||
json_map.insert("pub_ts".to_string(), Value::String(ts_string));
|
||||
}
|
||||
if let Some(ts) = json_map.get("pub_ts").and_then(Value::as_i64)
|
||||
&& let Some(ts_string) = ts_to_string(ts, time_fmt)
|
||||
{
|
||||
json_map.insert("pub_ts".to_string(), Value::String(ts_string));
|
||||
}
|
||||
|
||||
if let Some(ts) = json_map.get("create_ts").and_then(Value::as_u64) {
|
||||
if let Some(ts_string) = ts_to_string(ts as i64, time_fmt) {
|
||||
json_map.insert("create_ts".to_string(), Value::String(ts_string));
|
||||
}
|
||||
if let Some(ts) = json_map.get("create_ts").and_then(Value::as_u64)
|
||||
&& let Some(ts_string) = ts_to_string(ts as i64, time_fmt)
|
||||
{
|
||||
json_map.insert("create_ts".to_string(), Value::String(ts_string));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ impl AudioTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias);
|
||||
self.prepare(app, &medias);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -181,7 +181,7 @@ impl AudioTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias);
|
||||
self.prepare(app, &medias);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -241,12 +241,12 @@ impl AudioTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias);
|
||||
self.prepare(app, &medias);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn prepare(&mut self, app: &AppHandle, medias: Vec<MediaForPrepare>) {
|
||||
fn prepare(&mut self, app: &AppHandle, medias: &[MediaForPrepare]) {
|
||||
if medias.is_empty() {
|
||||
self.completed = true;
|
||||
return;
|
||||
@@ -256,10 +256,9 @@ impl AudioTask {
|
||||
let prefer_select_by_priority = self.audio_quality == AudioQuality::Unknown;
|
||||
|
||||
let selected_media = if prefer_select_by_priority {
|
||||
select_media_by_priority(app, &medias)
|
||||
select_media_by_priority(app, medias)
|
||||
} else {
|
||||
select_exact_match_media(self, &medias)
|
||||
.or_else(|| select_media_by_priority(app, &medias))
|
||||
select_exact_match_media(self, medias).or_else(|| select_media_by_priority(app, medias))
|
||||
};
|
||||
|
||||
let Some(media) = selected_media else {
|
||||
|
||||
@@ -101,7 +101,7 @@ impl VideoTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias)?;
|
||||
self.prepare(app, &medias)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -171,7 +171,7 @@ impl VideoTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias)?;
|
||||
self.prepare(app, &medias)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -241,12 +241,12 @@ impl VideoTask {
|
||||
}
|
||||
}
|
||||
|
||||
self.prepare(app, medias)?;
|
||||
self.prepare(app, &medias)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn prepare(&mut self, app: &AppHandle, medias: Vec<MediaForPrepare>) -> anyhow::Result<()> {
|
||||
fn prepare(&mut self, app: &AppHandle, medias: &[MediaForPrepare]) -> anyhow::Result<()> {
|
||||
if medias.is_empty() {
|
||||
return Err(anyhow!("获取视频地址失败,medias为空"));
|
||||
}
|
||||
@@ -264,10 +264,9 @@ impl VideoTask {
|
||||
let prefer_select_by_priority = video_quality_is_unknown;
|
||||
|
||||
let selected_media = if prefer_select_by_priority {
|
||||
select_media_by_priority(app, &medias)
|
||||
select_media_by_priority(app, medias)
|
||||
} else {
|
||||
select_exact_match_media(self, &medias)
|
||||
.or_else(|| select_media_by_priority(app, &medias))
|
||||
select_exact_match_media(self, medias).or_else(|| select_media_by_priority(app, medias))
|
||||
};
|
||||
|
||||
let media = selected_media.context("获取视频地址失败,medias为空")?;
|
||||
|
||||
+13
-3
@@ -10,13 +10,20 @@ mod logger;
|
||||
mod types;
|
||||
mod utils;
|
||||
mod wbi;
|
||||
#[allow(dead_code)]
|
||||
#[allow(warnings)]
|
||||
mod protobuf {
|
||||
include!("./bilibili.community.service.dm.v1.rs");
|
||||
}
|
||||
|
||||
use anyhow::Context;
|
||||
use commands::*;
|
||||
use commands::{
|
||||
create_download_tasks, delete_download_tasks, generate_qrcode, get_available_media_formats,
|
||||
get_bangumi_follow_info, get_bangumi_info, get_config, get_fav_folders, get_fav_info,
|
||||
get_history_info, get_logs_dir_size, get_normal_info, get_qrcode_status, get_skip_segments,
|
||||
get_user_info, get_user_video_info, get_watch_later_info, pause_download_tasks,
|
||||
restart_download_task, restart_download_tasks, restore_download_tasks, resume_download_tasks,
|
||||
save_config, search, show_path_in_file_manager,
|
||||
};
|
||||
use config::Config;
|
||||
use parking_lot::RwLock;
|
||||
use tauri::{Manager, Wry};
|
||||
@@ -31,6 +38,7 @@ fn generate_context() -> tauri::Context<Wry> {
|
||||
tauri::generate_context!()
|
||||
}
|
||||
|
||||
#[allow(clippy::missing_panics_doc)]
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let builder = tauri_specta::Builder::<Wry>::new()
|
||||
@@ -76,7 +84,9 @@ pub fn run() {
|
||||
|
||||
// 解决Ubuntu24.04窗口全白的问题
|
||||
#[cfg(target_os = "linux")]
|
||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||
unsafe {
|
||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
||||
@@ -195,12 +195,12 @@ async fn file_log_watcher(app: AppHandle) {
|
||||
while let Some(res) = receiver.recv().await {
|
||||
match res.map_err(anyhow::Error::from) {
|
||||
Ok(event) => {
|
||||
if let notify::EventKind::Remove(_) = event.kind {
|
||||
if let Err(err) = reload_file_logger() {
|
||||
let err_title = "重置日志文件失败";
|
||||
let string_chain = err.to_string_chain();
|
||||
tracing::error!(err_title, message = string_chain);
|
||||
}
|
||||
if let notify::EventKind::Remove(_) = event.kind
|
||||
&& let Err(err) = reload_file_logger()
|
||||
{
|
||||
let err_title = "重置日志文件失败";
|
||||
let string_chain = err.to_string_chain();
|
||||
tracing::error!(err_title, message = string_chain);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
bilibili_video_downloader_lib::run()
|
||||
bilibili_video_downloader_lib::run();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use super::{
|
||||
user_video_info::UserVideoInfo,
|
||||
};
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Type)]
|
||||
pub enum SearchResult {
|
||||
Normal(NormalSearchResult),
|
||||
|
||||
Reference in New Issue
Block a user