-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.d.ts
99 lines (84 loc) · 1.99 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
export interface SearchTypes {
ANY: "CAA%3D";
CHANNEL: "EgIQAg%3D%3D";
LIVE: "EgJAAQ%3D%3D";
MOVIE: "EgIQBA%3D%3D";
PLAYLIST: "EgIQAw%3D%3D";
VIDEO: "EgIQAQ%3D%3D";
}
export interface Thumbnail {
url: string;
width: number;
height: number;
}
export interface GeneralData {
id: string;
link: string;
thumbnail: string;
title: string;
}
export interface ShareableGeneralData extends GeneralData {
shareLink: string;
}
export interface VideoPreview extends ShareableGeneralData {
duration: number;
duration_raw: string;
views: number;
}
export interface ChannelPreview {
name: string;
link: string;
verified: boolean;
}
export interface Video extends ShareableGeneralData {
description: string;
duration: number;
duration_raw: string;
uploaded: string;
views: number;
channel: ChannelPreview;
}
export interface Playlist extends GeneralData {
preview: VideoPreview[];
duration: number;
duration_raw: string;
}
export interface Stream extends ShareableGeneralData {
watching: number;
channel: ChannelPreview;
}
export interface Channel {
channelId: string;
description: string;
link: string;
thumbnails: Thumbnail[];
subscribed: boolean;
uploadedVideos: number;
verified: boolean;
}
export interface Results {
channels: Channel[];
playlists: Playlist[];
streams: Stream[];
videos: Video[];
}
export interface SearchOptions {
searchType?: keyof SearchTypes;
language?: string;
}
declare class Scraper {
private _lang: string;
public constructor(language?: string);
private _extractData(
json: Record<string, unknown>
): Record<string, unknown>[];
private _fetch(
search_query: string,
searchType?: keyof SearchTypes,
requestedLang?: string
): Promise<string>;
private _getSearchData(webPage: string): Record<string, unknown>;
private _parseData(data: Record<string, unknown>[]): Results;
public search(query: string, options?: SearchOptions): Promise<Results>;
public setLang(language?: string): void;
}