feat(youtube): add YouTube embed support with yt-dlp integration for ad-free streaming

This commit is contained in:
2026-02-20 16:27:59 +11:00
parent d5ca19f770
commit c55e311241
6 changed files with 378 additions and 9 deletions

View File

@@ -34,6 +34,40 @@ export const openExternalUrl = async (url: string): Promise<void> => {
console.log('[openExternalUrl] falling back to window.open');
window.open(url, '_blank');
};
/**
* YouTube stream info returned by yt-dlp
*/
export interface YouTubeStreamInfo {
/** Direct video stream URL */
video_url: string;
/** Title of the video */
title: string;
}
/**
* Get direct YouTube stream URL using yt-dlp
* Requires yt-dlp to be installed on the system
* @param url The YouTube video URL
* @returns Stream info with direct URL and title
* @throws If yt-dlp is not installed or fails
*/
export const getYouTubeStream = async (url: string): Promise<YouTubeStreamInfo> => {
if (typeof window !== 'undefined' && (window as any).__TAURI__) {
const { invoke } = await import('@tauri-apps/api/core');
return invoke<YouTubeStreamInfo>('get_youtube_stream', { url });
}
throw new Error('YouTube streaming requires Tauri desktop app with yt-dlp installed');
};
/**
* Check if yt-dlp is available for YouTube streaming
* @returns True if yt-dlp streaming is available
*/
export const isYouTubeStreamingAvailable = (): boolean => {
return typeof window !== 'undefined' && !!(window as any).__TAURI__;
};
/**
* Tauri-specific utilities for desktop and mobile platforms
*/