mirror of
https://github.com/artegoser/piped-api.git
synced 2025-02-23 20:51:27 +03:00
feat: search
This commit is contained in:
parent
d018ea89fc
commit
c977203bfd
4 changed files with 24 additions and 3 deletions
12
src/index.ts
12
src/index.ts
|
@ -5,6 +5,7 @@ import {
|
|||
NextPageChannel,
|
||||
NextPagePlaylist,
|
||||
Playlist,
|
||||
Search,
|
||||
Sponsors,
|
||||
Streams,
|
||||
Video,
|
||||
|
@ -137,4 +138,15 @@ export class PipedAPI {
|
|||
`/sponsors/${id}?category=${JSON.stringify(category)}`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches videos for a given query with an optional filter.
|
||||
*
|
||||
* @param {string} query - The query to search for.
|
||||
* @param {string} [filter="all"] - The optional filter to apply.
|
||||
* @returns {Promise<Search>} - A Promise that resolves to the search results.
|
||||
*/
|
||||
async search(query: string, filter: string = "all"): Promise<Search> {
|
||||
return await this._get(`/search?q=${query}&filter=${filter}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ export interface Video {
|
|||
isShort: boolean;
|
||||
uploaded: number;
|
||||
shortDescription: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface Channel {
|
||||
|
@ -104,6 +105,7 @@ export interface Channel {
|
|||
relatedStreams: Video[];
|
||||
subscriberCount: number;
|
||||
verified: boolean;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface NextPageChannel {
|
||||
|
@ -141,3 +143,10 @@ export interface Segments {
|
|||
segment: string;
|
||||
videoDuration: number;
|
||||
}
|
||||
|
||||
export interface Search {
|
||||
nextpage: string;
|
||||
items: (Video | Channel)[];
|
||||
corrected: boolean;
|
||||
suggestion: string | null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue