diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 48aa3b2..c7f0caa 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -77,7 +77,7 @@ pub async fn start_download(app: AppHandle, url: String, options: DownloadOption output_path: output_dir, timestamp: chrono::Utc::now(), status: status.to_string(), - format: options.quality, + format: options.output_format, }; let _ = storage::add_history_item(&app, item); diff --git a/src-tauri/src/downloader.rs b/src-tauri/src/downloader.rs index 5d92a01..83d762a 100644 --- a/src-tauri/src/downloader.rs +++ b/src-tauri/src/downloader.rs @@ -36,6 +36,7 @@ pub struct DownloadOptions { pub is_audio_only: bool, pub quality: String, // e.g., "1080", "720", "best" pub output_path: String, // Directory + pub output_format: String, // "original", "mp4", "webm", "mkv", "m4a", "aac", "opus", "vorbis", "wav", etc. } #[derive(Serialize, Clone, Debug)] @@ -188,8 +189,11 @@ pub async fn download_video( // Formats if options.is_audio_only { args.push("-x".to_string()); - args.push("--audio-format".to_string()); - args.push("mp3".to_string()); + // Only set audio format if not "original" + if options.output_format != "original" { + args.push("--audio-format".to_string()); + args.push(options.output_format.clone()); + } } else { let format_arg = if options.quality == "best" { "bestvideo+bestaudio/best".to_string() @@ -198,6 +202,12 @@ pub async fn download_video( }; args.push("-f".to_string()); args.push(format_arg); + + // Only set merge output format if not "original" + if options.output_format != "original" { + args.push("--merge-output-format".to_string()); + args.push(options.output_format.clone()); + } } // Progress output diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 44ecf61..3552b9d 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -12,7 +12,7 @@ "app": { "windows": [ { - "title": "流萤 - 视频下载", + "title": "流萤 - 视频下载 v1.0.0", "width": 1300, "height": 900 } diff --git a/src/stores/analysis.ts b/src/stores/analysis.ts index 008e908..10bdf76 100644 --- a/src/stores/analysis.ts +++ b/src/stores/analysis.ts @@ -15,7 +15,8 @@ export const useAnalysisStore = defineStore('analysis', () => { const options = ref({ is_audio_only: false, quality: 'best', - output_path: '' + output_path: '', + output_format: 'original' }) function toggleEntry(id: string) { diff --git a/src/views/Home.vue b/src/views/Home.vue index 161decf..0ca3d5b 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -18,6 +18,26 @@ const qualityOptions = [ { label: '480p', value: '480' }, ] +const videoFormatOptions = [ + { label: '原格式', value: 'original' }, + { label: 'MP4', value: 'mp4' }, + { label: 'WebM', value: 'webm' }, + { label: 'Matroska (MKV)', value: 'mkv' }, + { label: 'FLV', value: 'flv' }, + { label: 'AVI', value: 'avi' }, +] + +const audioFormatOptions = [ + { label: '原格式', value: 'original' }, + { label: 'MP3', value: 'mp3' }, + { label: 'M4A', value: 'm4a' }, + { label: 'AAC', value: 'aac' }, + { label: 'Opus', value: 'opus' }, + { label: 'Vorbis', value: 'vorbis' }, + { label: 'WAV', value: 'wav' }, + { label: 'FLAC', value: 'flac' }, +] + // Sync default download path if not set watch(() => settingsStore.settings.download_path, (newPath) => { if (newPath && !analysisStore.options.output_path) { @@ -36,6 +56,11 @@ watch(() => analysisStore.url, (newUrl) => { } }) +// Reset format to original when toggling audio-only mode +watch(() => analysisStore.options.is_audio_only, () => { + analysisStore.options.output_format = 'original' +}) + async function analyze() { if (!analysisStore.url) return analysisStore.loading = true @@ -217,9 +242,9 @@ async function startDownload() {
{{ analysisStore.metadata.entries.length }} 个视频 (播放列表)
-