youtubei 0.0.1-rc.8 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +50 -53
- package/dist/cjs/classes/Base/Base.js +10 -0
- package/dist/cjs/classes/Base/index.js +13 -0
- package/dist/cjs/classes/BaseChannel/BaseChannel.js +31 -0
- package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +24 -0
- package/dist/cjs/classes/BaseChannel/ChannelPlaylists.js +57 -0
- package/dist/cjs/classes/BaseChannel/ChannelVideos.js +57 -0
- package/dist/cjs/classes/BaseChannel/index.js +16 -0
- package/dist/cjs/classes/BaseVideo/BaseVideo.js +34 -0
- package/dist/cjs/classes/BaseVideo/BaseVideoParser.js +82 -0
- package/dist/cjs/classes/BaseVideo/VideoRelated.js +39 -0
- package/dist/cjs/classes/BaseVideo/index.js +15 -0
- package/dist/cjs/classes/Channel/Channel.js +24 -0
- package/dist/cjs/classes/Channel/ChannelParser.js +55 -0
- package/dist/cjs/classes/Channel/index.js +14 -0
- package/dist/cjs/classes/Chat/Chat.js +23 -0
- package/dist/cjs/classes/Chat/ChatParser.js +21 -0
- package/dist/cjs/classes/Chat/index.js +14 -0
- package/dist/cjs/classes/Client/Client.js +101 -0
- package/dist/cjs/classes/Client/HTTP.js +59 -0
- package/dist/cjs/classes/Client/index.js +13 -0
- package/dist/cjs/classes/Comment/Comment.js +29 -0
- package/dist/cjs/classes/Comment/CommentParser.js +43 -0
- package/dist/cjs/classes/Comment/CommentReplies.js +36 -0
- package/dist/cjs/classes/Comment/index.js +15 -0
- package/dist/cjs/classes/Continuable/Continuable.js +43 -0
- package/dist/cjs/classes/Continuable/index.js +13 -0
- package/dist/cjs/classes/LiveVideo/LiveVideo.js +84 -0
- package/dist/cjs/classes/LiveVideo/LiveVideoParser.js +29 -0
- package/dist/cjs/classes/LiveVideo/index.js +14 -0
- package/dist/cjs/classes/MixPlaylist/MixPlaylist.js +25 -0
- package/dist/cjs/classes/MixPlaylist/MixPlaylistParser.js +27 -0
- package/dist/cjs/classes/MixPlaylist/index.js +14 -0
- package/dist/cjs/classes/Playlist/Playlist.js +25 -0
- package/dist/cjs/classes/Playlist/PlaylistParser.js +83 -0
- package/dist/cjs/classes/Playlist/PlaylistVideos.js +50 -0
- package/dist/cjs/classes/Playlist/index.js +15 -0
- package/dist/cjs/classes/PlaylistCompact/PlaylistCompact.js +45 -0
- package/dist/cjs/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
- package/dist/cjs/classes/PlaylistCompact/index.js +14 -0
- package/dist/cjs/classes/Reply/Reply.js +23 -0
- package/dist/cjs/classes/Reply/ReplyParser.js +26 -0
- package/dist/cjs/classes/Reply/index.js +14 -0
- package/dist/cjs/classes/SearchResult/SearchResult.js +85 -0
- package/dist/cjs/classes/SearchResult/SearchResultParser.js +40 -0
- package/dist/cjs/classes/SearchResult/index.js +14 -0
- package/dist/cjs/classes/SearchResult/proto/SearchProto.js +2 -0
- package/dist/cjs/classes/SearchResult/proto/index.js +57 -0
- package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -50
- package/dist/cjs/classes/Thumbnails/index.js +13 -0
- package/dist/cjs/classes/Video/Video.js +26 -0
- package/dist/cjs/classes/Video/VideoComments.js +53 -0
- package/dist/cjs/classes/Video/VideoParser.js +29 -0
- package/dist/cjs/classes/Video/index.js +15 -0
- package/dist/cjs/classes/VideoCompact/VideoCompact.js +49 -0
- package/dist/cjs/classes/VideoCompact/VideoCompactParser.js +36 -0
- package/dist/cjs/classes/VideoCompact/index.js +14 -0
- package/dist/cjs/classes/index.js +29 -0
- package/dist/{common → cjs/common}/decorators.js +14 -15
- package/dist/cjs/common/helper.js +45 -0
- package/dist/{common → cjs/common}/index.js +16 -23
- package/dist/{common → cjs/common}/mixins.js +14 -12
- package/dist/{common → cjs/common}/types.js +2 -2
- package/dist/{constants.js → cjs/constants.js} +10 -10
- package/dist/{index.js → cjs/index.js} +13 -13
- package/dist/esm/classes/Base/Base.js +8 -0
- package/dist/esm/classes/Base/index.js +1 -0
- package/dist/esm/classes/BaseChannel/BaseChannel.js +48 -0
- package/dist/esm/classes/BaseChannel/BaseChannelParser.js +24 -0
- package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +109 -0
- package/dist/esm/classes/BaseChannel/ChannelVideos.js +109 -0
- package/dist/esm/classes/BaseChannel/index.js +4 -0
- package/dist/esm/classes/BaseVideo/BaseVideo.js +51 -0
- package/dist/esm/classes/BaseVideo/BaseVideoParser.js +93 -0
- package/dist/esm/classes/BaseVideo/VideoRelated.js +87 -0
- package/dist/esm/classes/BaseVideo/index.js +3 -0
- package/dist/esm/classes/Channel/Channel.js +37 -0
- package/dist/esm/classes/Channel/ChannelParser.js +77 -0
- package/dist/esm/classes/Channel/index.js +2 -0
- package/dist/esm/classes/Chat/Chat.js +36 -0
- package/dist/esm/classes/Chat/ChatParser.js +21 -0
- package/dist/esm/classes/Chat/index.js +2 -0
- package/dist/esm/classes/Client/Client.js +176 -0
- package/dist/esm/classes/Client/HTTP.js +112 -0
- package/dist/esm/classes/Client/index.js +1 -0
- package/dist/esm/classes/Comment/Comment.js +46 -0
- package/dist/esm/classes/Comment/CommentParser.js +45 -0
- package/dist/esm/classes/Comment/CommentReplies.js +84 -0
- package/dist/esm/classes/Comment/index.js +3 -0
- package/dist/esm/classes/Continuable/Continuable.js +125 -0
- package/dist/esm/classes/Continuable/index.js +1 -0
- package/dist/esm/classes/LiveVideo/LiveVideo.js +160 -0
- package/dist/esm/classes/LiveVideo/LiveVideoParser.js +29 -0
- package/dist/esm/classes/LiveVideo/index.js +2 -0
- package/dist/esm/classes/MixPlaylist/MixPlaylist.js +38 -0
- package/dist/esm/classes/MixPlaylist/MixPlaylistParser.js +49 -0
- package/dist/esm/classes/MixPlaylist/index.js +2 -0
- package/dist/esm/classes/Playlist/Playlist.js +38 -0
- package/dist/esm/classes/Playlist/PlaylistParser.js +105 -0
- package/dist/esm/classes/Playlist/PlaylistVideos.js +98 -0
- package/dist/esm/classes/Playlist/index.js +3 -0
- package/dist/esm/classes/PlaylistCompact/PlaylistCompact.js +90 -0
- package/dist/esm/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
- package/dist/esm/classes/PlaylistCompact/index.js +2 -0
- package/dist/esm/classes/Reply/Reply.js +36 -0
- package/dist/esm/classes/Reply/ReplyParser.js +26 -0
- package/dist/esm/classes/Reply/index.js +2 -0
- package/dist/esm/classes/SearchResult/SearchResult.js +161 -0
- package/dist/esm/classes/SearchResult/SearchResultParser.js +62 -0
- package/dist/esm/classes/SearchResult/index.js +2 -0
- package/dist/esm/classes/SearchResult/proto/SearchProto.js +1 -0
- package/dist/esm/classes/SearchResult/proto/index.js +39 -0
- package/dist/esm/classes/Thumbnails/Thumbnails.js +109 -0
- package/dist/esm/classes/Thumbnails/index.js +1 -0
- package/dist/esm/classes/Video/Video.js +39 -0
- package/dist/esm/classes/Video/VideoComments.js +101 -0
- package/dist/esm/classes/Video/VideoParser.js +31 -0
- package/dist/esm/classes/Video/index.js +3 -0
- package/dist/esm/classes/VideoCompact/VideoCompact.js +98 -0
- package/dist/esm/classes/VideoCompact/VideoCompactParser.js +36 -0
- package/dist/esm/classes/VideoCompact/index.js +2 -0
- package/dist/esm/classes/index.js +17 -0
- package/dist/esm/common/decorators.js +30 -0
- package/dist/esm/common/helper.js +61 -0
- package/dist/esm/common/index.js +4 -0
- package/dist/esm/common/mixins.js +10 -0
- package/dist/esm/common/types.js +1 -0
- package/dist/esm/constants.js +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/typings/classes/Base/Base.d.ts +11 -0
- package/dist/typings/classes/Base/index.d.ts +1 -0
- package/dist/typings/classes/BaseChannel/BaseChannel.d.ts +43 -0
- package/dist/typings/classes/BaseChannel/BaseChannelParser.d.ts +7 -0
- package/dist/typings/classes/BaseChannel/ChannelPlaylists.d.ts +30 -0
- package/dist/typings/classes/BaseChannel/ChannelVideos.d.ts +30 -0
- package/dist/typings/classes/BaseChannel/index.d.ts +4 -0
- package/dist/typings/classes/BaseVideo/BaseVideo.d.ts +59 -0
- package/dist/typings/classes/BaseVideo/BaseVideoParser.d.ts +14 -0
- package/dist/typings/classes/BaseVideo/VideoRelated.d.ts +21 -0
- package/dist/typings/classes/BaseVideo/index.d.ts +3 -0
- package/dist/typings/classes/Channel/Channel.d.ts +33 -0
- package/dist/typings/classes/Channel/ChannelParser.d.ts +6 -0
- package/dist/typings/classes/Channel/index.d.ts +2 -0
- package/dist/typings/classes/Chat/Chat.d.ts +33 -0
- package/dist/typings/classes/Chat/ChatParser.d.ts +5 -0
- package/dist/typings/classes/Chat/index.d.ts +2 -0
- package/dist/typings/classes/Client/Client.d.ts +41 -0
- package/dist/typings/classes/Client/HTTP.d.ts +21 -0
- package/dist/typings/classes/Client/index.d.ts +1 -0
- package/dist/typings/classes/Comment/Comment.d.ts +51 -0
- package/dist/typings/classes/Comment/CommentParser.d.ts +8 -0
- package/dist/typings/classes/Comment/CommentReplies.d.ts +17 -0
- package/dist/typings/classes/Comment/index.d.ts +3 -0
- package/dist/typings/classes/Continuable/Continuable.d.ts +24 -0
- package/dist/typings/classes/Continuable/index.d.ts +1 -0
- package/dist/typings/classes/LiveVideo/LiveVideo.d.ts +46 -0
- package/dist/typings/classes/LiveVideo/LiveVideoParser.d.ts +10 -0
- package/dist/typings/classes/LiveVideo/index.d.ts +2 -0
- package/dist/typings/classes/MixPlaylist/MixPlaylist.d.ts +29 -0
- package/dist/typings/classes/MixPlaylist/MixPlaylistParser.d.ts +6 -0
- package/dist/typings/classes/MixPlaylist/index.d.ts +2 -0
- package/dist/typings/classes/Playlist/Playlist.d.ts +39 -0
- package/dist/typings/classes/Playlist/PlaylistParser.d.ts +16 -0
- package/dist/typings/classes/Playlist/PlaylistVideos.d.ts +31 -0
- package/dist/typings/classes/Playlist/index.d.ts +3 -0
- package/dist/typings/classes/PlaylistCompact/PlaylistCompact.d.ts +43 -0
- package/dist/typings/classes/PlaylistCompact/PlaylistCompactParser.d.ts +5 -0
- package/dist/typings/classes/PlaylistCompact/index.d.ts +2 -0
- package/dist/typings/classes/Reply/Reply.d.ts +43 -0
- package/dist/typings/classes/Reply/ReplyParser.d.ts +5 -0
- package/dist/typings/classes/Reply/index.d.ts +2 -0
- package/dist/typings/classes/SearchResult/SearchResult.d.ts +53 -0
- package/dist/typings/classes/SearchResult/SearchResultParser.d.ts +13 -0
- package/dist/typings/classes/SearchResult/index.d.ts +2 -0
- package/dist/typings/classes/SearchResult/proto/SearchProto.d.ts +13 -0
- package/dist/typings/classes/SearchResult/proto/index.d.ts +24 -0
- package/dist/typings/classes/Thumbnails/Thumbnails.d.ts +41 -0
- package/dist/typings/classes/Thumbnails/index.d.ts +1 -0
- package/dist/typings/classes/Video/Video.d.ts +24 -0
- package/dist/typings/classes/Video/VideoComments.d.ts +34 -0
- package/dist/typings/classes/Video/VideoParser.d.ts +8 -0
- package/dist/typings/classes/Video/index.d.ts +3 -0
- package/dist/typings/classes/VideoCompact/VideoCompact.d.ts +57 -0
- package/dist/typings/classes/VideoCompact/VideoCompactParser.d.ts +5 -0
- package/dist/typings/classes/VideoCompact/index.d.ts +2 -0
- package/dist/typings/classes/index.d.ts +17 -0
- package/dist/{common → typings/common}/decorators.d.ts +5 -7
- package/dist/typings/common/helper.d.ts +5 -0
- package/dist/typings/common/index.d.ts +4 -0
- package/dist/typings/common/mixins.d.ts +1 -0
- package/dist/{common → typings/common}/types.d.ts +1 -2
- package/dist/{constants.d.ts → typings/constants.d.ts} +7 -7
- package/dist/{index.d.ts → typings/index.d.ts} +1 -1
- package/package.json +68 -53
- package/CHANGELOG.md +0 -6
- package/dist/classes/Base.d.ts +0 -8
- package/dist/classes/Base.js +0 -10
- package/dist/classes/Channel.d.ts +0 -63
- package/dist/classes/Channel.js +0 -115
- package/dist/classes/Chat.d.ts +0 -35
- package/dist/classes/Chat.js +0 -34
- package/dist/classes/Client.d.ts +0 -17
- package/dist/classes/Client.js +0 -59
- package/dist/classes/Comment.d.ts +0 -51
- package/dist/classes/Comment.js +0 -47
- package/dist/classes/LiveVideo.d.ts +0 -20
- package/dist/classes/LiveVideo.js +0 -59
- package/dist/classes/Playlist.d.ts +0 -66
- package/dist/classes/Playlist.js +0 -133
- package/dist/classes/PlaylistCompact.d.ts +0 -35
- package/dist/classes/PlaylistCompact.js +0 -47
- package/dist/classes/SearchResult.d.ts +0 -51
- package/dist/classes/SearchResult.js +0 -121
- package/dist/classes/Thumbnails.d.ts +0 -26
- package/dist/classes/Video.d.ts +0 -90
- package/dist/classes/Video.js +0 -153
- package/dist/classes/VideoCompact.d.ts +0 -46
- package/dist/classes/VideoCompact.js +0 -53
- package/dist/classes/index.d.ts +0 -12
- package/dist/classes/index.js +0 -30
- package/dist/common/helper.d.ts +0 -4
- package/dist/common/helper.js +0 -39
- package/dist/common/http.d.ts +0 -33
- package/dist/common/http.js +0 -105
- package/dist/common/index.d.ts +0 -5
- package/dist/common/mixins.d.ts +0 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequestInit } from "node-fetch";
|
|
2
|
+
import { ClientOptions } from "./Client";
|
|
3
|
+
declare type Response<T = any> = {
|
|
4
|
+
data: T;
|
|
5
|
+
};
|
|
6
|
+
declare type Options = {
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
params: Record<string, string>;
|
|
9
|
+
} & RequestInit;
|
|
10
|
+
export declare class HTTP {
|
|
11
|
+
private cookie;
|
|
12
|
+
private defaultHeaders;
|
|
13
|
+
private defaultFetchOptions;
|
|
14
|
+
private defaultClientOptions;
|
|
15
|
+
constructor(options: ClientOptions);
|
|
16
|
+
get(url: string, options?: Partial<Options>): Promise<Response>;
|
|
17
|
+
post(url: string, options?: Partial<Options>): Promise<Response>;
|
|
18
|
+
private request;
|
|
19
|
+
private parseCookie;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Client";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { BaseChannel } from "../BaseChannel";
|
|
4
|
+
import { Video } from "../Video";
|
|
5
|
+
import { CommentReplies } from "./CommentReplies";
|
|
6
|
+
/** @hidden */
|
|
7
|
+
interface CommentProperties extends BaseProperties {
|
|
8
|
+
id?: string;
|
|
9
|
+
video?: Video;
|
|
10
|
+
author?: BaseChannel;
|
|
11
|
+
content?: string;
|
|
12
|
+
publishDate?: string;
|
|
13
|
+
likeCount?: number;
|
|
14
|
+
isAuthorChannelOwner?: boolean;
|
|
15
|
+
isPinned?: boolean;
|
|
16
|
+
replyCount?: number;
|
|
17
|
+
replies?: CommentReplies;
|
|
18
|
+
}
|
|
19
|
+
/** Represents a Comment / Reply */
|
|
20
|
+
export declare class Comment extends Base implements CommentProperties {
|
|
21
|
+
id: string;
|
|
22
|
+
/** The video this comment belongs to */
|
|
23
|
+
video: Video;
|
|
24
|
+
/** The comment's author */
|
|
25
|
+
author: BaseChannel;
|
|
26
|
+
/** The content of this comment */
|
|
27
|
+
content: string;
|
|
28
|
+
/** The publish date of the comment */
|
|
29
|
+
publishDate: string;
|
|
30
|
+
/** How many likes does this comment have */
|
|
31
|
+
likeCount: number;
|
|
32
|
+
/** Whether the comment is posted by the video uploader / owner */
|
|
33
|
+
isAuthorChannelOwner: boolean;
|
|
34
|
+
/** Whether the comment is pinned */
|
|
35
|
+
isPinned: boolean;
|
|
36
|
+
/** Reply count of this comment */
|
|
37
|
+
replyCount: number;
|
|
38
|
+
/** Continuable of replies in this comment */
|
|
39
|
+
replies: CommentReplies;
|
|
40
|
+
/** @hidden */
|
|
41
|
+
constructor(attr: CommentProperties);
|
|
42
|
+
/**
|
|
43
|
+
* Load this instance with raw data from Youtube
|
|
44
|
+
*
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
load(data: YoutubeRawData): Comment;
|
|
48
|
+
/** URL to the video with this comment being highlighted (appears on top of the comment section) */
|
|
49
|
+
get url(): string;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Reply } from "../Reply";
|
|
3
|
+
import { Comment } from "./Comment";
|
|
4
|
+
export declare class CommentParser {
|
|
5
|
+
static loadComment(target: Comment, data: YoutubeRawData): Comment;
|
|
6
|
+
static parseContinuation(data: YoutubeRawData): string | undefined;
|
|
7
|
+
static parseReplies(data: YoutubeRawData, comment: Comment): Reply[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
|
|
2
|
+
import { Reply } from "../Reply";
|
|
3
|
+
import { Comment } from "./Comment";
|
|
4
|
+
declare type ConstructorParams = ContinuableConstructorParams & {
|
|
5
|
+
comment: Comment;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* {@link Continuable} of replies inside a {@link Comment}
|
|
9
|
+
*/
|
|
10
|
+
export declare class CommentReplies extends Continuable<Reply> {
|
|
11
|
+
/** The comment this replies belongs to */
|
|
12
|
+
comment: Comment;
|
|
13
|
+
/** @hidden */
|
|
14
|
+
constructor({ client, comment }: ConstructorParams);
|
|
15
|
+
protected fetch(): Promise<FetchResult<Reply>>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Base } from "../Base";
|
|
2
|
+
import { Client } from "../Client";
|
|
3
|
+
/** @hidden */
|
|
4
|
+
export declare type FetchResult<T> = {
|
|
5
|
+
items: T[];
|
|
6
|
+
continuation?: string;
|
|
7
|
+
};
|
|
8
|
+
/** @hidden */
|
|
9
|
+
export declare type ContinuableConstructorParams = {
|
|
10
|
+
client: Client;
|
|
11
|
+
strictContinuationCheck?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** Represents a continuable list of items `T` (like pagination) */
|
|
14
|
+
export declare abstract class Continuable<T> extends Base {
|
|
15
|
+
items: T[];
|
|
16
|
+
continuation?: string | null;
|
|
17
|
+
private strictContinuationCheck;
|
|
18
|
+
/** @hidden */
|
|
19
|
+
constructor({ client, strictContinuationCheck }: ContinuableConstructorParams);
|
|
20
|
+
/** Fetch next items using continuation token */
|
|
21
|
+
next(count?: number): Promise<T[]>;
|
|
22
|
+
protected abstract fetch(): Promise<FetchResult<T>>;
|
|
23
|
+
private get hasContinuation();
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Continuable";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { BaseVideo, BaseVideoProperties } from "../BaseVideo";
|
|
3
|
+
import { Chat } from "../Chat";
|
|
4
|
+
/** @hidden */
|
|
5
|
+
interface LiveVideoProperties extends BaseVideoProperties {
|
|
6
|
+
watchingCount?: number;
|
|
7
|
+
chatContinuation?: string;
|
|
8
|
+
}
|
|
9
|
+
interface LiveVideoEvents {
|
|
10
|
+
chat: (chat: Chat) => void;
|
|
11
|
+
}
|
|
12
|
+
declare interface LiveVideo {
|
|
13
|
+
on<T extends keyof LiveVideoEvents>(event: T, listener: LiveVideoEvents[T]): AsyncIterableIterator<any>;
|
|
14
|
+
emit<T extends keyof LiveVideoEvents>(event: T, ...args: Parameters<LiveVideoEvents[T]>): boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Represents a video that's currently live, usually returned from `client.getVideo()` */
|
|
17
|
+
declare class LiveVideo extends BaseVideo implements LiveVideoProperties {
|
|
18
|
+
/** Number of people who's watching the live stream right now */
|
|
19
|
+
watchingCount: number;
|
|
20
|
+
/** Current continuation token to load next chat */
|
|
21
|
+
chatContinuation: string;
|
|
22
|
+
private _delay;
|
|
23
|
+
private _chatRequestPoolingTimeout;
|
|
24
|
+
private _timeoutMs;
|
|
25
|
+
private _isChatPlaying;
|
|
26
|
+
private _chatQueue;
|
|
27
|
+
/** @hidden */
|
|
28
|
+
constructor(attr: LiveVideoProperties);
|
|
29
|
+
/**
|
|
30
|
+
* Load this instance with raw data from Youtube
|
|
31
|
+
*
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
load(data: YoutubeRawData): LiveVideo;
|
|
35
|
+
/**
|
|
36
|
+
* Start polling for get live chat request
|
|
37
|
+
*
|
|
38
|
+
* @param delay chat delay in millisecond
|
|
39
|
+
*/
|
|
40
|
+
playChat(delay?: number): void;
|
|
41
|
+
/** Stop request polling for live chat */
|
|
42
|
+
stopChat(): void;
|
|
43
|
+
/** Start request polling */
|
|
44
|
+
private pollChatContinuation;
|
|
45
|
+
}
|
|
46
|
+
export { LiveVideo };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { LiveVideo } from "./LiveVideo";
|
|
3
|
+
export declare class LiveVideoParser {
|
|
4
|
+
static loadLiveVideo(target: LiveVideo, data: YoutubeRawData): LiveVideo;
|
|
5
|
+
static parseChats(data: YoutubeRawData): YoutubeRawData[];
|
|
6
|
+
static parseContinuation(data: YoutubeRawData): {
|
|
7
|
+
continuation: string;
|
|
8
|
+
timeout: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { VideoCompact } from "../VideoCompact";
|
|
4
|
+
/** @hidden */
|
|
5
|
+
interface MixPlaylistProperties extends BaseProperties {
|
|
6
|
+
id?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
videoCount?: number;
|
|
9
|
+
videos?: VideoCompact[];
|
|
10
|
+
}
|
|
11
|
+
/** Represents a MixPlaylist, usually returned from `client.getPlaylist()` */
|
|
12
|
+
export declare class MixPlaylist extends Base implements MixPlaylistProperties {
|
|
13
|
+
id: string;
|
|
14
|
+
/** The title of this playlist */
|
|
15
|
+
title: string;
|
|
16
|
+
/** How many videos in this playlist */
|
|
17
|
+
videoCount: number;
|
|
18
|
+
/** How many viewers does this playlist have */
|
|
19
|
+
videos: VideoCompact[];
|
|
20
|
+
/** @hidden */
|
|
21
|
+
constructor(attr: MixPlaylistProperties);
|
|
22
|
+
/**
|
|
23
|
+
* Load this instance with raw data from Youtube
|
|
24
|
+
*
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
27
|
+
load(data: YoutubeRawData): MixPlaylist;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { BaseChannel, BaseChannelProperties } from "../BaseChannel";
|
|
4
|
+
import { PlaylistVideos } from "./PlaylistVideos";
|
|
5
|
+
/** @hidden */
|
|
6
|
+
interface PlaylistProperties extends BaseProperties {
|
|
7
|
+
id?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
videoCount?: number;
|
|
10
|
+
viewCount?: number;
|
|
11
|
+
lastUpdatedAt?: string;
|
|
12
|
+
channel?: BaseChannelProperties;
|
|
13
|
+
videos?: PlaylistVideos;
|
|
14
|
+
}
|
|
15
|
+
/** Represents a Playlist, usually returned from `client.getPlaylist()` */
|
|
16
|
+
export declare class Playlist extends Base implements PlaylistProperties {
|
|
17
|
+
id: string;
|
|
18
|
+
/** The title of this playlist */
|
|
19
|
+
title: string;
|
|
20
|
+
/** How many videos in this playlist */
|
|
21
|
+
videoCount: number;
|
|
22
|
+
/** How many viewers does this playlist have */
|
|
23
|
+
viewCount: number;
|
|
24
|
+
/** Last time this playlist is updated */
|
|
25
|
+
lastUpdatedAt: string;
|
|
26
|
+
/** The channel that made this playlist */
|
|
27
|
+
channel?: BaseChannel;
|
|
28
|
+
/** Continuable of videos in this playlist */
|
|
29
|
+
videos: PlaylistVideos;
|
|
30
|
+
/** @hidden */
|
|
31
|
+
constructor(attr: PlaylistProperties);
|
|
32
|
+
/**
|
|
33
|
+
* Load this instance with raw data from Youtube
|
|
34
|
+
*
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
37
|
+
load(data: YoutubeRawData): Playlist;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Client } from "../Client";
|
|
3
|
+
import { VideoCompact } from "../VideoCompact";
|
|
4
|
+
import { Playlist } from "./Playlist";
|
|
5
|
+
export declare class PlaylistParser {
|
|
6
|
+
static loadPlaylist(target: Playlist, data: YoutubeRawData): Playlist;
|
|
7
|
+
static parseVideoContinuation(data: YoutubeRawData): string | undefined;
|
|
8
|
+
static parseContinuationVideos(data: YoutubeRawData, client: Client): VideoCompact[];
|
|
9
|
+
/**
|
|
10
|
+
* Get compact videos
|
|
11
|
+
*
|
|
12
|
+
* @param playlistContents raw object from youtubei
|
|
13
|
+
*/
|
|
14
|
+
private static parseVideos;
|
|
15
|
+
private static parseSideBarInfo;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
|
|
2
|
+
import { VideoCompact } from "../VideoCompact";
|
|
3
|
+
import { Playlist } from "./Playlist";
|
|
4
|
+
declare type ConstructorParams = ContinuableConstructorParams & {
|
|
5
|
+
playlist?: Playlist;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* {@link Continuable} of videos inside a {@link Playlist}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* const playlist = await youtube.getPlaylist(PLAYLIST_ID);
|
|
13
|
+
* console.log(playlist.videos) // first 100 videos
|
|
14
|
+
*
|
|
15
|
+
* let newVideos = await playlist.videos.next();
|
|
16
|
+
* console.log(newVideos) // 100 loaded videos
|
|
17
|
+
* console.log(playlist.videos) // first 200 videos
|
|
18
|
+
*
|
|
19
|
+
* await playlist.videos.next(0); // load the rest of the videos in the playlist
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param count How many times to load the next videos. Set 0 to load all videos (might take a while on a large playlist!)
|
|
23
|
+
*/
|
|
24
|
+
export declare class PlaylistVideos extends Continuable<VideoCompact> {
|
|
25
|
+
/** The playlist this videos belongs to */
|
|
26
|
+
playlist?: Playlist;
|
|
27
|
+
/** @hidden */
|
|
28
|
+
constructor({ client, playlist }: ConstructorParams);
|
|
29
|
+
protected fetch(): Promise<FetchResult<VideoCompact>>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { BaseChannel } from "../BaseChannel";
|
|
4
|
+
import { Playlist } from "../Playlist/Playlist";
|
|
5
|
+
import { Thumbnails } from "../Thumbnails";
|
|
6
|
+
/** @hidden */
|
|
7
|
+
interface PlaylistCompactProperties extends BaseProperties {
|
|
8
|
+
id?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
thumbnails?: Thumbnails;
|
|
11
|
+
channel?: BaseChannel;
|
|
12
|
+
videoCount?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Represents a Compact Playlist (e.g. from search result, related of a video) */
|
|
15
|
+
export declare class PlaylistCompact extends Base implements PlaylistCompactProperties {
|
|
16
|
+
id: string;
|
|
17
|
+
/** The playlist's title */
|
|
18
|
+
title: string;
|
|
19
|
+
/** Thumbnails of the playlist with different sizes */
|
|
20
|
+
thumbnails: Thumbnails;
|
|
21
|
+
/** The channel that made this playlist */
|
|
22
|
+
channel?: BaseChannel;
|
|
23
|
+
/** How many videos in this playlist */
|
|
24
|
+
videoCount: number;
|
|
25
|
+
/** @hidden */
|
|
26
|
+
constructor(attr: PlaylistCompactProperties);
|
|
27
|
+
/**
|
|
28
|
+
* Load this instance with raw data from Youtube
|
|
29
|
+
*
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
load(data: YoutubeRawData): PlaylistCompact;
|
|
33
|
+
/**
|
|
34
|
+
* Get {@link Playlist} object based on current playlist id
|
|
35
|
+
*
|
|
36
|
+
* Equivalent to
|
|
37
|
+
* ```js
|
|
38
|
+
* client.getPlaylist(playlistCompact.id);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
getPlaylist(): Promise<Playlist>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { BaseChannel } from "../BaseChannel";
|
|
4
|
+
import { Comment } from "../Comment";
|
|
5
|
+
import { Video } from "../Video";
|
|
6
|
+
/** @hidden */
|
|
7
|
+
interface ReplyProperties extends BaseProperties {
|
|
8
|
+
id?: string;
|
|
9
|
+
comment?: Comment;
|
|
10
|
+
video?: Video;
|
|
11
|
+
author?: BaseChannel;
|
|
12
|
+
content?: string;
|
|
13
|
+
publishDate?: string;
|
|
14
|
+
likeCount?: number;
|
|
15
|
+
isAuthorChannelOwner?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Represents a Reply */
|
|
18
|
+
export declare class Reply extends Base implements ReplyProperties {
|
|
19
|
+
id: string;
|
|
20
|
+
/** The comment this reply belongs to */
|
|
21
|
+
comment: Comment;
|
|
22
|
+
/** The video this reply belongs to */
|
|
23
|
+
video: Video;
|
|
24
|
+
/** The comment's author */
|
|
25
|
+
author: BaseChannel;
|
|
26
|
+
/** The content of this comment */
|
|
27
|
+
content: string;
|
|
28
|
+
/** The publish date of the comment */
|
|
29
|
+
publishDate: string;
|
|
30
|
+
/** How many likes does this comment have */
|
|
31
|
+
likeCount: number;
|
|
32
|
+
/** Whether the comment is posted by the video uploader / owner */
|
|
33
|
+
isAuthorChannelOwner: boolean;
|
|
34
|
+
/** @hidden */
|
|
35
|
+
constructor(attr: ReplyProperties);
|
|
36
|
+
/**
|
|
37
|
+
* Load this instance with raw data from Youtube
|
|
38
|
+
*
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
load(data: YoutubeRawData): Reply;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BaseChannel } from "../BaseChannel";
|
|
2
|
+
import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
|
|
3
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
4
|
+
import { VideoCompact } from "../VideoCompact";
|
|
5
|
+
export declare type SearchOptions = {
|
|
6
|
+
type?: SearchType;
|
|
7
|
+
duration?: SearchDuration;
|
|
8
|
+
uploadDate?: SearchUploadDate;
|
|
9
|
+
sortBy?: SearchSort;
|
|
10
|
+
};
|
|
11
|
+
export declare type SearchUploadDate = "all" | "hour" | "today" | "week" | "month" | "year";
|
|
12
|
+
export declare type SearchType = "all" | "video" | "channel" | "playlist";
|
|
13
|
+
export declare type SearchDuration = "all" | "short" | "medium" | "long";
|
|
14
|
+
export declare type SearchSort = "relevance" | "rating" | "date" | "view";
|
|
15
|
+
export declare type SearchResultItem<T = "all"> = T extends "video" | VideoCompact ? VideoCompact : T extends "channel" | BaseChannel ? BaseChannel : T extends "playlist" | PlaylistCompact ? PlaylistCompact : VideoCompact | BaseChannel | PlaylistCompact;
|
|
16
|
+
/**
|
|
17
|
+
* Represents search result, usually returned from `client.search();`.
|
|
18
|
+
*
|
|
19
|
+
* {@link SearchResult} is a helper class to manage search result
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const result = await youtube.search("Keyword");
|
|
24
|
+
*
|
|
25
|
+
* console.log(result.items); // search result from first page
|
|
26
|
+
*
|
|
27
|
+
* let nextSearchResult = await result.next();
|
|
28
|
+
* console.log(nextSearchResult); // search result from second page
|
|
29
|
+
*
|
|
30
|
+
* nextSearchResult = await result.next();
|
|
31
|
+
* console.log(nextSearchResult); // search result from third page
|
|
32
|
+
*
|
|
33
|
+
* console.log(result.items); // search result from first, second, and third page.
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @noInheritDoc
|
|
37
|
+
*/
|
|
38
|
+
export declare class SearchResult<T extends SearchType | undefined = "all"> extends Continuable<SearchResultItem<T>> {
|
|
39
|
+
/** The estimated search result count */
|
|
40
|
+
estimatedResults: number;
|
|
41
|
+
/** @hidden */
|
|
42
|
+
constructor({ client }: ContinuableConstructorParams);
|
|
43
|
+
/**
|
|
44
|
+
* Initialize data from search
|
|
45
|
+
*
|
|
46
|
+
* @param query Search query
|
|
47
|
+
* @param options Search Options
|
|
48
|
+
*
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
search(query: string, options: SearchOptions): Promise<SearchResult<T>>;
|
|
52
|
+
protected fetch(): Promise<FetchResult<SearchResultItem<T>>>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Client } from "../Client";
|
|
3
|
+
import { SearchResultItem } from "./SearchResult";
|
|
4
|
+
declare type ParseReturnType = {
|
|
5
|
+
data: SearchResultItem[];
|
|
6
|
+
continuation: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare class SearchResultParser {
|
|
9
|
+
static parseInitialSearchResult(data: YoutubeRawData, client: Client): ParseReturnType;
|
|
10
|
+
static parseContinuationSearchResult(data: YoutubeRawData, client: Client): ParseReturnType;
|
|
11
|
+
private static parseSearchResult;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare type Options = {
|
|
2
|
+
uploadDate?: number;
|
|
3
|
+
type?: number;
|
|
4
|
+
duration?: number;
|
|
5
|
+
};
|
|
6
|
+
declare type SearchOptions = {
|
|
7
|
+
sortBy?: number;
|
|
8
|
+
options?: Options;
|
|
9
|
+
};
|
|
10
|
+
export declare type SearchProto = {
|
|
11
|
+
SearchOptions: SearchOptions;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SearchOptions } from "../SearchResult";
|
|
3
|
+
import { SearchProto as ProtoType } from "./SearchProto";
|
|
4
|
+
export declare const SearchProto: {
|
|
5
|
+
SearchOptions: {
|
|
6
|
+
encode: (obj: {
|
|
7
|
+
sortBy?: number | undefined;
|
|
8
|
+
options?: {
|
|
9
|
+
uploadDate?: number | undefined;
|
|
10
|
+
type?: number | undefined;
|
|
11
|
+
duration?: number | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}) => Buffer;
|
|
14
|
+
decode: (buf: Buffer) => {
|
|
15
|
+
sortBy?: number | undefined;
|
|
16
|
+
options?: {
|
|
17
|
+
uploadDate?: number | undefined;
|
|
18
|
+
type?: number | undefined;
|
|
19
|
+
duration?: number | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare const optionsToProto: (options: SearchOptions) => ProtoType["SearchOptions"];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface Thumbnail {
|
|
2
|
+
url: string;
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Represents Thumbnails, usually found inside Playlist / Channel / Video, etc.
|
|
8
|
+
*
|
|
9
|
+
* {@link Thumbnails} is an array of {@link Thumbnail}
|
|
10
|
+
*
|
|
11
|
+
* @noInheritDoc
|
|
12
|
+
*/
|
|
13
|
+
export declare class Thumbnails extends Array<Thumbnail> {
|
|
14
|
+
/** @hidden */
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Returns thumbnail with the lowest resolution, usually the first element of the Thumbnails array
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* const min = video.thumbnails.min;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
get min(): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Returns thumbnail with the highest resolution, usually the last element of the Thumbnails array
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```js
|
|
30
|
+
* const min = video.thumbnails.min;
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
get best(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Load this instance with raw data from Youtube
|
|
36
|
+
*
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
load(thumbnails: Thumbnail[]): Thumbnails;
|
|
40
|
+
private static parseThumbnailUrl;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Thumbnails";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { BaseVideo, BaseVideoProperties } from "../BaseVideo";
|
|
3
|
+
import { VideoComments } from "./VideoComments";
|
|
4
|
+
/** @hidden */
|
|
5
|
+
interface VideoProperties extends BaseVideoProperties {
|
|
6
|
+
duration?: number;
|
|
7
|
+
comments?: VideoComments;
|
|
8
|
+
}
|
|
9
|
+
/** Represents a Video, usually returned from `client.getVideo()` */
|
|
10
|
+
export declare class Video extends BaseVideo implements VideoProperties {
|
|
11
|
+
/** The duration of this video in second */
|
|
12
|
+
duration: number;
|
|
13
|
+
/** {@link Continuable} of videos inside a {@link Video} */
|
|
14
|
+
comments: VideoComments;
|
|
15
|
+
/** @hidden */
|
|
16
|
+
constructor(attr: VideoProperties);
|
|
17
|
+
/**
|
|
18
|
+
* Load this instance with raw data from Youtube
|
|
19
|
+
*
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
load(data: YoutubeRawData): Video;
|
|
23
|
+
}
|
|
24
|
+
export {};
|