chore: update Angular cache and TypeScript build info files

This commit is contained in:
2025-09-22 09:34:22 -04:00
parent 08fd0682a4
commit 4eb339eb22
34 changed files with 1511 additions and 154 deletions
@@ -0,0 +1,40 @@
export type ProviderId = 'yt' | 'dm' | 'tw' | 'pt' | 'od' | 'ru';
export interface ProviderSpec {
id: ProviderId;
displayName: string;
shortLabel: string; // YT, DM, ...
icon: string; // lucide or custom svg name
colorClass: string; // tailwind text-red-500, etc.
supports: { search: boolean; shorts: boolean; live: boolean; playlists: boolean };
buildSearchUrl: (q: string, opts?: { page?: number; limit?: number; providers?: ProviderId[] | 'all' }) => string; // front-only fallback
}
export const PROVIDERS: ProviderSpec[] = [
{ id: 'yt', displayName: 'YouTube', shortLabel: 'YT', icon: 'youtube', colorClass: 'text-red-500',
supports: { search: true, shorts: true, live: true, playlists: true },
buildSearchUrl: (q, opts) => `/api/search?q=${encodeURIComponent(q)}&providers=${encodeURIComponent((opts?.providers && opts.providers !== 'all') ? opts.providers.join(',') : 'yt,dm,tw,pt,od,ru')}`
},
{ id: 'dm', displayName: 'Dailymotion', shortLabel: 'DM', icon: 'dailymotion', colorClass: 'text-blue-500',
supports: { search: true, shorts: false, live: false, playlists: false },
buildSearchUrl: (q, opts) => `/api/search?q=${encodeURIComponent(q)}&providers=${encodeURIComponent((opts?.providers && opts.providers !== 'all') ? opts.providers.join(',') : 'yt,dm,tw,pt,od,ru')}`
},
{ id: 'tw', displayName: 'Twitch', shortLabel: 'TW', icon: 'twitch', colorClass: 'text-purple-500',
supports: { search: true, shorts: false, live: true, playlists: false },
buildSearchUrl: (q, opts) => `/api/search?q=${encodeURIComponent(q)}&providers=${encodeURIComponent((opts?.providers && opts.providers !== 'all') ? opts.providers.join(',') : 'yt,dm,tw,pt,od,ru')}`
},
{ id: 'pt', displayName: 'PeerTube', shortLabel: 'PT', icon: 'peertube', colorClass: 'text-green-500',
supports: { search: true, shorts: false, live: false, playlists: true },
buildSearchUrl: (q, opts) => `/api/search?q=${encodeURIComponent(q)}&providers=${encodeURIComponent((opts?.providers && opts.providers !== 'all') ? opts.providers.join(',') : 'yt,dm,tw,pt,od,ru')}`
},
{ id: 'od', displayName: 'Odysee', shortLabel: 'OD', icon: 'odysee', colorClass: 'text-yellow-500',
supports: { search: true, shorts: false, live: false, playlists: false },
buildSearchUrl: (q, opts) => `/api/search?q=${encodeURIComponent(q)}&providers=${encodeURIComponent((opts?.providers && opts.providers !== 'all') ? opts.providers.join(',') : 'yt,dm,tw,pt,od,ru')}`
},
{ id: 'ru', displayName: 'Rumble', shortLabel: 'RU', icon: 'rumble', colorClass: 'text-orange-500',
supports: { search: true, shorts: false, live: false, playlists: false },
buildSearchUrl: (q, opts) => `/api/search?q=${encodeURIComponent(q)}&providers=${encodeURIComponent((opts?.providers && opts.providers !== 'all') ? opts.providers.join(',') : 'yt,dm,tw,pt,od,ru')}`
},
];
export const PROVIDER_MAP = new Map(PROVIDERS.map(p => [p.id, p]));
+49
View File
@@ -0,0 +1,49 @@
import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject, combineLatest, distinctUntilChanged, debounceTime, map, switchMap } from 'rxjs';
import type { ProviderId } from '../core/providers/provider-registry';
export interface SuggestionItem {
title: string;
id: string;
duration?: number;
isShort?: boolean;
thumbnail?: string;
uploaderName?: string;
url?: string;
type?: string; // 'video' | 'channel' | ...
}
export interface SearchResponse {
q: string;
providers: ProviderId[];
groups: Record<ProviderId, SuggestionItem[]>;
}
@Injectable({ providedIn: 'root' })
export class SearchService {
private http = inject(HttpClient);
readonly q$ = new BehaviorSubject<string>('');
readonly providers$ = new BehaviorSubject<ProviderId[] | 'all'>('all');
readonly params$ = combineLatest([this.q$, this.providers$]).pipe(
debounceTime(120),
distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b))
);
readonly request$ = this.params$.pipe(
switchMap(([q, prov]) => {
const providersParam = (prov === 'all')
? 'yt,dm,tw,pt,od,ru'
: (Array.isArray(prov) && prov.length > 0 ? prov.join(',') : '');
return this.http.get<SearchResponse>('/api/search', {
params: { q, providers: providersParam }
});
})
);
// Convenience setter helpers
setQuery(q: string) { this.q$.next(q || ''); }
setProviders(list: ProviderId[] | 'all') { this.providers$.next(list && (Array.isArray(list) ? list : 'all')); }
}