youtubei 0.0.1-rc.9 → 1.0.0-rc.3
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/{classes → cjs/classes/LiveVideo}/LiveVideo.js +84 -89
- 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/{classes/Base.js → cjs/classes/SearchResult/proto/SearchProto.js} +2 -5
- package/dist/cjs/classes/SearchResult/proto/index.js +57 -0
- package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -66
- 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 -14
- 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/{classes → typings/classes/LiveVideo}/LiveVideo.d.ts +46 -44
- 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/{classes → typings/classes/Thumbnails}/Thumbnails.d.ts +41 -42
- 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 -5
- 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 -1
- 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 -7
- package/dist/classes/BaseVideo.d.ts +0 -54
- package/dist/classes/BaseVideo.js +0 -82
- package/dist/classes/Channel.d.ts +0 -83
- package/dist/classes/Channel.js +0 -138
- package/dist/classes/Chat.d.ts +0 -29
- package/dist/classes/Chat.js +0 -31
- package/dist/classes/Client.d.ts +0 -30
- package/dist/classes/Client.js +0 -69
- package/dist/classes/Comment.d.ts +0 -43
- package/dist/classes/Comment.js +0 -42
- package/dist/classes/Playlist.d.ts +0 -61
- package/dist/classes/Playlist.js +0 -127
- package/dist/classes/PlaylistCompact.d.ts +0 -30
- package/dist/classes/PlaylistCompact.js +0 -45
- package/dist/classes/SearchResult.d.ts +0 -69
- package/dist/classes/SearchResult.js +0 -139
- package/dist/classes/Video.d.ts +0 -49
- package/dist/classes/Video.js +0 -102
- package/dist/classes/VideoCompact.d.ts +0 -40
- package/dist/classes/VideoCompact.js +0 -50
- package/dist/classes/index.d.ts +0 -13
- package/dist/classes/index.js +0 -32
- package/dist/common/helper.d.ts +0 -2
- package/dist/common/helper.js +0 -37
- package/dist/common/http.d.ts +0 -30
- package/dist/common/http.js +0 -108
- package/dist/common/index.d.ts +0 -5
- package/dist/common/mixins.d.ts +0 -2
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Thumbnails, BaseAttributes, Base } from ".";
|
|
2
|
-
import { YoutubeRawData } from "../common";
|
|
3
|
-
import Channel from "./Channel";
|
|
4
|
-
/** @hidden */
|
|
5
|
-
interface PlaylistCompactAttributes extends BaseAttributes {
|
|
6
|
-
title: string;
|
|
7
|
-
thumbnails: Thumbnails;
|
|
8
|
-
channel?: Channel;
|
|
9
|
-
videoCount: number;
|
|
10
|
-
}
|
|
11
|
-
/** Represents a Compact Playlist (e.g. from search result, upNext / related of a video) */
|
|
12
|
-
export default class PlaylistCompact extends Base implements PlaylistCompactAttributes {
|
|
13
|
-
/** The playlist's title */
|
|
14
|
-
title: string;
|
|
15
|
-
/** Thumbnails of the playlist with different sizes */
|
|
16
|
-
thumbnails: Thumbnails;
|
|
17
|
-
/** The channel that made this playlist */
|
|
18
|
-
channel?: Channel;
|
|
19
|
-
/** How many videos in this playlist */
|
|
20
|
-
videoCount: number;
|
|
21
|
-
/** @hidden */
|
|
22
|
-
constructor(playlist?: Partial<PlaylistCompactAttributes>);
|
|
23
|
-
/**
|
|
24
|
-
* Load this instance with raw data from Youtube
|
|
25
|
-
*
|
|
26
|
-
* @hidden
|
|
27
|
-
*/
|
|
28
|
-
load(data: YoutubeRawData): PlaylistCompact;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const _1 = require(".");
|
|
7
|
-
const Channel_1 = __importDefault(require("./Channel"));
|
|
8
|
-
/** Represents a Compact Playlist (e.g. from search result, upNext / related of a video) */
|
|
9
|
-
class PlaylistCompact extends _1.Base {
|
|
10
|
-
/** @hidden */
|
|
11
|
-
constructor(playlist = {}) {
|
|
12
|
-
super();
|
|
13
|
-
Object.assign(this, playlist);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Load this instance with raw data from Youtube
|
|
17
|
-
*
|
|
18
|
-
* @hidden
|
|
19
|
-
*/
|
|
20
|
-
load(data) {
|
|
21
|
-
var _a;
|
|
22
|
-
const { playlistId, title, thumbnail, shortBylineText, videoCount, videoCountShortText, } = data;
|
|
23
|
-
this.id = playlistId;
|
|
24
|
-
this.title = title.simpleText || title.runs[0].text;
|
|
25
|
-
this.videoCount =
|
|
26
|
-
+((_a = (videoCount !== null && videoCount !== void 0 ? videoCount : videoCountShortText.simpleText)) === null || _a === void 0 ? void 0 : _a.replace(/[^0-9]/g, "")) || 0;
|
|
27
|
-
// Thumbnail
|
|
28
|
-
let { thumbnails } = data;
|
|
29
|
-
if (!thumbnails)
|
|
30
|
-
thumbnails = thumbnail.thumbnails;
|
|
31
|
-
else
|
|
32
|
-
thumbnails = thumbnails[0].thumbnails;
|
|
33
|
-
this.thumbnails = new _1.Thumbnails().load(thumbnails);
|
|
34
|
-
// Channel
|
|
35
|
-
if (shortBylineText && shortBylineText.simpleText !== "YouTube") {
|
|
36
|
-
this.channel = new Channel_1.default({
|
|
37
|
-
id: shortBylineText.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
38
|
-
name: shortBylineText.runs[0].text,
|
|
39
|
-
url: `https://www.youtube.com${shortBylineText.runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url}`,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.default = PlaylistCompact;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Channel, PlaylistCompact, VideoCompact, ClientTypes } from ".";
|
|
2
|
-
export declare type SearchResultType<T> = T extends {
|
|
3
|
-
type: "video";
|
|
4
|
-
} ? VideoCompact : T extends {
|
|
5
|
-
type: "channel";
|
|
6
|
-
} ? Channel : T extends {
|
|
7
|
-
type: "playlist";
|
|
8
|
-
} ? PlaylistCompact : VideoCompact | Channel | PlaylistCompact;
|
|
9
|
-
/**
|
|
10
|
-
* Represents search result, usually returned from `client.search();`.
|
|
11
|
-
*
|
|
12
|
-
* {@link SearchResult} is a subclass of [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
|
13
|
-
* with {@link SearchResult.next} method to navigate through pagination
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const searchResult = await youtube.search("Keyword");
|
|
18
|
-
*
|
|
19
|
-
* console.log(searchResult); // search result from first page
|
|
20
|
-
*
|
|
21
|
-
* let nextSearchResult = await searchResult.next();
|
|
22
|
-
* console.log(nextSearchResult); // search result from second page
|
|
23
|
-
*
|
|
24
|
-
* nextSearchResult = await searchResult.next();
|
|
25
|
-
* console.log(nextSearchResult); // search result from third page
|
|
26
|
-
*
|
|
27
|
-
* console.log(searchResult); // search result from first, second, and third page.
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @noInheritDoc
|
|
31
|
-
*/
|
|
32
|
-
export default class SearchResult<T> extends Array<SearchResultType<T>> {
|
|
33
|
-
private _continuation;
|
|
34
|
-
/** @hidden */
|
|
35
|
-
constructor();
|
|
36
|
-
/**
|
|
37
|
-
* Initialize data from search
|
|
38
|
-
*
|
|
39
|
-
* @param query Search query
|
|
40
|
-
* @param options Search Options
|
|
41
|
-
* @hidden
|
|
42
|
-
*/
|
|
43
|
-
init(query: string, options: ClientTypes.SearchOptions): Promise<SearchResult<T>>;
|
|
44
|
-
/**
|
|
45
|
-
* Load next search data. Youtube returns inconsistent amount of search result, it usually varies from 18 to 20
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```js
|
|
49
|
-
* const videos = await youtube.search("keyword", { type: "video" });
|
|
50
|
-
* console.log(videos) // first 18-20 videos from the search result
|
|
51
|
-
*
|
|
52
|
-
* let newVideos = await videos.next();
|
|
53
|
-
* console.log(newVideos) // 18-20 loaded videos
|
|
54
|
-
* console.log(videos) // 36-40 first videos from the search result
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @param count How many times to load the next data
|
|
58
|
-
*/
|
|
59
|
-
next(count?: number): Promise<Array<SearchResultType<T>>>;
|
|
60
|
-
/** Load videos data from youtube */
|
|
61
|
-
private loadSearchResult;
|
|
62
|
-
/**
|
|
63
|
-
* Get type query value
|
|
64
|
-
*
|
|
65
|
-
* @param type Search type
|
|
66
|
-
* @hidden
|
|
67
|
-
*/
|
|
68
|
-
static getSearchTypeParam(type: "video" | "playlist" | "channel" | "all"): string;
|
|
69
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var SearchResult_1;
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
const constants_1 = require("../constants");
|
|
20
|
-
const common_1 = require("../common");
|
|
21
|
-
const _1 = require(".");
|
|
22
|
-
/**
|
|
23
|
-
* Represents search result, usually returned from `client.search();`.
|
|
24
|
-
*
|
|
25
|
-
* {@link SearchResult} is a subclass of [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
|
26
|
-
* with {@link SearchResult.next} method to navigate through pagination
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const searchResult = await youtube.search("Keyword");
|
|
31
|
-
*
|
|
32
|
-
* console.log(searchResult); // search result from first page
|
|
33
|
-
*
|
|
34
|
-
* let nextSearchResult = await searchResult.next();
|
|
35
|
-
* console.log(nextSearchResult); // search result from second page
|
|
36
|
-
*
|
|
37
|
-
* nextSearchResult = await searchResult.next();
|
|
38
|
-
* console.log(nextSearchResult); // search result from third page
|
|
39
|
-
*
|
|
40
|
-
* console.log(searchResult); // search result from first, second, and third page.
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @noInheritDoc
|
|
44
|
-
*/
|
|
45
|
-
let SearchResult = SearchResult_1 = class SearchResult extends Array {
|
|
46
|
-
/** @hidden */
|
|
47
|
-
constructor() {
|
|
48
|
-
super();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Initialize data from search
|
|
52
|
-
*
|
|
53
|
-
* @param query Search query
|
|
54
|
-
* @param options Search Options
|
|
55
|
-
* @hidden
|
|
56
|
-
*/
|
|
57
|
-
init(query, options) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
60
|
-
data: { query, params: SearchResult_1.getSearchTypeParam(options.type) },
|
|
61
|
-
});
|
|
62
|
-
this.loadSearchResult(response.data.contents.twoColumnSearchResultsRenderer.primaryContents
|
|
63
|
-
.sectionListRenderer.contents);
|
|
64
|
-
return this;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Load next search data. Youtube returns inconsistent amount of search result, it usually varies from 18 to 20
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```js
|
|
72
|
-
* const videos = await youtube.search("keyword", { type: "video" });
|
|
73
|
-
* console.log(videos) // first 18-20 videos from the search result
|
|
74
|
-
*
|
|
75
|
-
* let newVideos = await videos.next();
|
|
76
|
-
* console.log(newVideos) // 18-20 loaded videos
|
|
77
|
-
* console.log(videos) // 36-40 first videos from the search result
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* @param count How many times to load the next data
|
|
81
|
-
*/
|
|
82
|
-
next(count = 1) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const newSearchResults = [];
|
|
85
|
-
for (let i = 0; i < count; i++) {
|
|
86
|
-
if (!this._continuation)
|
|
87
|
-
break;
|
|
88
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
89
|
-
data: { continuation: this._continuation },
|
|
90
|
-
});
|
|
91
|
-
newSearchResults.push(...this.loadSearchResult(response.data.onResponseReceivedCommands[0].appendContinuationItemsAction
|
|
92
|
-
.continuationItems));
|
|
93
|
-
}
|
|
94
|
-
this.push(...newSearchResults);
|
|
95
|
-
return newSearchResults;
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
/** Load videos data from youtube */
|
|
99
|
-
loadSearchResult(sectionListContents) {
|
|
100
|
-
var _a, _b;
|
|
101
|
-
const contents = sectionListContents
|
|
102
|
-
.filter((c) => "itemSectionRenderer" in c)
|
|
103
|
-
.pop().itemSectionRenderer.contents;
|
|
104
|
-
const continuationToken = (_b = (_a = sectionListContents
|
|
105
|
-
.filter((c) => "continuationItemRenderer" in c)
|
|
106
|
-
.pop().continuationItemRenderer) === null || _a === void 0 ? void 0 : _a.continuationEndpoint) === null || _b === void 0 ? void 0 : _b.continuationCommand.token;
|
|
107
|
-
this._continuation = continuationToken;
|
|
108
|
-
const newContent = [];
|
|
109
|
-
for (const content of contents) {
|
|
110
|
-
if ("playlistRenderer" in content)
|
|
111
|
-
newContent.push(new _1.PlaylistCompact().load(content.playlistRenderer));
|
|
112
|
-
else if ("videoRenderer" in content)
|
|
113
|
-
newContent.push(new _1.VideoCompact().load(content.videoRenderer));
|
|
114
|
-
else if ("channelRenderer" in content)
|
|
115
|
-
newContent.push(new _1.Channel().load(content.channelRenderer));
|
|
116
|
-
}
|
|
117
|
-
this.push(...newContent);
|
|
118
|
-
return newContent;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Get type query value
|
|
122
|
-
*
|
|
123
|
-
* @param type Search type
|
|
124
|
-
* @hidden
|
|
125
|
-
*/
|
|
126
|
-
static getSearchTypeParam(type) {
|
|
127
|
-
const searchType = {
|
|
128
|
-
video: "EgIQAQ%3D%3D",
|
|
129
|
-
playlist: "EgIQAw%3D%3D",
|
|
130
|
-
channel: "EgIQAg%3D%3D",
|
|
131
|
-
all: "",
|
|
132
|
-
};
|
|
133
|
-
return type in searchType ? searchType[type] : "";
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
SearchResult = SearchResult_1 = __decorate([
|
|
137
|
-
common_1.extendsBuiltIn()
|
|
138
|
-
], SearchResult);
|
|
139
|
-
exports.default = SearchResult;
|
package/dist/classes/Video.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BaseVideo, BaseVideoAttributes, Comment } from ".";
|
|
2
|
-
import { YoutubeRawData } from "../common";
|
|
3
|
-
/** @hidden */
|
|
4
|
-
interface VideoAttributes extends BaseVideoAttributes {
|
|
5
|
-
duration: number | null;
|
|
6
|
-
comments: Comment[];
|
|
7
|
-
}
|
|
8
|
-
/** Represents a Video, usually returned from `client.getVideo()` */
|
|
9
|
-
export default class Video extends BaseVideo implements VideoAttributes {
|
|
10
|
-
/** The duration of this video in second */
|
|
11
|
-
duration: number;
|
|
12
|
-
/**
|
|
13
|
-
* Comments of this video
|
|
14
|
-
*
|
|
15
|
-
* You need to load the comment first by calling `video.nextComments()` as youtube doesn't send any comments data when loading the video (from `client.getVideo()`)
|
|
16
|
-
*/
|
|
17
|
-
comments: Comment[];
|
|
18
|
-
private _commentContinuation?;
|
|
19
|
-
/** @hidden */
|
|
20
|
-
constructor(video?: Partial<VideoAttributes>);
|
|
21
|
-
/**
|
|
22
|
-
* Load this instance with raw data from Youtube
|
|
23
|
-
*
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
load(data: YoutubeRawData): Video;
|
|
27
|
-
/**
|
|
28
|
-
* Load next 20 comments of the video, and push the loaded comments to {@link Video.comments}
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```js
|
|
32
|
-
* const video = await youtube.getVideo(VIDEO_ID);
|
|
33
|
-
* await video.nextComments();
|
|
34
|
-
* console.log(video.comments) // first 20 comments
|
|
35
|
-
*
|
|
36
|
-
* let newComments = await video.nextComments();
|
|
37
|
-
* console.log(newComments) // 20 loaded comments
|
|
38
|
-
* console.log(video.comments) // first 40 comments
|
|
39
|
-
*
|
|
40
|
-
* await video.nextComments(0); // load the rest of the comments in the video
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @param count How many times to load the next comments. Set 0 to load all comments (might take a while on a video with many comments!)
|
|
44
|
-
*
|
|
45
|
-
* @returns Loaded comments
|
|
46
|
-
*/
|
|
47
|
-
nextComments(count?: number): Promise<Comment[]>;
|
|
48
|
-
}
|
|
49
|
-
export {};
|
package/dist/classes/Video.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const _1 = require(".");
|
|
13
|
-
const common_1 = require("../common");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
|
-
/** Represents a Video, usually returned from `client.getVideo()` */
|
|
16
|
-
class Video extends _1.BaseVideo {
|
|
17
|
-
/** @hidden */
|
|
18
|
-
constructor(video = {}) {
|
|
19
|
-
super();
|
|
20
|
-
Object.assign(this, video);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Load this instance with raw data from Youtube
|
|
24
|
-
*
|
|
25
|
-
* @hidden
|
|
26
|
-
*/
|
|
27
|
-
load(data) {
|
|
28
|
-
var _a;
|
|
29
|
-
super.load(data);
|
|
30
|
-
const contents = data[3].response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
31
|
-
const videoInfo = _1.BaseVideo.parseRawData(data);
|
|
32
|
-
// Comment Continuation Token
|
|
33
|
-
this.comments = [];
|
|
34
|
-
const continuation = (_a = contents.find((c) => "itemSectionRenderer" in c)) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer.continuations[0].nextContinuationData;
|
|
35
|
-
if (continuation) {
|
|
36
|
-
this._commentContinuation = {
|
|
37
|
-
token: continuation.continuation,
|
|
38
|
-
itct: continuation.clickTrackingParams,
|
|
39
|
-
xsrfToken: data[3].xsrf_token,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// Duration
|
|
43
|
-
this.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Load next 20 comments of the video, and push the loaded comments to {@link Video.comments}
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```js
|
|
51
|
-
* const video = await youtube.getVideo(VIDEO_ID);
|
|
52
|
-
* await video.nextComments();
|
|
53
|
-
* console.log(video.comments) // first 20 comments
|
|
54
|
-
*
|
|
55
|
-
* let newComments = await video.nextComments();
|
|
56
|
-
* console.log(newComments) // 20 loaded comments
|
|
57
|
-
* console.log(video.comments) // first 40 comments
|
|
58
|
-
*
|
|
59
|
-
* await video.nextComments(0); // load the rest of the comments in the video
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @param count How many times to load the next comments. Set 0 to load all comments (might take a while on a video with many comments!)
|
|
63
|
-
*
|
|
64
|
-
* @returns Loaded comments
|
|
65
|
-
*/
|
|
66
|
-
nextComments(count = 1) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const newComments = [];
|
|
69
|
-
for (let i = 0; i < count || count == 0; i++) {
|
|
70
|
-
if (!this._commentContinuation)
|
|
71
|
-
break;
|
|
72
|
-
// Send request
|
|
73
|
-
const response = yield common_1.http.post(constants_1.COMMENT_END_POINT, {
|
|
74
|
-
data: { session_token: this._commentContinuation.xsrfToken },
|
|
75
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
76
|
-
params: {
|
|
77
|
-
action_get_comments: "1",
|
|
78
|
-
pbj: "1",
|
|
79
|
-
ctoken: this._commentContinuation.token,
|
|
80
|
-
continuation: this._commentContinuation.token,
|
|
81
|
-
itct: this._commentContinuation.itct,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
const { contents: comments, continuations, } = response.data.response.continuationContents.itemSectionContinuation;
|
|
85
|
-
const continuation = continuations === null || continuations === void 0 ? void 0 : continuations.pop().nextContinuationData;
|
|
86
|
-
this._commentContinuation = continuation
|
|
87
|
-
? {
|
|
88
|
-
token: continuation.continuation,
|
|
89
|
-
itct: continuation.clickTrackingParams,
|
|
90
|
-
xsrfToken: response.data.xsrf_token,
|
|
91
|
-
}
|
|
92
|
-
: undefined;
|
|
93
|
-
for (const comment of comments.map((c) => c.commentThreadRenderer)) {
|
|
94
|
-
newComments.push(new _1.Comment({ video: this }).load(comment));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
this.comments.push(...newComments);
|
|
98
|
-
return newComments;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.default = Video;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { YoutubeRawData } from "../common";
|
|
2
|
-
import { Base, Channel, Thumbnails, BaseAttributes } from ".";
|
|
3
|
-
/** @hidden */
|
|
4
|
-
interface VideoCompactAttributes extends BaseAttributes {
|
|
5
|
-
title: string;
|
|
6
|
-
thumbnails: Thumbnails;
|
|
7
|
-
duration: number | null;
|
|
8
|
-
isLiveContent: boolean;
|
|
9
|
-
channel?: Channel;
|
|
10
|
-
uploadDate?: string;
|
|
11
|
-
viewCount?: number;
|
|
12
|
-
}
|
|
13
|
-
/** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
|
|
14
|
-
export default class VideoCompact extends Base implements VideoCompactAttributes {
|
|
15
|
-
/** The title of the video */
|
|
16
|
-
title: string;
|
|
17
|
-
/** Thumbnails of the video with different sizes */
|
|
18
|
-
thumbnails: Thumbnails;
|
|
19
|
-
/** The duration of this video in second, null if the video is live */
|
|
20
|
-
duration: number | null;
|
|
21
|
-
/** Whether this video is a live content or not */
|
|
22
|
-
isLiveContent: boolean;
|
|
23
|
-
/** The channel who uploads this video */
|
|
24
|
-
channel?: Channel;
|
|
25
|
-
/** The date this video is uploaded at */
|
|
26
|
-
uploadDate?: string;
|
|
27
|
-
/** How many view does this video have, null if the view count is hidden */
|
|
28
|
-
viewCount?: number;
|
|
29
|
-
/** @hidden */
|
|
30
|
-
constructor(videoCompact?: Partial<VideoCompactAttributes>);
|
|
31
|
-
/**
|
|
32
|
-
* Load this instance with raw data from Youtube
|
|
33
|
-
*
|
|
34
|
-
* @hidden
|
|
35
|
-
*/
|
|
36
|
-
load(data: YoutubeRawData): VideoCompact;
|
|
37
|
-
/** Whether this video is private / deleted or not, only useful in playlist's videos */
|
|
38
|
-
get isPrivateOrDeleted(): boolean;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const common_1 = require("../common");
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
/** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
|
|
6
|
-
class VideoCompact extends _1.Base {
|
|
7
|
-
/** @hidden */
|
|
8
|
-
constructor(videoCompact = {}) {
|
|
9
|
-
super();
|
|
10
|
-
Object.assign(this, videoCompact);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Load this instance with raw data from Youtube
|
|
14
|
-
*
|
|
15
|
-
* @hidden
|
|
16
|
-
*/
|
|
17
|
-
load(data) {
|
|
18
|
-
var _a, _b, _c;
|
|
19
|
-
const { videoId, title, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, } = data;
|
|
20
|
-
this.id = videoId;
|
|
21
|
-
this.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
|
|
22
|
-
this.thumbnails = new _1.Thumbnails().load(thumbnail.thumbnails);
|
|
23
|
-
this.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
24
|
-
this.duration =
|
|
25
|
-
common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_b = thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _b === void 0 ? void 0 : _b.text.simpleText) ||
|
|
26
|
-
"") || null;
|
|
27
|
-
this.isLiveContent = badges
|
|
28
|
-
? badges[0].metadataBadgeRenderer.style === "BADGE_STYLE_TYPE_LIVE_NOW"
|
|
29
|
-
: false;
|
|
30
|
-
// Channel
|
|
31
|
-
if (ownerText || shortBylineText) {
|
|
32
|
-
const { browseId, canonicalBaseUrl } = (ownerText || shortBylineText).runs[0].navigationEndpoint.browseEndpoint;
|
|
33
|
-
this.channel = new _1.Channel({
|
|
34
|
-
id: browseId,
|
|
35
|
-
name: (ownerText || shortBylineText).runs[0].text,
|
|
36
|
-
url: "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`),
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (!this.isLiveContent)
|
|
40
|
-
this.viewCount = +((_c = viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) === null || _c === void 0 ? void 0 : _c.replace(/[^0-9]/g, "")) || undefined;
|
|
41
|
-
else
|
|
42
|
-
this.viewCount = +(viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text.replace(/[^0-9]/g, "")) || undefined;
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
/** Whether this video is private / deleted or not, only useful in playlist's videos */
|
|
46
|
-
get isPrivateOrDeleted() {
|
|
47
|
-
return !this.duration;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.default = VideoCompact;
|
package/dist/classes/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { default as Client, Client as ClientTypes } from "./Client";
|
|
2
|
-
export { default as Base, BaseAttributes } from "./Base";
|
|
3
|
-
export { default as BaseVideo, BaseVideoAttributes } from "./BaseVideo";
|
|
4
|
-
export { default as VideoCompact } from "./VideoCompact";
|
|
5
|
-
export { default as Thumbnails } from "./Thumbnails";
|
|
6
|
-
export { default as Channel } from "./Channel";
|
|
7
|
-
export { default as Comment } from "./Comment";
|
|
8
|
-
export { default as Chat } from "./Chat";
|
|
9
|
-
export { default as PlaylistCompact } from "./PlaylistCompact";
|
|
10
|
-
export { default as Playlist } from "./Playlist";
|
|
11
|
-
export { default as Video } from "./Video";
|
|
12
|
-
export { default as LiveVideo } from "./LiveVideo";
|
|
13
|
-
export { default as SearchResult } from "./SearchResult";
|
package/dist/classes/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SearchResult = exports.LiveVideo = exports.Video = exports.Playlist = exports.PlaylistCompact = exports.Chat = exports.Comment = exports.Channel = exports.Thumbnails = exports.VideoCompact = exports.BaseVideo = exports.Base = exports.Client = void 0;
|
|
7
|
-
var Client_1 = require("./Client");
|
|
8
|
-
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return __importDefault(Client_1).default; } });
|
|
9
|
-
var Base_1 = require("./Base");
|
|
10
|
-
Object.defineProperty(exports, "Base", { enumerable: true, get: function () { return __importDefault(Base_1).default; } });
|
|
11
|
-
var BaseVideo_1 = require("./BaseVideo");
|
|
12
|
-
Object.defineProperty(exports, "BaseVideo", { enumerable: true, get: function () { return __importDefault(BaseVideo_1).default; } });
|
|
13
|
-
var VideoCompact_1 = require("./VideoCompact");
|
|
14
|
-
Object.defineProperty(exports, "VideoCompact", { enumerable: true, get: function () { return __importDefault(VideoCompact_1).default; } });
|
|
15
|
-
var Thumbnails_1 = require("./Thumbnails");
|
|
16
|
-
Object.defineProperty(exports, "Thumbnails", { enumerable: true, get: function () { return __importDefault(Thumbnails_1).default; } });
|
|
17
|
-
var Channel_1 = require("./Channel");
|
|
18
|
-
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return __importDefault(Channel_1).default; } });
|
|
19
|
-
var Comment_1 = require("./Comment");
|
|
20
|
-
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return __importDefault(Comment_1).default; } });
|
|
21
|
-
var Chat_1 = require("./Chat");
|
|
22
|
-
Object.defineProperty(exports, "Chat", { enumerable: true, get: function () { return __importDefault(Chat_1).default; } });
|
|
23
|
-
var PlaylistCompact_1 = require("./PlaylistCompact");
|
|
24
|
-
Object.defineProperty(exports, "PlaylistCompact", { enumerable: true, get: function () { return __importDefault(PlaylistCompact_1).default; } });
|
|
25
|
-
var Playlist_1 = require("./Playlist");
|
|
26
|
-
Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return __importDefault(Playlist_1).default; } });
|
|
27
|
-
var Video_1 = require("./Video");
|
|
28
|
-
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return __importDefault(Video_1).default; } });
|
|
29
|
-
var LiveVideo_1 = require("./LiveVideo");
|
|
30
|
-
Object.defineProperty(exports, "LiveVideo", { enumerable: true, get: function () { return __importDefault(LiveVideo_1).default; } });
|
|
31
|
-
var SearchResult_1 = require("./SearchResult");
|
|
32
|
-
Object.defineProperty(exports, "SearchResult", { enumerable: true, get: function () { return __importDefault(SearchResult_1).default; } });
|
package/dist/common/helper.d.ts
DELETED
package/dist/common/helper.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getQueryParameter = exports.getDuration = void 0;
|
|
4
|
-
const url_1 = require("url");
|
|
5
|
-
const getDuration = (s) => {
|
|
6
|
-
s = s.replace(/:/g, ".");
|
|
7
|
-
const spl = s.split(".");
|
|
8
|
-
if (spl.length === 0)
|
|
9
|
-
return +spl;
|
|
10
|
-
else {
|
|
11
|
-
const sumStr = spl.pop();
|
|
12
|
-
if (sumStr !== undefined) {
|
|
13
|
-
let sum = +sumStr;
|
|
14
|
-
if (spl.length === 1)
|
|
15
|
-
sum += +spl[0] * 60;
|
|
16
|
-
if (spl.length === 2) {
|
|
17
|
-
sum += +spl[1] * 60;
|
|
18
|
-
sum += +spl[0] * 3600;
|
|
19
|
-
}
|
|
20
|
-
return sum;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return 0;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
exports.getDuration = getDuration;
|
|
28
|
-
const getQueryParameter = (url, queryName) => {
|
|
29
|
-
try {
|
|
30
|
-
return new url_1.URL(url).searchParams.get(queryName) || url;
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
/* not an URL */
|
|
34
|
-
return url;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.getQueryParameter = getQueryParameter;
|
package/dist/common/http.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import https from "https";
|
|
3
|
-
import { IncomingHttpHeaders } from "http";
|
|
4
|
-
import { YoutubeRawData } from "./types";
|
|
5
|
-
interface Options extends https.RequestOptions {
|
|
6
|
-
params: Record<string, any>;
|
|
7
|
-
data: any;
|
|
8
|
-
headers: Record<string, string>;
|
|
9
|
-
}
|
|
10
|
-
interface Response<T = any> {
|
|
11
|
-
data: T;
|
|
12
|
-
headers: IncomingHttpHeaders;
|
|
13
|
-
status: number | undefined;
|
|
14
|
-
}
|
|
15
|
-
export default class HTTP {
|
|
16
|
-
/**
|
|
17
|
-
* Send request to Youtube
|
|
18
|
-
*/
|
|
19
|
-
static request(partialOptions: Partial<Options>): Promise<Response>;
|
|
20
|
-
private static returnPromise;
|
|
21
|
-
/**
|
|
22
|
-
* Send GET request to Youtube
|
|
23
|
-
*/
|
|
24
|
-
static get(path: string, options: Partial<Options>): Promise<YoutubeRawData>;
|
|
25
|
-
/**
|
|
26
|
-
* Send POST request to Youtube
|
|
27
|
-
*/
|
|
28
|
-
static post(path: string, options: Partial<Options>): Promise<YoutubeRawData>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|