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,98 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (_) try {
|
|
30
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
import { Base } from "../Base";
|
|
51
|
+
import { VideoCompactParser } from "./VideoCompactParser";
|
|
52
|
+
/** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
|
|
53
|
+
var VideoCompact = /** @class */ (function (_super) {
|
|
54
|
+
__extends(VideoCompact, _super);
|
|
55
|
+
/** @hidden */
|
|
56
|
+
function VideoCompact(attr) {
|
|
57
|
+
var _this = _super.call(this, attr.client) || this;
|
|
58
|
+
Object.assign(_this, attr);
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
Object.defineProperty(VideoCompact.prototype, "isPrivateOrDeleted", {
|
|
62
|
+
/** Whether this video is private / deleted or not, only useful in playlist's videos */
|
|
63
|
+
get: function () {
|
|
64
|
+
return !this.duration;
|
|
65
|
+
},
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: true
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Load this instance with raw data from Youtube
|
|
71
|
+
*
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
VideoCompact.prototype.load = function (data) {
|
|
75
|
+
VideoCompactParser.loadVideoCompact(this, data);
|
|
76
|
+
return this;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Get {@link Video} object based on current video id
|
|
80
|
+
*
|
|
81
|
+
* Equivalent to
|
|
82
|
+
* ```js
|
|
83
|
+
* client.getVideo(videoCompact.id);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
VideoCompact.prototype.getVideo = function () {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0: return [4 /*yield*/, this.client.getVideo(this.id)];
|
|
91
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
return VideoCompact;
|
|
97
|
+
}(Base));
|
|
98
|
+
export { VideoCompact };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getDuration, stripToInt } from "../../common";
|
|
2
|
+
import { BaseChannel } from "../BaseChannel";
|
|
3
|
+
import { Thumbnails } from "../Thumbnails";
|
|
4
|
+
var VideoCompactParser = /** @class */ (function () {
|
|
5
|
+
function VideoCompactParser() {
|
|
6
|
+
}
|
|
7
|
+
VideoCompactParser.loadVideoCompact = function (target, data) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
var videoId = data.videoId, title = data.title, lengthText = data.lengthText, thumbnail = data.thumbnail, ownerText = data.ownerText, shortBylineText = data.shortBylineText, publishedTimeText = data.publishedTimeText, viewCountText = data.viewCountText, badges = data.badges, thumbnailOverlays = data.thumbnailOverlays, channelThumbnailSupportedRenderers = data.channelThumbnailSupportedRenderers, detailedMetadataSnippets = data.detailedMetadataSnippets;
|
|
10
|
+
target.id = videoId;
|
|
11
|
+
target.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
|
|
12
|
+
target.thumbnails = new Thumbnails().load(thumbnail.thumbnails);
|
|
13
|
+
target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
14
|
+
target.description =
|
|
15
|
+
(detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs.map(function (r) { return r.text; }).join("")) || "";
|
|
16
|
+
target.duration =
|
|
17
|
+
getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_b = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _b === void 0 ? void 0 : _b.text.simpleText) ||
|
|
18
|
+
"") || null;
|
|
19
|
+
target.isLive = !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW");
|
|
20
|
+
// Channel
|
|
21
|
+
if (ownerText || shortBylineText) {
|
|
22
|
+
var browseId = (ownerText || shortBylineText).runs[0].navigationEndpoint.browseEndpoint.browseId;
|
|
23
|
+
var thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
|
|
24
|
+
target.channel = new BaseChannel({
|
|
25
|
+
id: browseId,
|
|
26
|
+
name: (ownerText || shortBylineText).runs[0].text,
|
|
27
|
+
thumbnails: thumbnails ? new Thumbnails().load(thumbnails) : undefined,
|
|
28
|
+
client: target.client,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
target.viewCount = stripToInt((viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) || (viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text));
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
return VideoCompactParser;
|
|
35
|
+
}());
|
|
36
|
+
export { VideoCompactParser };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./Base";
|
|
2
|
+
export * from "./BaseChannel";
|
|
3
|
+
export * from "./BaseVideo";
|
|
4
|
+
export * from "./Channel";
|
|
5
|
+
export * from "./Chat";
|
|
6
|
+
export * from "./Client";
|
|
7
|
+
export * from "./Comment";
|
|
8
|
+
export * from "./Continuable";
|
|
9
|
+
export * from "./LiveVideo";
|
|
10
|
+
export * from "./MixPlaylist";
|
|
11
|
+
export * from "./Playlist";
|
|
12
|
+
export * from "./PlaylistCompact";
|
|
13
|
+
export * from "./Reply";
|
|
14
|
+
export * from "./SearchResult";
|
|
15
|
+
export * from "./Thumbnails";
|
|
16
|
+
export * from "./Video";
|
|
17
|
+
export * from "./VideoCompact";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
export function extendsBuiltIn() {
|
|
15
|
+
return function (target) {
|
|
16
|
+
return /** @class */ (function (_super) {
|
|
17
|
+
__extends(class_1, _super);
|
|
18
|
+
function class_1() {
|
|
19
|
+
var args = [];
|
|
20
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
21
|
+
args[_i] = arguments[_i];
|
|
22
|
+
}
|
|
23
|
+
var _this = _super.call(this, args) || this;
|
|
24
|
+
Object.setPrototypeOf(_this, target.prototype);
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
return class_1;
|
|
28
|
+
}(target));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
12
|
+
export var getDuration = function (s) {
|
|
13
|
+
s = s.replace(/:/g, ".");
|
|
14
|
+
var spl = s.split(".");
|
|
15
|
+
if (spl.length === 0)
|
|
16
|
+
return +spl;
|
|
17
|
+
else {
|
|
18
|
+
var sumStr = spl.pop();
|
|
19
|
+
var sum = +sumStr;
|
|
20
|
+
if (spl.length === 1)
|
|
21
|
+
sum += +spl[0] * 60;
|
|
22
|
+
if (spl.length === 2) {
|
|
23
|
+
sum += +spl[1] * 60;
|
|
24
|
+
sum += +spl[0] * 3600;
|
|
25
|
+
}
|
|
26
|
+
return sum;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export var stripToInt = function (string) {
|
|
30
|
+
if (!string)
|
|
31
|
+
return null;
|
|
32
|
+
return +string.replace(/[^0-9]/g, "");
|
|
33
|
+
};
|
|
34
|
+
export var getContinuationFromItems = function (items, accessors) {
|
|
35
|
+
var e_1, _a;
|
|
36
|
+
if (accessors === void 0) { accessors = ["continuationEndpoint"]; }
|
|
37
|
+
var continuation = items[items.length - 1];
|
|
38
|
+
var renderer = continuation === null || continuation === void 0 ? void 0 : continuation.continuationItemRenderer;
|
|
39
|
+
if (!renderer)
|
|
40
|
+
return;
|
|
41
|
+
var current = renderer;
|
|
42
|
+
try {
|
|
43
|
+
for (var accessors_1 = __values(accessors), accessors_1_1 = accessors_1.next(); !accessors_1_1.done; accessors_1_1 = accessors_1.next()) {
|
|
44
|
+
var accessor = accessors_1_1.value;
|
|
45
|
+
current = current[accessor];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
49
|
+
finally {
|
|
50
|
+
try {
|
|
51
|
+
if (accessors_1_1 && !accessors_1_1.done && (_a = accessors_1.return)) _a.call(accessors_1);
|
|
52
|
+
}
|
|
53
|
+
finally { if (e_1) throw e_1.error; }
|
|
54
|
+
}
|
|
55
|
+
return current.continuationCommand.token;
|
|
56
|
+
};
|
|
57
|
+
export var mapFilter = function (items, key) {
|
|
58
|
+
return items
|
|
59
|
+
.filter(function (item) { return item[key]; })
|
|
60
|
+
.map(function (item) { return item[key]; });
|
|
61
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
2
|
+
export var applyMixins = function (derivedCtor, baseCtors) {
|
|
3
|
+
baseCtors.forEach(function (baseCtor) {
|
|
4
|
+
Object.getOwnPropertyNames(baseCtor.prototype).forEach(function (name) {
|
|
5
|
+
if (name !== "constructor") {
|
|
6
|
+
derivedCtor.prototype[name] = baseCtor.prototype[name];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
|
|
2
|
+
export var INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
|
|
3
|
+
export var BASE_URL = "www.youtube.com";
|
|
4
|
+
export var I_END_POINT = "/youtubei/v1";
|
|
5
|
+
export var LIVE_CHAT_END_POINT = I_END_POINT + "/live_chat/get_live_chat";
|
|
6
|
+
export var WATCH_END_POINT = "/watch";
|
|
7
|
+
export var COMMENT_END_POINT = "/comment_service_ajax";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./classes";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client } from "../Client";
|
|
2
|
+
/** @hidden */
|
|
3
|
+
export interface BaseProperties {
|
|
4
|
+
client: Client;
|
|
5
|
+
}
|
|
6
|
+
export declare class Base implements BaseProperties {
|
|
7
|
+
/** An instance of {@link Client} */
|
|
8
|
+
client: Client;
|
|
9
|
+
/** @hidden */
|
|
10
|
+
constructor(client: Client);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Base";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { Thumbnails } from "../Thumbnails";
|
|
4
|
+
import { ChannelPlaylists } from "./ChannelPlaylists";
|
|
5
|
+
import { ChannelVideos } from "./ChannelVideos";
|
|
6
|
+
/** @hidden */
|
|
7
|
+
export interface BaseChannelProperties extends BaseProperties {
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
thumbnails?: Thumbnails;
|
|
11
|
+
videoCount?: number;
|
|
12
|
+
subscriberCount?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Represents a Youtube Channel */
|
|
15
|
+
export declare class BaseChannel extends Base implements BaseChannelProperties {
|
|
16
|
+
id: string;
|
|
17
|
+
/** The channel's name */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Thumbnails of this Channel */
|
|
20
|
+
thumbnails?: Thumbnails;
|
|
21
|
+
/** How many video does this channel have */
|
|
22
|
+
videoCount?: number;
|
|
23
|
+
/**
|
|
24
|
+
* How many subscriber does this channel have,
|
|
25
|
+
*
|
|
26
|
+
* This is not the exact amount, but a literal string like `"1.95M subscribers"`
|
|
27
|
+
*/
|
|
28
|
+
subscriberCount?: string;
|
|
29
|
+
/** Continuable of videos */
|
|
30
|
+
videos: ChannelVideos;
|
|
31
|
+
/** Continuable of playlists */
|
|
32
|
+
playlists: ChannelPlaylists;
|
|
33
|
+
/** @hidden */
|
|
34
|
+
constructor(attr: BaseChannelProperties);
|
|
35
|
+
/** The URL of the channel page */
|
|
36
|
+
get url(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Load this instance with raw data from Youtube
|
|
39
|
+
*
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
load(data: YoutubeRawData): BaseChannel;
|
|
43
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { BaseChannel } from "./BaseChannel";
|
|
3
|
+
export declare class BaseChannelParser {
|
|
4
|
+
static loadBaseChannel(target: BaseChannel, data: YoutubeRawData): BaseChannel;
|
|
5
|
+
/** Parse tab data from request, tab name is ignored if it's a continuation data */
|
|
6
|
+
static parseTabData(name: "videos" | "playlists", data: YoutubeRawData): YoutubeRawData;
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
|
|
2
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
3
|
+
import { BaseChannel } from "./BaseChannel";
|
|
4
|
+
declare type ConstructorParams = ContinuableConstructorParams & {
|
|
5
|
+
channel?: BaseChannel;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* {@link Continuable} of playlists inside a {@link BaseChannel}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
13
|
+
* await channel.playlists.next();
|
|
14
|
+
* console.log(channel.playlists.items) // first 30 playlists
|
|
15
|
+
*
|
|
16
|
+
* let newPlaylists = await channel.playlists.next();
|
|
17
|
+
* console.log(newPlaylists) // 30 loaded playlists
|
|
18
|
+
* console.log(channel.playlists.items) // first 60 playlists
|
|
19
|
+
*
|
|
20
|
+
* await channel.playlists.next(0); // load the rest of the playlists in the channel
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class ChannelPlaylists extends Continuable<PlaylistCompact> {
|
|
24
|
+
/** The channel this playlists belongs to */
|
|
25
|
+
channel?: BaseChannel;
|
|
26
|
+
/** @hidden */
|
|
27
|
+
constructor({ client, channel }: ConstructorParams);
|
|
28
|
+
protected fetch(): Promise<FetchResult<PlaylistCompact>>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
|
|
2
|
+
import { VideoCompact } from "../VideoCompact";
|
|
3
|
+
import { BaseChannel } from "./BaseChannel";
|
|
4
|
+
declare type ConstructorParams = ContinuableConstructorParams & {
|
|
5
|
+
channel?: BaseChannel;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* {@link Continuable} of videos inside a {@link BaseChannel}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
13
|
+
* await channel.videos.next();
|
|
14
|
+
* console.log(channel.videos.items) // first 30 videos
|
|
15
|
+
*
|
|
16
|
+
* let newVideos = await channel.videos.next();
|
|
17
|
+
* console.log(newVideos) // 30 loaded videos
|
|
18
|
+
* console.log(channel.videos.items) // first 60 videos
|
|
19
|
+
*
|
|
20
|
+
* await channel.videos.next(0); // load the rest of the videos in the channel
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class ChannelVideos extends Continuable<VideoCompact> {
|
|
24
|
+
/** The channel this videos belongs to */
|
|
25
|
+
channel?: BaseChannel;
|
|
26
|
+
/** @hidden */
|
|
27
|
+
constructor({ client, channel }: ConstructorParams);
|
|
28
|
+
protected fetch(): Promise<FetchResult<VideoCompact>>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { BaseChannel } from "../BaseChannel";
|
|
4
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
5
|
+
import { Thumbnails } from "../Thumbnails";
|
|
6
|
+
import { VideoCompact } from "../VideoCompact";
|
|
7
|
+
import { VideoRelated } from "./VideoRelated";
|
|
8
|
+
/** @hidden */
|
|
9
|
+
export interface BaseVideoProperties extends BaseProperties {
|
|
10
|
+
id?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
thumbnails?: Thumbnails;
|
|
13
|
+
description?: string;
|
|
14
|
+
channel?: BaseChannel;
|
|
15
|
+
uploadDate?: string;
|
|
16
|
+
viewCount?: number | null;
|
|
17
|
+
likeCount?: number | null;
|
|
18
|
+
isLiveContent?: boolean;
|
|
19
|
+
tags?: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Represents a Video */
|
|
22
|
+
export declare class BaseVideo extends Base implements BaseVideoProperties {
|
|
23
|
+
id: string;
|
|
24
|
+
/** The title of this video */
|
|
25
|
+
title: string;
|
|
26
|
+
/** Thumbnails of the video with different sizes */
|
|
27
|
+
thumbnails: Thumbnails;
|
|
28
|
+
/** The description of this video */
|
|
29
|
+
description: string;
|
|
30
|
+
/** The channel that uploaded this video */
|
|
31
|
+
channel: BaseChannel;
|
|
32
|
+
/** The date this video is uploaded at */
|
|
33
|
+
uploadDate: string;
|
|
34
|
+
/** How many view does this video have, null if the view count is hidden */
|
|
35
|
+
viewCount: number | null;
|
|
36
|
+
/** How many like does this video have, null if the like count is hidden */
|
|
37
|
+
likeCount: number | null;
|
|
38
|
+
/** Whether this video is a live content or not */
|
|
39
|
+
isLiveContent: boolean;
|
|
40
|
+
/** The tags of this video */
|
|
41
|
+
tags: string[];
|
|
42
|
+
/** Continuable of videos / playlists related to this video */
|
|
43
|
+
related: VideoRelated;
|
|
44
|
+
/** @hidden */
|
|
45
|
+
constructor(attr: BaseVideoProperties);
|
|
46
|
+
/**
|
|
47
|
+
* Load this instance with raw data from Youtube
|
|
48
|
+
*
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
load(data: YoutubeRawData): BaseVideo;
|
|
52
|
+
/**
|
|
53
|
+
* Video / playlist to play next after this video, alias to
|
|
54
|
+
* ```js
|
|
55
|
+
* video.related.items[0]
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
get upNext(): VideoCompact | PlaylistCompact;
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Client } from "../Client";
|
|
3
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
4
|
+
import { VideoCompact } from "../VideoCompact";
|
|
5
|
+
import { BaseVideo } from "./BaseVideo";
|
|
6
|
+
export declare class BaseVideoParser {
|
|
7
|
+
static loadBaseVideo(target: BaseVideo, data: YoutubeRawData): BaseVideo;
|
|
8
|
+
static parseRelated(data: YoutubeRawData, client: Client): (VideoCompact | PlaylistCompact)[];
|
|
9
|
+
static parseContinuation(data: YoutubeRawData): string | undefined;
|
|
10
|
+
static parseRawData(data: YoutubeRawData): YoutubeRawData;
|
|
11
|
+
private static parseCompactRenderer;
|
|
12
|
+
private static parseRelatedFromSecondaryContent;
|
|
13
|
+
private static parseButtonRenderer;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Client } from "../Client";
|
|
2
|
+
import { Continuable, FetchResult } from "../Continuable";
|
|
3
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
4
|
+
import { VideoCompact } from "../VideoCompact";
|
|
5
|
+
import { BaseVideo } from "./BaseVideo";
|
|
6
|
+
/** @hidden */
|
|
7
|
+
interface ConstructorParams {
|
|
8
|
+
client: Client;
|
|
9
|
+
video?: BaseVideo;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* {@link Continuable} of related videos inside a Video
|
|
13
|
+
*/
|
|
14
|
+
export declare class VideoRelated extends Continuable<VideoCompact | PlaylistCompact> {
|
|
15
|
+
/** The video this list of related videos belongs to */
|
|
16
|
+
video?: BaseVideo;
|
|
17
|
+
/** @hidden */
|
|
18
|
+
constructor({ video, client }: ConstructorParams);
|
|
19
|
+
protected fetch(): Promise<FetchResult<VideoCompact | PlaylistCompact>>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { BaseChannel, BaseChannelProperties } from "../BaseChannel";
|
|
3
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
4
|
+
import { Thumbnails } from "../Thumbnails";
|
|
5
|
+
import { VideoCompact } from "../VideoCompact";
|
|
6
|
+
export interface Shelf {
|
|
7
|
+
title: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
items: BaseChannel[] | VideoCompact[] | PlaylistCompact[];
|
|
10
|
+
}
|
|
11
|
+
/** @hidden */
|
|
12
|
+
interface ChannelProperties extends BaseChannelProperties {
|
|
13
|
+
banner?: Thumbnails;
|
|
14
|
+
tvBanner?: Thumbnails;
|
|
15
|
+
mobileBanner?: Thumbnails;
|
|
16
|
+
shelves?: Shelf[];
|
|
17
|
+
}
|
|
18
|
+
/** Represents a Youtube Channel */
|
|
19
|
+
export declare class Channel extends BaseChannel implements ChannelProperties {
|
|
20
|
+
banner: Thumbnails;
|
|
21
|
+
mobileBanner: Thumbnails;
|
|
22
|
+
tvBanner: Thumbnails;
|
|
23
|
+
shelves: Shelf[];
|
|
24
|
+
/** @hidden */
|
|
25
|
+
constructor(attr: ChannelProperties);
|
|
26
|
+
/**
|
|
27
|
+
* Load this instance with raw data from Youtube
|
|
28
|
+
*
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
load(data: YoutubeRawData): Channel;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Channel, Shelf } from "./Channel";
|
|
3
|
+
export declare class ChannelParser {
|
|
4
|
+
static loadChannel(target: Channel, data: YoutubeRawData): Channel;
|
|
5
|
+
static parseShelves(target: Channel, data: YoutubeRawData): Shelf[];
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { YoutubeRawData } from "../../common";
|
|
2
|
+
import { Base, BaseProperties } from "../Base";
|
|
3
|
+
import { BaseChannel } from "../BaseChannel";
|
|
4
|
+
import { Video } from "../Video";
|
|
5
|
+
/** @hidden */
|
|
6
|
+
interface ChatProperties extends BaseProperties {
|
|
7
|
+
id?: string;
|
|
8
|
+
video?: Video;
|
|
9
|
+
author?: BaseChannel;
|
|
10
|
+
message?: string;
|
|
11
|
+
timestamp?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Represents a chat in a live stream */
|
|
14
|
+
export declare class Chat extends Base implements ChatProperties {
|
|
15
|
+
id?: string;
|
|
16
|
+
/** The video this chat belongs to */
|
|
17
|
+
video: Video;
|
|
18
|
+
/** The chat's author */
|
|
19
|
+
author: BaseChannel;
|
|
20
|
+
/** The message of this chat */
|
|
21
|
+
message: string;
|
|
22
|
+
/** Timestamp in usec / microsecond */
|
|
23
|
+
timestamp: number;
|
|
24
|
+
/** @hidden */
|
|
25
|
+
constructor(attr: ChatProperties);
|
|
26
|
+
/**
|
|
27
|
+
* Load this instance with raw data from Youtube
|
|
28
|
+
*
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
load(data: YoutubeRawData): Chat;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RequestInit } from "node-fetch";
|
|
2
|
+
import { Channel } from "../Channel";
|
|
3
|
+
import { LiveVideo } from "../LiveVideo";
|
|
4
|
+
import { MixPlaylist } from "../MixPlaylist";
|
|
5
|
+
import { Playlist } from "../Playlist";
|
|
6
|
+
import { SearchOptions, SearchResult, SearchResultItem } from "../SearchResult";
|
|
7
|
+
import { Video } from "../Video";
|
|
8
|
+
import { HTTP } from "./HTTP";
|
|
9
|
+
export declare type ClientOptions = {
|
|
10
|
+
initialCookie: string;
|
|
11
|
+
/** Optional options for http client */
|
|
12
|
+
fetchOptions: Partial<RequestInit>;
|
|
13
|
+
/** Optional options passed when sending a request to youtube (context.client) */
|
|
14
|
+
youtubeClientOptions: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/** Youtube Client */
|
|
17
|
+
export declare class Client {
|
|
18
|
+
/** @hidden */
|
|
19
|
+
http: HTTP;
|
|
20
|
+
constructor(options?: Partial<ClientOptions>);
|
|
21
|
+
/**
|
|
22
|
+
* Searches for videos / playlists / channels
|
|
23
|
+
*
|
|
24
|
+
* @param query The search query
|
|
25
|
+
* @param options Search options
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
search<T extends SearchOptions>(query: string, options?: T): Promise<SearchResult<T["type"]>>;
|
|
29
|
+
/**
|
|
30
|
+
* Search for videos / playlists / channels and returns the first result
|
|
31
|
+
*
|
|
32
|
+
* @return Can be {@link VideoCompact} | {@link PlaylistCompact} | {@link BaseChannel} | `undefined`
|
|
33
|
+
*/
|
|
34
|
+
findOne<T extends SearchOptions>(query: string, options?: T): Promise<SearchResultItem<T["type"]> | undefined>;
|
|
35
|
+
/** Get playlist information and its videos by playlist id or URL */
|
|
36
|
+
getPlaylist<T extends Playlist | MixPlaylist | undefined>(playlistId: string): Promise<T>;
|
|
37
|
+
/** Get video information by video id or URL */
|
|
38
|
+
getVideo<T extends Video | LiveVideo | undefined>(videoId: string): Promise<T>;
|
|
39
|
+
/** Get channel information by channel id+ */
|
|
40
|
+
getChannel(channelId: string): Promise<Channel | undefined>;
|
|
41
|
+
}
|