fix ig thumbnail
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -3974,6 +3974,7 @@ name = "stream-capture"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"futures-util",
|
||||
"regex",
|
||||
|
||||
@@ -19,6 +19,7 @@ tauri-plugin-dialog = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
reqwest = { version = "0.12", features = ["json", "rustls-tls", "stream"] }
|
||||
base64 = "0.22"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
anyhow = "1.0"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
||||
@@ -49,6 +49,28 @@ pub fn get_ffmpeg_version(app: AppHandle) -> Result<String, String> {
|
||||
binary_manager::get_ffmpeg_version(&app).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn fetch_image(url: String) -> Result<String, String> {
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client.get(&url)
|
||||
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let bytes = res.bytes().await.map_err(|e| e.to_string())?;
|
||||
|
||||
// Convert to base64
|
||||
let b64 = general_purpose::STANDARD.encode(&bytes);
|
||||
|
||||
// Simple heuristic for mime type
|
||||
let mime = if url.to_lowercase().ends_with(".png") { "image/png" } else { "image/jpeg" };
|
||||
|
||||
Ok(format!("data:{};base64,{}", mime, b64))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn fetch_metadata(app: AppHandle, url: String, parse_mix_playlist: bool) -> Result<downloader::MetadataResult, String> {
|
||||
downloader::fetch_metadata(&app, &url, parse_mix_playlist).await.map_err(|e| e.to_string())
|
||||
|
||||
@@ -17,6 +17,7 @@ pub fn run() {
|
||||
commands::get_ytdlp_version,
|
||||
commands::get_quickjs_version,
|
||||
commands::get_ffmpeg_version,
|
||||
commands::fetch_image,
|
||||
commands::fetch_metadata,
|
||||
commands::start_download,
|
||||
commands::get_settings,
|
||||
|
||||
Reference in New Issue
Block a user