invidious: move searching to backend

This commit is contained in:
2025-02-22 01:09:33 -08:00
parent cfe48e28f8
commit 880057b0fc
6 changed files with 265 additions and 38 deletions

View File

@@ -33,6 +33,19 @@ export interface MetadataUpdateEvent {
};
}
export interface SearchResult {
type: string;
title: string;
author: string;
mediaUrl: string;
thumbnailUrl: string;
}
export interface SearchResponse {
success: boolean;
results: SearchResult[];
}
export const API = {
async getPlaylist(): Promise<PlaylistItem[]> {
const response = await fetch('/api/playlist');
@@ -90,6 +103,11 @@ export const API = {
});
},
async search(query: string): Promise<SearchResponse> {
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
return response.json();
},
subscribeToEvents(onMessage: (event: any) => void): WebSocket {
const ws = new WebSocket(`ws://${window.location.host}/api/events`);
ws.onmessage = (event) => {