fix download fails in batch mode
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "stream-capture",
|
"name": "stream-capture",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -3971,7 +3971,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stream-capture"
|
name = "stream-capture"
|
||||||
version = "1.0.1"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "stream-capture"
|
name = "stream-capture"
|
||||||
version = "1.0.1"
|
version = "1.1.0"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ pub struct VideoMetadata {
|
|||||||
pub thumbnail: String,
|
pub thumbnail: String,
|
||||||
pub duration: Option<f64>,
|
pub duration: Option<f64>,
|
||||||
pub uploader: Option<String>,
|
pub uploader: Option<String>,
|
||||||
|
pub url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -150,12 +151,17 @@ fn parse_video_metadata(json: &serde_json::Value) -> VideoMetadata {
|
|||||||
_ => format!("https://i.ytimg.com/vi/{}/mqdefault.jpg", id),
|
_ => format!("https://i.ytimg.com/vi/{}/mqdefault.jpg", id),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let url = json["webpage_url"].as_str()
|
||||||
|
.or_else(|| json["url"].as_str())
|
||||||
|
.map(|s| s.to_string());
|
||||||
|
|
||||||
VideoMetadata {
|
VideoMetadata {
|
||||||
id,
|
id,
|
||||||
title: json["title"].as_str().unwrap_or("Unknown Title").to_string(),
|
title: json["title"].as_str().unwrap_or("Unknown Title").to_string(),
|
||||||
thumbnail,
|
thumbnail,
|
||||||
duration: json["duration"].as_f64(),
|
duration: json["duration"].as_f64(),
|
||||||
uploader: json["uploader"].as_str().map(|s| s.to_string()),
|
uploader: json["uploader"].as_str().map(|s| s.to_string()),
|
||||||
|
url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "StreamCapture",
|
"productName": "StreamCapture",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"identifier": "top.volan.stream-capture",
|
"identifier": "top.volan.stream-capture",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev",
|
"beforeDevCommand": "pnpm dev",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"label": "main",
|
"label": "main",
|
||||||
"title": "流萤 - 视频下载 v1.0.1",
|
"title": "流萤 - 视频下载 v1.1.0",
|
||||||
"width": 1300,
|
"width": 1300,
|
||||||
"height": 900,
|
"height": 900,
|
||||||
"visible": false
|
"visible": false
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ async function startDownload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const entry of selectedEntries) {
|
for (const entry of selectedEntries) {
|
||||||
const videoUrl = `https://www.youtube.com/watch?v=${entry.id}`
|
const videoUrl = entry.url || `https://www.youtube.com/watch?v=${entry.id}`
|
||||||
const id = await invoke<string>('start_download', {
|
const id = await invoke<string>('start_download', {
|
||||||
url: videoUrl,
|
url: videoUrl,
|
||||||
options: analysisStore.options,
|
options: analysisStore.options,
|
||||||
@@ -264,7 +264,7 @@ async function startDownload() {
|
|||||||
>
|
>
|
||||||
<List v-if="analysisStore.isBatchMode" class="w-3.5 h-3.5" />
|
<List v-if="analysisStore.isBatchMode" class="w-3.5 h-3.5" />
|
||||||
<Link v-else class="w-3.5 h-3.5" />
|
<Link v-else class="w-3.5 h-3.5" />
|
||||||
{{ analysisStore.isBatchMode ? '切换到单链接模式' : '批量输入模式' }}
|
{{ analysisStore.isBatchMode ? '单链接模式' : '批量输入模式' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ async function startDownload() {
|
|||||||
v-else
|
v-else
|
||||||
v-model="analysisStore.url"
|
v-model="analysisStore.url"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="https://youtube.com/watch?v=..."
|
placeholder="https://..."
|
||||||
class="w-full bg-gray-50 dark:bg-zinc-800 border-none rounded-xl px-4 py-3 text-zinc-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"
|
class="w-full bg-gray-50 dark:bg-zinc-800 border-none rounded-xl px-4 py-3 text-zinc-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"
|
||||||
@keyup.enter="analyze"
|
@keyup.enter="analyze"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user