/** * Media download helper — shared logic for batch downloading images/videos. * * Used by: xiaohongshu/download, twitter/download, bilibili/download, * and future media adapters. * * Flow: MediaItem[] → DownloadProgressTracker → httpDownload/ytdlpDownload → results */ import type { BrowserCookie } from '../types.js'; export interface MediaItem { type: 'image' | 'video' | 'video-tweet' | 'video-ytdlp'; url: string; /** Optional custom filename (without directory) */ filename?: string; } export interface MediaDownloadOptions { output: string; /** Subdirectory inside output */ subdir?: string; /** Cookie string for HTTP downloads */ cookies?: string; /** Raw browser cookies — auto-exported to Netscape for yt-dlp, auto-cleaned up */ browserCookies?: BrowserCookie[]; /** Timeout in ms (default: 30000 for images, 60000 for videos) */ timeout?: number; /** File name prefix (default: 'download') */ filenamePrefix?: string; /** Extra yt-dlp args */ ytdlpExtraArgs?: string[]; /** Whether to show progress (default: true) */ verbose?: boolean; } export interface MediaDownloadResult { index: number; type: string; status: string; size: string; } /** * Batch download media files with progress tracking. * * Handles: * - DownloadProgressTracker for terminal UX * - Automatic httpDownload vs ytdlpDownload routing via MediaItem.type * - Cookie export to Netscape format for yt-dlp (auto-cleanup) * - Directory creation * - Error handling with per-file results */ export declare function downloadMedia(items: MediaItem[], options: MediaDownloadOptions): Promise;