mirror of
https://github.com/artegoser/piped-api.git
synced 2024-11-24 20:06:22 +03:00
feat: search
This commit is contained in:
parent
d018ea89fc
commit
c977203bfd
4 changed files with 24 additions and 3 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "piped-api",
|
||||
"version": "1.0.5",
|
||||
"version": "1.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "piped-api",
|
||||
"version": "1.0.5",
|
||||
"version": "1.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"got": "^13.0.0"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "piped-api",
|
||||
"version": "1.0.5",
|
||||
"version": "1.1.0",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
|
|
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