-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
127 lines (109 loc) · 3.06 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
export const version: number;
export const validOptions: string[];
export type ResultType = 'youtube#video' | 'youtube#channel' | 'youtube#playlist';
export interface SearchOptions {
part?: string;
forContentOwner?: boolean;
forDeveloper?: boolean;
forMine?: boolean;
relatedToVideoId?: string;
channelId?: string;
channelType?: 'any' | 'show';
eventType?: 'completed' | 'live' | 'upcoming';
fields?: string;
location?: string;
locationRadius?: string;
maxResults?: number;
onBehalfOfContentOwner?: string;
order?:
| 'date'
| 'rating'
| 'relevance'
| 'title'
| 'videoCount'
| 'viewCount';
pageToken?: string;
publishedAfter?: string;
publishedBefore?: string;
q?: string;
regionCode?: string;
relevanceLanguage?: string;
safeSearch?: 'moderate' | 'none' | 'strict';
topicId?: string;
type?: 'channel' | 'playlist' | 'video';
videoCaption?: 'any' | 'closedCaption' | 'none';
videoCategoryId?: string;
videoDefinition?: 'any' | 'high' | 'standard';
videoDimension?: '2d' | '3d' | 'any';
videoDuration?: 'any' | 'long' | 'medium' | 'short';
videoEmbeddable?: 'any' | 'true';
videoLicense?: 'any' | 'creativeCommon' | 'youtube';
videoSyndicated?: 'any' | 'true';
videoType?: 'any' | 'episode' | 'movie';
}
export interface KeyData {
key: string;
revealKey?: string;
}
export interface VideoEntry extends Omit<ResultSnippet, 'publishedAt'> {
kind: ResultType;
id: string;
url: string;
publishedAt: Date;
}
export interface Thumbnail {
url: string;
width: number;
height: number;
}
export interface Thumbnails {
[key: string]: Thumbnail;
}
export interface ResultID {
kind: ResultType;
videoId?: string;
channelId?: string;
playlistId?: string;
}
export interface ResultSnippet {
publishedAt: string;
channelId: string;
title: string;
description: string;
thumbnails: Thumbnails;
channelTitle: string;
liveBroadcastContent: string;
}
export interface SearchResult {
kind: 'youtube#searchResult';
etag: string;
id: ResultID;
snippet: ResultSnippet;
}
export class YTSearch {
public options?: SearchOptions;
public timestamp: number;
public query: string;
public totalResults?: number | null;
public pages?: number | null;
public nextPageToken?: string;
public prevPageToken?: string;
public currentPage?: YTSearchPage;
public constructor(query: string);
public search(options?: SearchOptions, apiKey?: KeyData): Promise<this>;
public nextPage(newOptions?: SearchOptions): Promise<null | this>;
public prevPage(newOptions?: SearchOptions): Promise<null | this>;
}
export class YTSearcher {
public defaultoptions?: SearchOptions;
public first?: VideoEntry;
public constructor(apiKey: string | KeyData, defaultoptions?: SearchOptions);
public set key(newKey: string);
public get key(): undefined | string;
public search(query: string, options?: SearchOptions): YTSearch;
}
export class YTSearchPage extends Array<VideoEntry> {
public constructor(items: SearchResult[]);
public first(): VideoEntry | null;
public last(): VideoEntry | null;
}