UNPKG

@sushibtw/youtubei

Version:

Simple package to get information from youtube such as videos, playlists, channels, video information & comments, related videos, up next video, and more!

46 lines (45 loc) 1.8 kB
import { HTTP } from "../common"; import { Playlist, Video, SearchResult, LiveVideo } from "."; import { SearchResultType } from "./SearchResult"; export declare namespace Client { type SearchType = "video" | "channel" | "playlist" | "all"; type SearchOptions = { /** Search type, can be `"video"`, `"channel"`, `"playlist"`, or `"all"` */ type: SearchType; }; type ClientOptions = { cookie: string; /** 2-chars language code for localization */ hl: string; /** 2-chars country code */ gl: string; /** Local address for sending the request */ localAddress?: string; }; } /** Youtube Client */ export default class Client { /** @hidden */ http: HTTP; /** @hidden */ options: Client.ClientOptions; constructor(options?: Partial<Client.ClientOptions>); /** * Searches for videos / playlists / channels * * @param query The search query * @param searchOptions Search options * */ search<T extends Client.SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResult<T>>; /** * Search for videos / playlists / channels and returns the first result * * @return Can be {@link VideoCompact} | {@link PlaylistCompact} | {@link Channel} | `undefined` */ findOne<T extends Client.SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResultType<T> | undefined>; /** Get playlist information and its videos by playlist id or URL */ getPlaylist(playlistIdOrUrl: string): Promise<Playlist | undefined>; /** Get video information by video id or URL */ getVideo<T extends Video | LiveVideo | undefined>(videoIdOrUrl: string): Promise<T>; }