change icon and add more logs
This commit is contained in:
@@ -56,6 +56,12 @@ pub struct LogEvent {
|
||||
|
||||
|
||||
pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> {
|
||||
app.emit("download-log", LogEvent {
|
||||
id: "Analysis".to_string(),
|
||||
message: format!("Starting metadata fetch for URL: {}", url),
|
||||
level: "info".to_string(),
|
||||
}).ok();
|
||||
|
||||
let ytdlp_path = binary_manager::get_ytdlp_path(app)?;
|
||||
let qjs_path = binary_manager::get_qjs_path(app)?; // Get absolute path to quickjs
|
||||
|
||||
@@ -79,6 +85,11 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
app.emit("download-log", LogEvent {
|
||||
id: "Analysis".to_string(),
|
||||
message: format!("Metadata fetch failed: {}", stderr),
|
||||
level: "error".to_string(),
|
||||
}).ok();
|
||||
return Err(anyhow!("yt-dlp error: {}", stderr));
|
||||
}
|
||||
|
||||
@@ -95,16 +106,31 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
|
||||
entries.push(parse_video_metadata(entry));
|
||||
}
|
||||
|
||||
return Ok(MetadataResult::Playlist(PlaylistMetadata {
|
||||
let result = MetadataResult::Playlist(PlaylistMetadata {
|
||||
id: json["id"].as_str().unwrap_or("").to_string(),
|
||||
title: json["title"].as_str().unwrap_or("Unknown Playlist").to_string(),
|
||||
entries,
|
||||
}));
|
||||
});
|
||||
|
||||
app.emit("download-log", LogEvent {
|
||||
id: "Analysis".to_string(),
|
||||
message: "Metadata fetch success (Playlist)".to_string(),
|
||||
level: "info".to_string(),
|
||||
}).ok();
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
// Single video
|
||||
Ok(MetadataResult::Video(parse_video_metadata(&json)))
|
||||
let result = MetadataResult::Video(parse_video_metadata(&json));
|
||||
app.emit("download-log", LogEvent {
|
||||
id: "Analysis".to_string(),
|
||||
message: "Metadata fetch success (Video)".to_string(),
|
||||
level: "info".to_string(),
|
||||
}).ok();
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn parse_video_metadata(json: &serde_json::Value) -> VideoMetadata {
|
||||
@@ -165,6 +191,14 @@ pub async fn download_video(
|
||||
// Progress output
|
||||
args.push("--newline".to_string());
|
||||
|
||||
// Log the full command
|
||||
let full_cmd_str = format!("{} {}", ytdlp_path.to_string_lossy(), args.join(" "));
|
||||
app.emit("download-log", LogEvent {
|
||||
id: id.clone(),
|
||||
message: format!("Executing command: {}", full_cmd_str),
|
||||
level: "info".to_string(),
|
||||
}).ok();
|
||||
|
||||
let mut cmd = Command::new(ytdlp_path);
|
||||
|
||||
let mut child = cmd
|
||||
|
||||
Reference in New Issue
Block a user