diff --git a/package-lock.json b/package-lock.json index c0d2e71..1a2f934 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" diff --git a/package.json b/package.json index ad6099e..01424a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "piped-api", - "version": "1.0.5", + "version": "1.1.0", "description": "", "main": "dist/index.js", "type": "module", diff --git a/src/index.ts b/src/index.ts index d1f72f6..0267f1e 100644 --- a/src/index.ts +++ b/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} - A Promise that resolves to the search results. + */ + async search(query: string, filter: string = "all"): Promise { + return await this._get(`/search?q=${query}&filter=${filter}`); + } } diff --git a/src/responses.interface.ts b/src/responses.interface.ts index 3309d03..b10820f 100644 --- a/src/responses.interface.ts +++ b/src/responses.interface.ts @@ -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; +}