YT Fixes
This commit is contained in:
@@ -66,11 +66,28 @@ export interface YouTubeStreamInfo {
|
||||
* @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__) {
|
||||
if (typeof window === 'undefined') {
|
||||
throw new Error('YouTube streaming requires desktop app with yt-dlp installed');
|
||||
}
|
||||
|
||||
// Check for Electron
|
||||
const electron = (window as any).electron;
|
||||
if (electron?.youtube?.getStream) {
|
||||
const result = await electron.youtube.getStream(url);
|
||||
// Electron returns { success: true, data: { video_url, title } } or { success: false, error }
|
||||
if (result.success === false) {
|
||||
throw new Error(result.error || 'Failed to get YouTube stream');
|
||||
}
|
||||
return result.data;
|
||||
}
|
||||
|
||||
// Check for Tauri
|
||||
if ((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');
|
||||
|
||||
throw new Error('YouTube streaming requires desktop app with yt-dlp installed');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -78,7 +95,18 @@ export const getYouTubeStream = async (url: string): Promise<YouTubeStreamInfo>
|
||||
* @returns True if yt-dlp streaming is available
|
||||
*/
|
||||
export const isYouTubeStreamingAvailable = (): boolean => {
|
||||
return typeof window !== 'undefined' && !!(window as any).__TAURI__;
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for Electron
|
||||
const electron = (window as any).electron;
|
||||
if (electron?.youtube?.getStream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for Tauri
|
||||
return !!(window as any).__TAURI__;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user