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/common/http.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @ignore */ /** */
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
-
const https_1 = __importDefault(require("https"));
|
|
18
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
19
|
-
const querystring_1 = __importDefault(require("querystring"));
|
|
20
|
-
const constants_1 = require("../constants");
|
|
21
|
-
let cookie = "";
|
|
22
|
-
/** @hidden */
|
|
23
|
-
class HTTP {
|
|
24
|
-
/**
|
|
25
|
-
* Send request to Youtube
|
|
26
|
-
*/
|
|
27
|
-
static request(partialOptions) {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const options = Object.assign(Object.assign({ hostname: constants_1.BASE_URL, port: 443 }, partialOptions), { path: `${partialOptions.path}?${querystring_1.default.stringify(partialOptions.params)}`, headers: Object.assign({ "x-youtube-client-version": constants_1.INNERTUBE_CLIENT_VERSION, "x-youtube-client-name": "1", "content-type": "application/json", "accept-encoding": "gzip", cookie }, partialOptions.headers) });
|
|
30
|
-
let body = options.data || "";
|
|
31
|
-
if (options.data) {
|
|
32
|
-
if (options.headers["content-type"] === "application/x-www-form-urlencoded") {
|
|
33
|
-
body = querystring_1.default.stringify(body);
|
|
34
|
-
}
|
|
35
|
-
else if (options.headers["content-type"] === "application/json") {
|
|
36
|
-
body = JSON.stringify(body);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const request = https_1.default.request(options, (res) => {
|
|
40
|
-
var _a;
|
|
41
|
-
cookie = ((_a = res.headers["set-cookie"]) === null || _a === void 0 ? void 0 : _a.join(";")) || cookie;
|
|
42
|
-
if (res.headers["content-encoding"] === "gzip") {
|
|
43
|
-
const gunzip = zlib_1.default.createGunzip();
|
|
44
|
-
res.pipe(gunzip);
|
|
45
|
-
const buffer = [];
|
|
46
|
-
gunzip
|
|
47
|
-
.on("data", (data) => {
|
|
48
|
-
buffer.push(data.toString());
|
|
49
|
-
})
|
|
50
|
-
.on("end", () => {
|
|
51
|
-
const data = JSON.parse(buffer.join("").toString());
|
|
52
|
-
resolve({
|
|
53
|
-
status: res.statusCode,
|
|
54
|
-
headers: res.headers,
|
|
55
|
-
data,
|
|
56
|
-
});
|
|
57
|
-
})
|
|
58
|
-
.on("error", reject);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
let body = "";
|
|
62
|
-
res.on("data", (data) => {
|
|
63
|
-
body += data;
|
|
64
|
-
})
|
|
65
|
-
.on("end", () => {
|
|
66
|
-
const data = JSON.parse(body);
|
|
67
|
-
resolve({
|
|
68
|
-
status: res.statusCode,
|
|
69
|
-
headers: res.headers,
|
|
70
|
-
data,
|
|
71
|
-
});
|
|
72
|
-
})
|
|
73
|
-
.on("error", reject);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
request.on("error", reject);
|
|
77
|
-
request.write(body);
|
|
78
|
-
request.end();
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Send GET request to Youtube
|
|
83
|
-
*/
|
|
84
|
-
static get(path, options) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
options = Object.assign({ method: "GET", path }, options);
|
|
87
|
-
return yield HTTP.request(options);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Send POST request to Youtube
|
|
92
|
-
*/
|
|
93
|
-
static post(path, options) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
options = Object.assign(Object.assign({ method: "POST", path }, options), { params: Object.assign({ key: constants_1.INNERTUBE_API_KEY }, options.params), data: Object.assign({ context: {
|
|
96
|
-
client: {
|
|
97
|
-
clientName: "WEB",
|
|
98
|
-
clientVersion: constants_1.INNERTUBE_CLIENT_VERSION,
|
|
99
|
-
},
|
|
100
|
-
} }, options.data) });
|
|
101
|
-
return yield HTTP.request(options);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.default = HTTP;
|
package/dist/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COMMENT_END_POINT = exports.WATCH_END_POINT = exports.I_END_POINT = exports.BASE_URL = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_VERSION = void 0;
|
|
4
|
-
exports.INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
|
|
5
|
-
exports.INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
|
|
6
|
-
exports.BASE_URL = "www.youtube.com";
|
|
7
|
-
exports.I_END_POINT = "/youtubei/v1";
|
|
8
|
-
exports.WATCH_END_POINT = "/watch";
|
|
9
|
-
exports.COMMENT_END_POINT = "/comment_service_ajax";
|
package/dist/src/classes/Base.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { YoutubeRawData } from "../common";
|
|
2
|
-
import { Base, PlaylistCompact, Thumbnails, VideoCompact } from ".";
|
|
3
|
-
/** @hidden */
|
|
4
|
-
interface ChannelAttributes {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
url: string;
|
|
8
|
-
thumbnails: Thumbnails;
|
|
9
|
-
videoCount?: number;
|
|
10
|
-
}
|
|
11
|
-
/** Represents a Youtube Channel */
|
|
12
|
-
export default class Channel extends Base implements ChannelAttributes {
|
|
13
|
-
/** The channel's ID */
|
|
14
|
-
id: string;
|
|
15
|
-
/** The channel's name */
|
|
16
|
-
name: string;
|
|
17
|
-
/** The URL to the channel page */
|
|
18
|
-
url: string;
|
|
19
|
-
/** Thumbnails of the Channel with different sizes */
|
|
20
|
-
thumbnails: Thumbnails;
|
|
21
|
-
/** How many video does this channel have */
|
|
22
|
-
videoCount?: number;
|
|
23
|
-
/** @hidden */
|
|
24
|
-
constructor(channel?: Partial<ChannelAttributes>);
|
|
25
|
-
/** Get videos from current Channel */
|
|
26
|
-
getVideos(): Promise<VideoCompact[]>;
|
|
27
|
-
/** Get playlists from current channel */
|
|
28
|
-
getPlaylists(): Promise<PlaylistCompact[]>;
|
|
29
|
-
/**
|
|
30
|
-
* Load instance attributes from youtube raw data
|
|
31
|
-
*
|
|
32
|
-
* @param youtubeRawData raw object from youtubei
|
|
33
|
-
* @hidden
|
|
34
|
-
*/
|
|
35
|
-
load(youtubeRawData: YoutubeRawData): Channel;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
@@ -1,82 +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 common_1 = require("../common");
|
|
13
|
-
const _1 = require(".");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
|
-
/** Represents a Youtube Channel */
|
|
16
|
-
class Channel extends _1.Base {
|
|
17
|
-
/** @hidden */
|
|
18
|
-
constructor(channel = {}) {
|
|
19
|
-
super();
|
|
20
|
-
Object.assign(this, channel);
|
|
21
|
-
}
|
|
22
|
-
/** Get videos from current Channel */
|
|
23
|
-
getVideos() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
// TODO: Add continuation support
|
|
26
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
27
|
-
data: {
|
|
28
|
-
browseId: this.id,
|
|
29
|
-
params: "EgZ2aWRlb3M%3D",
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
return response.data.contents.twoColumnBrowseResultsRenderer.tabs[1].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer.items
|
|
33
|
-
.filter((i) => i.gridVideoRenderer)
|
|
34
|
-
.map((i) => new _1.VideoCompact().load(i.gridVideoRenderer));
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/** Get playlists from current channel */
|
|
38
|
-
getPlaylists() {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
// TODO: Add continuation support
|
|
41
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
42
|
-
data: {
|
|
43
|
-
browseId: this.id,
|
|
44
|
-
params: "EglwbGF5bGlzdHM%3D",
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
const section = response.data.contents.twoColumnBrowseResultsRenderer.tabs[2].tabRenderer.content
|
|
48
|
-
.sectionListRenderer;
|
|
49
|
-
let gridPlaylistRenderer;
|
|
50
|
-
// Has category
|
|
51
|
-
if ("shelfRenderer" in section.contents[0].itemSectionRenderer.contents[0]) {
|
|
52
|
-
gridPlaylistRenderer = section.contents
|
|
53
|
-
.map((c) => c.itemSectionRenderer.contents[0].shelfRenderer.content
|
|
54
|
-
.horizontalListRenderer.items)
|
|
55
|
-
.flat();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
gridPlaylistRenderer =
|
|
59
|
-
section.contents[0].itemSectionRenderer.contents[0].gridRenderer.items;
|
|
60
|
-
}
|
|
61
|
-
return gridPlaylistRenderer.map((i) => new _1.PlaylistCompact().load(i.gridPlaylistRenderer));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Load instance attributes from youtube raw data
|
|
66
|
-
*
|
|
67
|
-
* @param youtubeRawData raw object from youtubei
|
|
68
|
-
* @hidden
|
|
69
|
-
*/
|
|
70
|
-
load(youtubeRawData) {
|
|
71
|
-
var _a;
|
|
72
|
-
const { channelId, title, thumbnail, videoCountText, navigationEndpoint } = youtubeRawData;
|
|
73
|
-
const { browseId, canonicalBaseUrl } = navigationEndpoint.browseEndpoint;
|
|
74
|
-
this.id = channelId;
|
|
75
|
-
this.name = title.simpleText;
|
|
76
|
-
this.thumbnails = new _1.Thumbnails().load(thumbnail.thumbnails);
|
|
77
|
-
this.url = "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`);
|
|
78
|
-
this.videoCount = (_a = +(videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs[0].text.replace(/[^0-9]/g, ""))) !== null && _a !== void 0 ? _a : 0;
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.default = Channel;
|
|
@@ -1,14 +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
|
-
/** Youtube Client */
|
|
7
|
-
export default class Client {
|
|
8
|
-
/** Searches for videos / playlists / channels */
|
|
9
|
-
search<T extends SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResult<T>>;
|
|
10
|
-
/** Get playlist information and its videos by playlist id or URL */
|
|
11
|
-
getPlaylist(playlistIdOrUrl: string): Promise<Playlist | undefined>;
|
|
12
|
-
/** Get video information by video id or URL */
|
|
13
|
-
getVideo(videoIdOrUrl: string): Promise<Video | undefined>;
|
|
14
|
-
}
|
|
@@ -1,51 +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
|
-
/** Get playlist information and its videos by playlist id or URL */
|
|
27
|
-
getPlaylist(playlistIdOrUrl) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const playlistId = common_1.getQueryParameter(playlistIdOrUrl, "list");
|
|
30
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
31
|
-
data: { browseId: `VL${playlistId}` },
|
|
32
|
-
});
|
|
33
|
-
if (response.data.error || response.data.alerts)
|
|
34
|
-
return undefined;
|
|
35
|
-
return new _1.Playlist().load(response.data);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/** Get video information by video id or URL */
|
|
39
|
-
getVideo(videoIdOrUrl) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const videoId = common_1.getQueryParameter(videoIdOrUrl, "v");
|
|
42
|
-
const response = yield common_1.http.get(`${constants_1.WATCH_END_POINT}`, {
|
|
43
|
-
params: { v: videoId, pbj: "1" },
|
|
44
|
-
});
|
|
45
|
-
if (!response.data[3].response.contents)
|
|
46
|
-
return undefined;
|
|
47
|
-
return new _1.Video().load(response.data);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.default = Client;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Base, Channel, Video } from ".";
|
|
2
|
-
import { YoutubeRawData } from "../common";
|
|
3
|
-
/** @hidden */
|
|
4
|
-
interface CommentAttributes {
|
|
5
|
-
id: string;
|
|
6
|
-
video: Video;
|
|
7
|
-
author: Channel;
|
|
8
|
-
content: string;
|
|
9
|
-
publishDate: string;
|
|
10
|
-
likeCount: number;
|
|
11
|
-
isAuthorChannelOwner: boolean;
|
|
12
|
-
isPinnedComment: boolean;
|
|
13
|
-
replyCount: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Represents a Comment / Reply
|
|
17
|
-
*/
|
|
18
|
-
export default class Comment extends Base implements CommentAttributes {
|
|
19
|
-
/** The comment's ID */
|
|
20
|
-
id: string;
|
|
21
|
-
/** The video this comment belongs to */
|
|
22
|
-
video: Video;
|
|
23
|
-
/** The comment's author */
|
|
24
|
-
author: Channel;
|
|
25
|
-
/** The content of this comment */
|
|
26
|
-
content: string;
|
|
27
|
-
/** The publish date of the comment */
|
|
28
|
-
publishDate: string;
|
|
29
|
-
/** How many likes does this comment have */
|
|
30
|
-
likeCount: number;
|
|
31
|
-
/** Whether the comment is posted by the video uploader / owner */
|
|
32
|
-
isAuthorChannelOwner: boolean;
|
|
33
|
-
/** Whether the comment is pinned */
|
|
34
|
-
isPinnedComment: boolean;
|
|
35
|
-
/** Comment's reply count */
|
|
36
|
-
replyCount: number;
|
|
37
|
-
/** @hidden */
|
|
38
|
-
constructor(channel?: Partial<CommentAttributes>);
|
|
39
|
-
/**
|
|
40
|
-
* Load instance attributes from youtube raw data
|
|
41
|
-
*
|
|
42
|
-
* @param youtubeRawData raw object from youtubei
|
|
43
|
-
* @hidden
|
|
44
|
-
*/
|
|
45
|
-
load(data: YoutubeRawData): Comment;
|
|
46
|
-
/**
|
|
47
|
-
* URL to the video with this comment being highlighted (appears on top of the comment section)
|
|
48
|
-
*/
|
|
49
|
-
get url(): string;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const _1 = require(".");
|
|
4
|
-
/**
|
|
5
|
-
* Represents a Comment / Reply
|
|
6
|
-
*/
|
|
7
|
-
class Comment extends _1.Base {
|
|
8
|
-
// TODO: Add replies
|
|
9
|
-
/** @hidden */
|
|
10
|
-
constructor(channel = {}) {
|
|
11
|
-
super();
|
|
12
|
-
Object.assign(this, channel);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Load instance attributes from youtube raw data
|
|
16
|
-
*
|
|
17
|
-
* @param youtubeRawData raw object from youtubei
|
|
18
|
-
* @hidden
|
|
19
|
-
*/
|
|
20
|
-
load(data) {
|
|
21
|
-
const { authorText, authorThumbnail, authorEndpoint, contentText, publishedTimeText, commentId, likeCount, authorIsChannelOwner, pinnedCommentBadge, replyCount, } = data.comment.commentRenderer;
|
|
22
|
-
// Basic information
|
|
23
|
-
this.id = commentId;
|
|
24
|
-
this.content = contentText.runs.map((r) => r.text).join("");
|
|
25
|
-
this.publishDate = publishedTimeText.runs.shift().text;
|
|
26
|
-
this.likeCount = likeCount;
|
|
27
|
-
this.isAuthorChannelOwner = authorIsChannelOwner;
|
|
28
|
-
this.isPinnedComment = !!pinnedCommentBadge;
|
|
29
|
-
this.replyCount = replyCount;
|
|
30
|
-
// Author
|
|
31
|
-
const { browseId, canonicalBaseUrl } = authorEndpoint.browseEndpoint;
|
|
32
|
-
this.author = new _1.Channel({
|
|
33
|
-
id: browseId,
|
|
34
|
-
name: authorText.simpleText,
|
|
35
|
-
thumbnails: new _1.Thumbnails().load(authorThumbnail.thumbnails),
|
|
36
|
-
url: "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`),
|
|
37
|
-
});
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* URL to the video with this comment being highlighted (appears on top of the comment section)
|
|
42
|
-
*/
|
|
43
|
-
get url() {
|
|
44
|
-
return `https://www.youtube.com?watch=${this.video.id}&lc=${this.id}`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = Comment;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { YoutubeRawData } from "../common";
|
|
2
|
-
import Channel from "./Channel";
|
|
3
|
-
import VideoCompact from "./VideoCompact";
|
|
4
|
-
/** @hidden */
|
|
5
|
-
interface PlaylistAttributes {
|
|
6
|
-
id: string;
|
|
7
|
-
title: string;
|
|
8
|
-
videoCount: number;
|
|
9
|
-
viewCount: number;
|
|
10
|
-
lastUpdatedAt: string;
|
|
11
|
-
channel?: Channel;
|
|
12
|
-
videos: VideoCompact[];
|
|
13
|
-
}
|
|
14
|
-
/** Represents a Playlist, usually returned from `client.getPlaylist()` */
|
|
15
|
-
export default class Playlist implements PlaylistAttributes {
|
|
16
|
-
/** The playlist's ID */
|
|
17
|
-
id: string;
|
|
18
|
-
/** The title of this playlist */
|
|
19
|
-
title: string;
|
|
20
|
-
/** How many videos in this playlist */
|
|
21
|
-
videoCount: number;
|
|
22
|
-
/** How many viewers does this playlist have */
|
|
23
|
-
viewCount: number;
|
|
24
|
-
/** Last time this playlist is updated */
|
|
25
|
-
lastUpdatedAt: string;
|
|
26
|
-
/** The channel that made this playlist */
|
|
27
|
-
channel?: Channel;
|
|
28
|
-
/** Videos in the playlist */
|
|
29
|
-
videos: VideoCompact[];
|
|
30
|
-
private _continuation;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
constructor(playlist?: Partial<Playlist>);
|
|
33
|
-
/**
|
|
34
|
-
* Load instance attributes from youtube raw data
|
|
35
|
-
*
|
|
36
|
-
* @param youtubeRawData raw object from youtubei
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
load(youtubeRawData: YoutubeRawData): Playlist;
|
|
40
|
-
/**
|
|
41
|
-
* Load next 100 videos of the playlist
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```js
|
|
45
|
-
* const playlist = await youtube.getPlaylist(PLAYLIST_ID);
|
|
46
|
-
* console.log(playlist.videos) // first 100 videos
|
|
47
|
-
*
|
|
48
|
-
* let newVideos = await playlist.next();
|
|
49
|
-
* console.log(newVideos) // 100 loaded videos
|
|
50
|
-
* console.log(playlist.videos) // first 200 videos
|
|
51
|
-
*
|
|
52
|
-
* await playlist.next(0); // load the rest of the videos in the playlist
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @param count How many times to load the next videos. Set 0 to load all videos (might take a while on a large playlist!)
|
|
56
|
-
*/
|
|
57
|
-
next(count?: number): Promise<VideoCompact[]>;
|
|
58
|
-
/**
|
|
59
|
-
* Get compact videos
|
|
60
|
-
*
|
|
61
|
-
* @param playlistContents raw object from youtubei
|
|
62
|
-
*/
|
|
63
|
-
private getVideos;
|
|
64
|
-
private getSideBarInfo;
|
|
65
|
-
}
|
|
66
|
-
export {};
|
|
@@ -1,133 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const _1 = require(".");
|
|
16
|
-
const common_1 = require("../common");
|
|
17
|
-
const constants_1 = require("../constants");
|
|
18
|
-
const Channel_1 = __importDefault(require("./Channel"));
|
|
19
|
-
const VideoCompact_1 = __importDefault(require("./VideoCompact"));
|
|
20
|
-
/** Represents a Playlist, usually returned from `client.getPlaylist()` */
|
|
21
|
-
class Playlist {
|
|
22
|
-
/** @hidden */
|
|
23
|
-
constructor(playlist = {}) {
|
|
24
|
-
Object.assign(this, playlist);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Load instance attributes from youtube raw data
|
|
28
|
-
*
|
|
29
|
-
* @param youtubeRawData raw object from youtubei
|
|
30
|
-
* @hidden
|
|
31
|
-
*/
|
|
32
|
-
load(youtubeRawData) {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
const sidebarRenderer = youtubeRawData.sidebar.playlistSidebarRenderer.items;
|
|
35
|
-
const primaryRenderer = sidebarRenderer[0].playlistSidebarPrimaryInfoRenderer;
|
|
36
|
-
// Basic information
|
|
37
|
-
this.id = primaryRenderer.title.runs[0].navigationEndpoint.watchEndpoint.playlistId;
|
|
38
|
-
this.title = primaryRenderer.title.runs[0].text;
|
|
39
|
-
const { stats } = primaryRenderer;
|
|
40
|
-
if (primaryRenderer.stats.length === 3) {
|
|
41
|
-
this.videoCount = this.getSideBarInfo(stats[0], true);
|
|
42
|
-
this.viewCount = this.getSideBarInfo(stats[1], true);
|
|
43
|
-
this.lastUpdatedAt = this.getSideBarInfo(stats[2], false);
|
|
44
|
-
}
|
|
45
|
-
else if (stats.length === 2) {
|
|
46
|
-
this.videoCount = this.getSideBarInfo(stats[0], true);
|
|
47
|
-
this.lastUpdatedAt = this.getSideBarInfo(stats[1], false);
|
|
48
|
-
}
|
|
49
|
-
// Videos
|
|
50
|
-
const playlistContents = youtubeRawData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
|
|
51
|
-
.sectionListRenderer.contents[0].itemSectionRenderer.contents[0]
|
|
52
|
-
.playlistVideoListRenderer.contents;
|
|
53
|
-
const videos = this.getVideos(playlistContents);
|
|
54
|
-
// Video Continuation Token
|
|
55
|
-
this._continuation = (_a = playlistContents[100]) === null || _a === void 0 ? void 0 : _a.continuationItemRenderer.continuationEndpoint.continuationCommand.token;
|
|
56
|
-
this.videos = videos;
|
|
57
|
-
// Channel
|
|
58
|
-
const videoOwner = ((_b = sidebarRenderer[1]) === null || _b === void 0 ? void 0 : _b.playlistSidebarSecondaryInfoRenderer.videoOwner) || undefined;
|
|
59
|
-
if (videoOwner) {
|
|
60
|
-
const { title, thumbnail } = videoOwner.videoOwnerRenderer;
|
|
61
|
-
this.channel = new Channel_1.default({
|
|
62
|
-
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
63
|
-
name: title.runs[0].text,
|
|
64
|
-
thumbnails: new _1.Thumbnails().load(thumbnail.thumbnails),
|
|
65
|
-
url: "https://www.youtube.com" +
|
|
66
|
-
title.runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Load next 100 videos of the playlist
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```js
|
|
76
|
-
* const playlist = await youtube.getPlaylist(PLAYLIST_ID);
|
|
77
|
-
* console.log(playlist.videos) // first 100 videos
|
|
78
|
-
*
|
|
79
|
-
* let newVideos = await playlist.next();
|
|
80
|
-
* console.log(newVideos) // 100 loaded videos
|
|
81
|
-
* console.log(playlist.videos) // first 200 videos
|
|
82
|
-
*
|
|
83
|
-
* await playlist.next(0); // load the rest of the videos in the playlist
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @param count How many times to load the next videos. Set 0 to load all videos (might take a while on a large playlist!)
|
|
87
|
-
*/
|
|
88
|
-
next(count = 1) {
|
|
89
|
-
var _a;
|
|
90
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
const newVideos = [];
|
|
92
|
-
for (let i = 0; i < count || count == 0; i++) {
|
|
93
|
-
if (!this._continuation)
|
|
94
|
-
break;
|
|
95
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
96
|
-
data: { continuation: this._continuation },
|
|
97
|
-
});
|
|
98
|
-
const playlistContents = response.data.onResponseReceivedActions[0].appendContinuationItemsAction
|
|
99
|
-
.continuationItems;
|
|
100
|
-
newVideos.push(...this.getVideos(playlistContents));
|
|
101
|
-
this._continuation = (_a = playlistContents[100]) === null || _a === void 0 ? void 0 : _a.continuationItemRenderer.continuationEndpoint.continuationCommand.token;
|
|
102
|
-
}
|
|
103
|
-
this.videos.push(...newVideos);
|
|
104
|
-
return newVideos;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get compact videos
|
|
109
|
-
*
|
|
110
|
-
* @param playlistContents raw object from youtubei
|
|
111
|
-
*/
|
|
112
|
-
getVideos(playlistContents) {
|
|
113
|
-
const videosRenderer = playlistContents.map((c) => c.playlistVideoRenderer);
|
|
114
|
-
const videos = [];
|
|
115
|
-
for (const videoRenderer of videosRenderer) {
|
|
116
|
-
if (!videoRenderer)
|
|
117
|
-
continue;
|
|
118
|
-
videos.push(new VideoCompact_1.default().load(videoRenderer));
|
|
119
|
-
}
|
|
120
|
-
return videos;
|
|
121
|
-
}
|
|
122
|
-
getSideBarInfo(stats, parseInt) {
|
|
123
|
-
let data;
|
|
124
|
-
if ("runs" in stats)
|
|
125
|
-
data = stats.runs.map((r) => r.text).join("");
|
|
126
|
-
else
|
|
127
|
-
data = stats.simpleText.replace(/[^0-9]/g, "");
|
|
128
|
-
if (parseInt)
|
|
129
|
-
data = +data.replace(/[^0-9]/g, "");
|
|
130
|
-
return data;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.default = Playlist;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Thumbnails } from ".";
|
|
2
|
-
import { YoutubeRawData } from "../common";
|
|
3
|
-
import Base from "./Base";
|
|
4
|
-
import Channel from "./Channel";
|
|
5
|
-
/** @hidden */
|
|
6
|
-
interface PlaylistCompactAttributes {
|
|
7
|
-
id: string;
|
|
8
|
-
title: string;
|
|
9
|
-
thumbnails: Thumbnails;
|
|
10
|
-
channel?: Channel;
|
|
11
|
-
videoCount: number;
|
|
12
|
-
}
|
|
13
|
-
/** Represents a Compact Playlist (e.g. from search result, upNext / related of a video) */
|
|
14
|
-
export default class PlaylistCompact extends Base implements PlaylistCompactAttributes {
|
|
15
|
-
/** The playlist's ID */
|
|
16
|
-
id: string;
|
|
17
|
-
/** The playlist's title */
|
|
18
|
-
title: string;
|
|
19
|
-
/** Thumbnails of the playlist with different sizes */
|
|
20
|
-
thumbnails: Thumbnails;
|
|
21
|
-
/** The channel that made this playlist */
|
|
22
|
-
channel?: Channel;
|
|
23
|
-
/** How many videos in this playlist */
|
|
24
|
-
videoCount: number;
|
|
25
|
-
/** @hidden */
|
|
26
|
-
constructor(playlist?: Partial<PlaylistCompactAttributes>);
|
|
27
|
-
/**
|
|
28
|
-
* Load instance attributes from youtube raw data
|
|
29
|
-
*
|
|
30
|
-
* @param youtubeRawData raw object from youtubei
|
|
31
|
-
* @hidden
|
|
32
|
-
*/
|
|
33
|
-
load(youtubeRawData: YoutubeRawData): PlaylistCompact;
|
|
34
|
-
}
|
|
35
|
-
export {};
|