youtubei 0.0.1-rc.7 → 1.0.0-rc.1
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/{index.js → cjs/classes/Base/index.js} +13 -13
- 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/{classes/client → cjs/classes/BaseChannel}/index.js +16 -19
- 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/{common → cjs/classes/BaseVideo}/index.js +15 -21
- 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 +13 -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 +13 -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 +13 -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/SearchManager/SearchManager.js +83 -0
- package/dist/cjs/classes/SearchManager/SearchManagerParser.js +40 -0
- package/dist/cjs/classes/SearchManager/index.js +14 -0
- package/dist/{common/types.js → cjs/classes/SearchManager/proto/SearchProto.js} +2 -2
- package/dist/cjs/classes/SearchManager/proto/index.js +57 -0
- package/dist/cjs/classes/Thumbnails/Thumbnails.js +67 -0
- 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 +14 -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/{src → cjs}/common/decorators.js +14 -15
- package/dist/cjs/common/helper.js +45 -0
- package/dist/{src → cjs}/common/index.js +16 -21
- package/dist/cjs/common/mixins.js +14 -0
- package/dist/{classes/client → cjs/common}/types.js +2 -2
- package/dist/{src → cjs}/constants.js +10 -9
- package/dist/{src → 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 +1 -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 +1 -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 +1 -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/SearchManager/SearchManager.js +159 -0
- package/dist/esm/classes/SearchManager/SearchManagerParser.js +62 -0
- package/dist/esm/classes/SearchManager/index.js +2 -0
- package/dist/esm/classes/SearchManager/proto/SearchProto.js +1 -0
- package/dist/esm/classes/SearchManager/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 +2 -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/{common/index.d.ts → esm/common/index.js} +4 -4
- 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/{index.d.ts → esm/index.js} +1 -1
- 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 +1 -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 +1 -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 +1 -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/SearchManager/SearchManager.d.ts +51 -0
- package/dist/typings/classes/SearchManager/SearchManagerParser.d.ts +13 -0
- package/dist/typings/classes/SearchManager/index.d.ts +2 -0
- package/dist/typings/classes/SearchManager/proto/SearchProto.d.ts +13 -0
- package/dist/typings/classes/SearchManager/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 +2 -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/{src → typings}/common/decorators.d.ts +5 -7
- package/dist/typings/common/helper.d.ts +5 -0
- package/dist/{src → typings}/common/index.d.ts +4 -4
- 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 -6
- package/dist/{src → 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/Comment.d.ts +0 -51
- package/dist/classes/Comment.js +0 -47
- package/dist/classes/LiveVideo.d.ts +0 -3
- package/dist/classes/LiveVideo.js +0 -12
- 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 -52
- package/dist/classes/SearchResult.js +0 -121
- package/dist/classes/Test.d.ts +0 -7
- package/dist/classes/Test.js +0 -9
- package/dist/classes/Thumbnails.d.ts +0 -23
- package/dist/classes/Thumbnails.js +0 -42
- 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/client/Client.d.ts +0 -26
- package/dist/classes/client/Client.js +0 -63
- package/dist/classes/client/index.d.ts +0 -2
- package/dist/classes/client/types.d.ts +0 -12
- package/dist/classes/client.d.ts +0 -17
- package/dist/classes/client.js +0 -57
- package/dist/classes/index.d.ts +0 -10
- package/dist/classes/index.js +0 -26
- package/dist/common/decorators.d.ts +0 -7
- package/dist/common/decorators.js +0 -15
- 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/constants.js +0 -9
- package/dist/src/classes/Base.d.ts +0 -8
- package/dist/src/classes/Base.js +0 -10
- package/dist/src/classes/Channel.d.ts +0 -37
- package/dist/src/classes/Channel.js +0 -82
- package/dist/src/classes/Client.d.ts +0 -14
- package/dist/src/classes/Client.js +0 -51
- package/dist/src/classes/Comment.d.ts +0 -51
- package/dist/src/classes/Comment.js +0 -47
- package/dist/src/classes/Playlist.d.ts +0 -66
- package/dist/src/classes/Playlist.js +0 -133
- package/dist/src/classes/PlaylistCompact.d.ts +0 -35
- package/dist/src/classes/PlaylistCompact.js +0 -47
- package/dist/src/classes/SearchResult.d.ts +0 -53
- package/dist/src/classes/SearchResult.js +0 -122
- package/dist/src/classes/Thumbnails.d.ts +0 -24
- package/dist/src/classes/Thumbnails.js +0 -42
- package/dist/src/classes/Video.d.ts +0 -90
- package/dist/src/classes/Video.js +0 -153
- package/dist/src/classes/VideoCompact.d.ts +0 -46
- package/dist/src/classes/VideoCompact.js +0 -53
- package/dist/src/classes/index.d.ts +0 -10
- package/dist/src/classes/index.js +0 -26
- package/dist/src/common/helper.d.ts +0 -4
- package/dist/src/common/helper.js +0 -39
- package/dist/src/common/http.d.ts +0 -33
- package/dist/src/common/http.js +0 -105
- package/dist/src/common/types.d.ts +0 -2
- package/dist/src/common/types.js +0 -2
- package/dist/src/constants.d.ts +0 -6
- package/dist/tempCodeRunnerFile.d.ts +0 -8
- package/dist/tempCodeRunnerFile.js +0 -15
package/dist/classes/Video.js
DELETED
|
@@ -1,153 +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.Base {
|
|
17
|
-
/** @hidden */
|
|
18
|
-
constructor(video = {}) {
|
|
19
|
-
super();
|
|
20
|
-
Object.assign(this, video);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Load instance attributes from youtube raw data
|
|
24
|
-
*
|
|
25
|
-
* @param youtubeRawData raw object from youtubei
|
|
26
|
-
* @hidden
|
|
27
|
-
*/
|
|
28
|
-
load(youtubeRawData) {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
|
-
const contents = youtubeRawData[3].response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
31
|
-
const primaryInfo = contents.find((c) => "videoPrimaryInfoRenderer" in c)
|
|
32
|
-
.videoPrimaryInfoRenderer;
|
|
33
|
-
const secondaryInfo = contents.find((c) => "videoSecondaryInfoRenderer" in c).videoSecondaryInfoRenderer;
|
|
34
|
-
const videoDetails = youtubeRawData[2].playerResponse.videoDetails;
|
|
35
|
-
const videoInfo = Object.assign(Object.assign(Object.assign({}, secondaryInfo), primaryInfo), { videoDetails });
|
|
36
|
-
// Comment Continuation Token
|
|
37
|
-
this.comments = [];
|
|
38
|
-
const continuation = (_a = contents.find((c) => "itemSectionRenderer" in c)) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer.continuations[0].nextContinuationData;
|
|
39
|
-
if (continuation) {
|
|
40
|
-
this._commentContinuation = {
|
|
41
|
-
token: continuation.continuation,
|
|
42
|
-
itct: continuation.clickTrackingParams,
|
|
43
|
-
xsrfToken: youtubeRawData[3].xsrf_token,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
// Basic information
|
|
47
|
-
this.id = videoInfo.videoDetails.videoId;
|
|
48
|
-
this.title = videoInfo.videoDetails.title;
|
|
49
|
-
this.duration = +videoInfo.videoDetails.lengthSeconds || null;
|
|
50
|
-
this.uploadDate = videoInfo.dateText.simpleText;
|
|
51
|
-
this.viewCount = +videoInfo.videoDetails.viewCount;
|
|
52
|
-
this.isLiveContent = videoInfo.videoDetails.isLiveContent;
|
|
53
|
-
this.thumbnails = new _1.Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
54
|
-
// Channel
|
|
55
|
-
const { title, thumbnail } = videoInfo.owner.videoOwnerRenderer;
|
|
56
|
-
this.channel = new _1.Channel({
|
|
57
|
-
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
58
|
-
name: title.runs[0].text,
|
|
59
|
-
thumbnails: new _1.Thumbnails().load(thumbnail.thumbnails),
|
|
60
|
-
url: `https://www.youtube.com/channel/${title.runs[0].navigationEndpoint.browseEndpoint.browseId}`,
|
|
61
|
-
});
|
|
62
|
-
// Like Count and Dislike Count
|
|
63
|
-
const topLevelButtons = videoInfo.videoActions.menuRenderer.topLevelButtons;
|
|
64
|
-
this.likeCount =
|
|
65
|
-
+((_b = topLevelButtons[0].toggleButtonRenderer.defaultText.accessibility) === null || _b === void 0 ? void 0 : _b.accessibilityData.label.replace(/[^0-9]/g, "")) || null;
|
|
66
|
-
this.dislikeCount =
|
|
67
|
-
+((_c = topLevelButtons[1].toggleButtonRenderer.defaultText.accessibility) === null || _c === void 0 ? void 0 : _c.accessibilityData.label.replace(/[^0-9]/g, "")) || null;
|
|
68
|
-
// Tags and description
|
|
69
|
-
this.tags =
|
|
70
|
-
((_e = (_d = videoInfo.superTitleLink) === null || _d === void 0 ? void 0 : _d.runs) === null || _e === void 0 ? void 0 : _e.reduce((tags, t) => {
|
|
71
|
-
if (t.text.trim())
|
|
72
|
-
tags.push(t.text.trim());
|
|
73
|
-
return tags;
|
|
74
|
-
}, [])) || [];
|
|
75
|
-
this.description =
|
|
76
|
-
((_f = videoInfo.description) === null || _f === void 0 ? void 0 : _f.runs.map((d) => d.text).join("")) || "";
|
|
77
|
-
// Up Next and related videos
|
|
78
|
-
this.related = [];
|
|
79
|
-
const secondaryContents = youtubeRawData[3].response.contents.twoColumnWatchNextResults.secondaryResults
|
|
80
|
-
.secondaryResults.results;
|
|
81
|
-
for (const secondaryContent of secondaryContents) {
|
|
82
|
-
if ("compactAutoplayRenderer" in secondaryContent) {
|
|
83
|
-
const content = secondaryContent.compactAutoplayRenderer.contents[0];
|
|
84
|
-
if ("compactVideoRenderer" in content) {
|
|
85
|
-
this.upNext = new _1.VideoCompact().load(content.compactVideoRenderer);
|
|
86
|
-
}
|
|
87
|
-
else if ("compactRadioRenderer" in content) {
|
|
88
|
-
this.upNext = new _1.PlaylistCompact().load(content.compactRadioRenderer);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if ("compactVideoRenderer" in secondaryContent) {
|
|
92
|
-
this.related.push(new _1.VideoCompact().load(secondaryContent.compactVideoRenderer));
|
|
93
|
-
}
|
|
94
|
-
else if ("compactRadioRenderer" in secondaryContent) {
|
|
95
|
-
this.related.push(new _1.PlaylistCompact().load(secondaryContent.compactRadioRenderer));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Load next 20 comments of the video
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```js
|
|
105
|
-
* const video = await youtube.getVideo(VIDEO_ID);
|
|
106
|
-
* console.log(video.comments) // first 20 comments
|
|
107
|
-
*
|
|
108
|
-
* let newComments = await video.nextComments();
|
|
109
|
-
* console.log(newComments) // 20 loaded comments
|
|
110
|
-
* console.log(video.comments) // first 40 comments
|
|
111
|
-
*
|
|
112
|
-
* await video.nextComments(0); // load the rest of the comments in the playlist
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* @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!)
|
|
116
|
-
*/
|
|
117
|
-
nextComments(count = 1) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
const newComments = [];
|
|
120
|
-
for (let i = 0; i < count || count == 0; i++) {
|
|
121
|
-
if (!this._commentContinuation)
|
|
122
|
-
break;
|
|
123
|
-
// Send request
|
|
124
|
-
const response = yield common_1.http.post(constants_1.COMMENT_END_POINT, {
|
|
125
|
-
data: { session_token: this._commentContinuation.xsrfToken },
|
|
126
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
127
|
-
params: {
|
|
128
|
-
action_get_comments: "1",
|
|
129
|
-
pbj: "1",
|
|
130
|
-
ctoken: this._commentContinuation.token,
|
|
131
|
-
continuation: this._commentContinuation.token,
|
|
132
|
-
itct: this._commentContinuation.itct,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
const { contents: comments, continuations, } = response.data.response.continuationContents.itemSectionContinuation;
|
|
136
|
-
const continuation = continuations === null || continuations === void 0 ? void 0 : continuations.pop().nextContinuationData;
|
|
137
|
-
this._commentContinuation = continuation
|
|
138
|
-
? {
|
|
139
|
-
token: continuation.continuation,
|
|
140
|
-
itct: continuation.clickTrackingParams,
|
|
141
|
-
xsrfToken: response.data.xsrf_token,
|
|
142
|
-
}
|
|
143
|
-
: undefined;
|
|
144
|
-
for (const comment of comments.map((c) => c.commentThreadRenderer)) {
|
|
145
|
-
newComments.push(new _1.Comment({ video: this }).load(comment));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
this.comments.push(...newComments);
|
|
149
|
-
return newComments;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
exports.default = Video;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { YoutubeRawData } from "../common";
|
|
2
|
-
import { Base, Channel, Thumbnails } from ".";
|
|
3
|
-
/** @hidden */
|
|
4
|
-
interface VideoCompactAttributes {
|
|
5
|
-
id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
thumbnails: Thumbnails;
|
|
8
|
-
duration: number | null;
|
|
9
|
-
isLiveContent: boolean;
|
|
10
|
-
channel?: Channel;
|
|
11
|
-
uploadDate?: string;
|
|
12
|
-
viewCount?: number;
|
|
13
|
-
}
|
|
14
|
-
/** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
|
|
15
|
-
export default class VideoCompact extends Base implements VideoCompactAttributes {
|
|
16
|
-
/** The video's ID */
|
|
17
|
-
id: string;
|
|
18
|
-
/** The title of the video */
|
|
19
|
-
title: string;
|
|
20
|
-
/** Thumbnails of the video with different sizes */
|
|
21
|
-
thumbnails: Thumbnails;
|
|
22
|
-
/** The duration of this video in second, null if the video is live */
|
|
23
|
-
duration: number | null;
|
|
24
|
-
/** Whether this video is a live content or not */
|
|
25
|
-
isLiveContent: boolean;
|
|
26
|
-
/** The channel who uploads this video */
|
|
27
|
-
channel?: Channel;
|
|
28
|
-
/** The date this video is uploaded at */
|
|
29
|
-
uploadDate?: string;
|
|
30
|
-
/** How many view does this video have, null if the view count is hidden */
|
|
31
|
-
viewCount?: number;
|
|
32
|
-
/** @hidden */
|
|
33
|
-
constructor(videoCompact?: Partial<VideoCompactAttributes>);
|
|
34
|
-
/**
|
|
35
|
-
* Load instance attributes from youtube raw data
|
|
36
|
-
*
|
|
37
|
-
* @param youtubeRawData raw object from youtubei
|
|
38
|
-
* @hidden
|
|
39
|
-
*/
|
|
40
|
-
load(youtubeRawData: YoutubeRawData): VideoCompact;
|
|
41
|
-
/**
|
|
42
|
-
* Whether this video is private / deleted or not, only useful in playlist's videos
|
|
43
|
-
*/
|
|
44
|
-
get isPrivateOrDeleted(): boolean;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
@@ -1,53 +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 instance attributes from youtube raw data
|
|
14
|
-
*
|
|
15
|
-
* @param youtubeRawData raw object from youtubei
|
|
16
|
-
* @hidden
|
|
17
|
-
*/
|
|
18
|
-
load(youtubeRawData) {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
-
const { videoId, title, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, } = youtubeRawData;
|
|
21
|
-
this.id = videoId;
|
|
22
|
-
this.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
|
|
23
|
-
this.thumbnails = new _1.Thumbnails().load(thumbnail.thumbnails);
|
|
24
|
-
this.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
25
|
-
this.duration =
|
|
26
|
-
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) ||
|
|
27
|
-
"") || null;
|
|
28
|
-
this.isLiveContent = badges
|
|
29
|
-
? badges[0].metadataBadgeRenderer.style === "BADGE_STYLE_TYPE_LIVE_NOW"
|
|
30
|
-
: false;
|
|
31
|
-
// Channel
|
|
32
|
-
if (ownerText || shortBylineText) {
|
|
33
|
-
const { browseId, canonicalBaseUrl } = (ownerText || shortBylineText).runs[0].navigationEndpoint.browseEndpoint;
|
|
34
|
-
this.channel = new _1.Channel({
|
|
35
|
-
id: browseId,
|
|
36
|
-
name: (ownerText || shortBylineText).runs[0].text,
|
|
37
|
-
url: "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (!this.isLiveContent)
|
|
41
|
-
this.viewCount = +((_c = viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) === null || _c === void 0 ? void 0 : _c.replace(/[^0-9]/g, "")) || undefined;
|
|
42
|
-
else
|
|
43
|
-
this.viewCount = +(viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text.replace(/[^0-9]/g, "")) || undefined;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Whether this video is private / deleted or not, only useful in playlist's videos
|
|
48
|
-
*/
|
|
49
|
-
get isPrivateOrDeleted() {
|
|
50
|
-
return !this.duration;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.default = VideoCompact;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Playlist, Video, SearchResult } from "..";
|
|
2
|
-
export declare type SearchType = "video" | "channel" | "playlist" | "all";
|
|
3
|
-
export declare type SearchOptions = {
|
|
4
|
-
type: SearchType;
|
|
5
|
-
};
|
|
6
|
-
export default class YoutubeClient {
|
|
7
|
-
/**
|
|
8
|
-
* Searches for videos / playlists / channels
|
|
9
|
-
*
|
|
10
|
-
* @param {string} query
|
|
11
|
-
* @param {SearchOptions} searchOptions
|
|
12
|
-
*/
|
|
13
|
-
search<T extends SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResult<T>>;
|
|
14
|
-
/**
|
|
15
|
-
* Get playlist information and its videos by playlist id or URL
|
|
16
|
-
*
|
|
17
|
-
* @param playlistIdOrUrl
|
|
18
|
-
*/
|
|
19
|
-
getPlaylist(playlistIdOrUrl: string): Promise<Playlist | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* Get video information by video id or URL
|
|
22
|
-
*
|
|
23
|
-
* @param videoIdOrUrl
|
|
24
|
-
*/
|
|
25
|
-
getVideo(videoIdOrUrl: string): Promise<Video | undefined>;
|
|
26
|
-
}
|
|
@@ -1,63 +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 constants_1 = require("../../constants");
|
|
13
|
-
const common_1 = require("../../common");
|
|
14
|
-
const __1 = require("..");
|
|
15
|
-
class YoutubeClient {
|
|
16
|
-
/**
|
|
17
|
-
* Searches for videos / playlists / channels
|
|
18
|
-
*
|
|
19
|
-
* @param {string} query
|
|
20
|
-
* @param {SearchOptions} searchOptions
|
|
21
|
-
*/
|
|
22
|
-
search(query, searchOptions) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const options = Object.assign({ type: "all" }, searchOptions);
|
|
25
|
-
const result = new __1.SearchResult();
|
|
26
|
-
yield result.init(query, options);
|
|
27
|
-
return result;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get playlist information and its videos by playlist id or URL
|
|
32
|
-
*
|
|
33
|
-
* @param playlistIdOrUrl
|
|
34
|
-
*/
|
|
35
|
-
getPlaylist(playlistIdOrUrl) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const playlistId = common_1.getQueryParameter(playlistIdOrUrl, "list");
|
|
38
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
39
|
-
data: { browseId: `VL${playlistId}` },
|
|
40
|
-
});
|
|
41
|
-
if (response.data.error || response.data.alerts)
|
|
42
|
-
return undefined;
|
|
43
|
-
return new __1.Playlist().load(response.data);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get video information by video id or URL
|
|
48
|
-
*
|
|
49
|
-
* @param videoIdOrUrl
|
|
50
|
-
*/
|
|
51
|
-
getVideo(videoIdOrUrl) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const videoId = common_1.getQueryParameter(videoIdOrUrl, "v");
|
|
54
|
-
const response = yield common_1.http.get(`${constants_1.WATCH_END_POINT}`, {
|
|
55
|
-
params: { v: videoId, pbj: "1" },
|
|
56
|
-
});
|
|
57
|
-
if (!response.data[3].response.contents)
|
|
58
|
-
return undefined;
|
|
59
|
-
return new __1.Video().load(response.data);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.default = YoutubeClient;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Channel, PlaylistCompact, VideoCompact } from "..";
|
|
2
|
-
export declare type SearchType = "video" | "channel" | "playlist" | "all";
|
|
3
|
-
export declare type SearchOptions = {
|
|
4
|
-
type: SearchType;
|
|
5
|
-
};
|
|
6
|
-
export declare type SearchResultType<T> = T extends {
|
|
7
|
-
type: "video";
|
|
8
|
-
} ? VideoCompact : T extends {
|
|
9
|
-
type: "channel";
|
|
10
|
-
} ? Channel : T extends {
|
|
11
|
-
type: "playlist";
|
|
12
|
-
} ? PlaylistCompact : VideoCompact | Channel | PlaylistCompact;
|
package/dist/classes/client.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Playlist, Video, SearchResult } from ".";
|
|
2
|
-
import { SearchResultType } from "./SearchResult";
|
|
3
|
-
export declare type SearchType = "video" | "channel" | "playlist" | "all";
|
|
4
|
-
export declare type SearchOptions = {
|
|
5
|
-
type: SearchType;
|
|
6
|
-
};
|
|
7
|
-
/** Youtube Client */
|
|
8
|
-
export default class Client {
|
|
9
|
-
/** Searches for videos / playlists / channels */
|
|
10
|
-
search<T extends SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResult<T>>;
|
|
11
|
-
/** Search for videos / playlists / channels and returns the first result */
|
|
12
|
-
findOne<T extends SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResultType<T> | undefined>;
|
|
13
|
-
/** Get playlist information and its videos by playlist id or URL */
|
|
14
|
-
getPlaylist(playlistIdOrUrl: string): Promise<Playlist | undefined>;
|
|
15
|
-
/** Get video information by video id or URL */
|
|
16
|
-
getVideo(videoIdOrUrl: string): Promise<Video | undefined>;
|
|
17
|
-
}
|
package/dist/classes/client.js
DELETED
|
@@ -1,57 +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 constants_1 = require("../constants");
|
|
13
|
-
const common_1 = require("../common");
|
|
14
|
-
const _1 = require(".");
|
|
15
|
-
/** Youtube Client */
|
|
16
|
-
class Client {
|
|
17
|
-
/** Searches for videos / playlists / channels */
|
|
18
|
-
search(query, searchOptions) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const options = Object.assign({ type: "all" }, searchOptions);
|
|
21
|
-
const result = new _1.SearchResult();
|
|
22
|
-
yield result.init(query, options);
|
|
23
|
-
return result;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/** Search for videos / playlists / channels and returns the first result */
|
|
27
|
-
findOne(query, searchOptions) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return (yield this.search(query, searchOptions)).shift();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/** Get playlist information and its videos by playlist id or URL */
|
|
33
|
-
getPlaylist(playlistIdOrUrl) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const playlistId = common_1.getQueryParameter(playlistIdOrUrl, "list");
|
|
36
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
37
|
-
data: { browseId: `VL${playlistId}` },
|
|
38
|
-
});
|
|
39
|
-
if (response.data.error || response.data.alerts)
|
|
40
|
-
return undefined;
|
|
41
|
-
return new _1.Playlist().load(response.data);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** Get video information by video id or URL */
|
|
45
|
-
getVideo(videoIdOrUrl) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const videoId = common_1.getQueryParameter(videoIdOrUrl, "v");
|
|
48
|
-
const response = yield common_1.http.get(`${constants_1.WATCH_END_POINT}`, {
|
|
49
|
-
params: { v: videoId, pbj: "1" },
|
|
50
|
-
});
|
|
51
|
-
if (!response.data[3].response.contents)
|
|
52
|
-
return undefined;
|
|
53
|
-
return new _1.Video().load(response.data);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.default = Client;
|
package/dist/classes/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { default as Client, SearchOptions, SearchType } from "./Client";
|
|
2
|
-
export { default as Base } from "./Base";
|
|
3
|
-
export { default as VideoCompact } from "./VideoCompact";
|
|
4
|
-
export { default as Thumbnails } from "./Thumbnails";
|
|
5
|
-
export { default as Channel } from "./Channel";
|
|
6
|
-
export { default as Comment } from "./Comment";
|
|
7
|
-
export { default as PlaylistCompact } from "./PlaylistCompact";
|
|
8
|
-
export { default as Playlist } from "./Playlist";
|
|
9
|
-
export { default as Video } from "./Video";
|
|
10
|
-
export { default as SearchResult } from "./SearchResult";
|
package/dist/classes/index.js
DELETED
|
@@ -1,26 +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.Video = exports.Playlist = exports.PlaylistCompact = exports.Comment = exports.Channel = exports.Thumbnails = exports.VideoCompact = 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 VideoCompact_1 = require("./VideoCompact");
|
|
12
|
-
Object.defineProperty(exports, "VideoCompact", { enumerable: true, get: function () { return __importDefault(VideoCompact_1).default; } });
|
|
13
|
-
var Thumbnails_1 = require("./Thumbnails");
|
|
14
|
-
Object.defineProperty(exports, "Thumbnails", { enumerable: true, get: function () { return __importDefault(Thumbnails_1).default; } });
|
|
15
|
-
var Channel_1 = require("./Channel");
|
|
16
|
-
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return __importDefault(Channel_1).default; } });
|
|
17
|
-
var Comment_1 = require("./Comment");
|
|
18
|
-
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return __importDefault(Comment_1).default; } });
|
|
19
|
-
var PlaylistCompact_1 = require("./PlaylistCompact");
|
|
20
|
-
Object.defineProperty(exports, "PlaylistCompact", { enumerable: true, get: function () { return __importDefault(PlaylistCompact_1).default; } });
|
|
21
|
-
var Playlist_1 = require("./Playlist");
|
|
22
|
-
Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return __importDefault(Playlist_1).default; } });
|
|
23
|
-
var Video_1 = require("./Video");
|
|
24
|
-
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return __importDefault(Video_1).default; } });
|
|
25
|
-
var SearchResult_1 = require("./SearchResult");
|
|
26
|
-
Object.defineProperty(exports, "SearchResult", { enumerable: true, get: function () { return __importDefault(SearchResult_1).default; } });
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extendsBuiltIn = void 0;
|
|
4
|
-
/** @hidden */
|
|
5
|
-
function extendsBuiltIn() {
|
|
6
|
-
return (target) => {
|
|
7
|
-
return class extends target {
|
|
8
|
-
constructor(...args) {
|
|
9
|
-
super(args);
|
|
10
|
-
Object.setPrototypeOf(this, target.prototype);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.extendsBuiltIn = extendsBuiltIn;
|
package/dist/common/helper.d.ts
DELETED
package/dist/common/helper.js
DELETED
|
@@ -1,39 +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
|
-
/** @hidden */
|
|
6
|
-
const getDuration = (s) => {
|
|
7
|
-
s = s.replace(/:/g, ".");
|
|
8
|
-
const spl = s.split(".");
|
|
9
|
-
if (spl.length === 0)
|
|
10
|
-
return +spl;
|
|
11
|
-
else {
|
|
12
|
-
const sumStr = spl.pop();
|
|
13
|
-
if (sumStr !== undefined) {
|
|
14
|
-
let sum = +sumStr;
|
|
15
|
-
if (spl.length === 1)
|
|
16
|
-
sum += +spl[0] * 60;
|
|
17
|
-
if (spl.length === 2) {
|
|
18
|
-
sum += +spl[1] * 60;
|
|
19
|
-
sum += +spl[0] * 3600;
|
|
20
|
-
}
|
|
21
|
-
return sum;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
exports.getDuration = getDuration;
|
|
29
|
-
/** @hidden */
|
|
30
|
-
const getQueryParameter = (url, queryName) => {
|
|
31
|
-
try {
|
|
32
|
-
return new url_1.URL(url).searchParams.get(queryName) || url;
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
/* not an URL */
|
|
36
|
-
return url;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.getQueryParameter = getQueryParameter;
|
package/dist/common/http.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** @ignore */ /** */
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import https from "https";
|
|
4
|
-
import { IncomingHttpHeaders } from "http";
|
|
5
|
-
import { YoutubeRawData } from "./types";
|
|
6
|
-
/** @hidden */
|
|
7
|
-
interface Options extends https.RequestOptions {
|
|
8
|
-
params: Record<string, any>;
|
|
9
|
-
data: any;
|
|
10
|
-
headers: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
/** @hidden */
|
|
13
|
-
interface Response<T = any> {
|
|
14
|
-
data: T;
|
|
15
|
-
headers: IncomingHttpHeaders;
|
|
16
|
-
status: number | undefined;
|
|
17
|
-
}
|
|
18
|
-
/** @hidden */
|
|
19
|
-
export default class HTTP {
|
|
20
|
-
/**
|
|
21
|
-
* Send request to Youtube
|
|
22
|
-
*/
|
|
23
|
-
static request(partialOptions: Partial<Options>): Promise<Response>;
|
|
24
|
-
/**
|
|
25
|
-
* Send GET request to Youtube
|
|
26
|
-
*/
|
|
27
|
-
static get(path: string, options: Partial<Options>): Promise<YoutubeRawData>;
|
|
28
|
-
/**
|
|
29
|
-
* Send POST request to Youtube
|
|
30
|
-
*/
|
|
31
|
-
static post(path: string, options: Partial<Options>): Promise<YoutubeRawData>;
|
|
32
|
-
}
|
|
33
|
-
export {};
|