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,109 @@
|
|
|
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 { getContinuationFromItems, mapFilter } from "../../common";
|
|
51
|
+
import { I_END_POINT } from "../../constants";
|
|
52
|
+
import { Continuable } from "../Continuable";
|
|
53
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
54
|
+
import { BaseChannelParser } from "./BaseChannelParser";
|
|
55
|
+
/**
|
|
56
|
+
* {@link Continuable} of playlists inside a {@link BaseChannel}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```js
|
|
60
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
61
|
+
* await channel.playlists.next();
|
|
62
|
+
* console.log(channel.playlists.items) // first 30 playlists
|
|
63
|
+
*
|
|
64
|
+
* let newPlaylists = await channel.playlists.next();
|
|
65
|
+
* console.log(newPlaylists) // 30 loaded playlists
|
|
66
|
+
* console.log(channel.playlists.items) // first 60 playlists
|
|
67
|
+
*
|
|
68
|
+
* await channel.playlists.next(0); // load the rest of the playlists in the channel
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
var ChannelPlaylists = /** @class */ (function (_super) {
|
|
72
|
+
__extends(ChannelPlaylists, _super);
|
|
73
|
+
/** @hidden */
|
|
74
|
+
function ChannelPlaylists(_a) {
|
|
75
|
+
var client = _a.client, channel = _a.channel;
|
|
76
|
+
var _this = _super.call(this, { client: client, strictContinuationCheck: true }) || this;
|
|
77
|
+
_this.channel = channel;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
ChannelPlaylists.prototype.fetch = function () {
|
|
81
|
+
var _a;
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var params, response, items, continuation, data;
|
|
84
|
+
var _this = this;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
params = "EglwbGF5bGlzdHMgAQ%3D%3D";
|
|
89
|
+
return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
|
|
90
|
+
data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
|
|
91
|
+
})];
|
|
92
|
+
case 1:
|
|
93
|
+
response = _b.sent();
|
|
94
|
+
items = BaseChannelParser.parseTabData("playlists", response.data);
|
|
95
|
+
continuation = getContinuationFromItems(items);
|
|
96
|
+
data = mapFilter(items, "gridPlaylistRenderer");
|
|
97
|
+
return [2 /*return*/, {
|
|
98
|
+
continuation: continuation,
|
|
99
|
+
items: data.map(function (i) {
|
|
100
|
+
return new PlaylistCompact({ client: _this.client }).load(i);
|
|
101
|
+
}),
|
|
102
|
+
}];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
return ChannelPlaylists;
|
|
108
|
+
}(Continuable));
|
|
109
|
+
export { ChannelPlaylists };
|
|
@@ -0,0 +1,109 @@
|
|
|
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 { getContinuationFromItems, mapFilter } from "../../common";
|
|
51
|
+
import { I_END_POINT } from "../../constants";
|
|
52
|
+
import { Continuable } from "../Continuable";
|
|
53
|
+
import { VideoCompact } from "../VideoCompact";
|
|
54
|
+
import { BaseChannelParser } from "./BaseChannelParser";
|
|
55
|
+
/**
|
|
56
|
+
* {@link Continuable} of videos inside a {@link BaseChannel}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```js
|
|
60
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
61
|
+
* await channel.videos.next();
|
|
62
|
+
* console.log(channel.videos.items) // first 30 videos
|
|
63
|
+
*
|
|
64
|
+
* let newVideos = await channel.videos.next();
|
|
65
|
+
* console.log(newVideos) // 30 loaded videos
|
|
66
|
+
* console.log(channel.videos.items) // first 60 videos
|
|
67
|
+
*
|
|
68
|
+
* await channel.videos.next(0); // load the rest of the videos in the channel
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
var ChannelVideos = /** @class */ (function (_super) {
|
|
72
|
+
__extends(ChannelVideos, _super);
|
|
73
|
+
/** @hidden */
|
|
74
|
+
function ChannelVideos(_a) {
|
|
75
|
+
var client = _a.client, channel = _a.channel;
|
|
76
|
+
var _this = _super.call(this, { client: client, strictContinuationCheck: true }) || this;
|
|
77
|
+
_this.channel = channel;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
ChannelVideos.prototype.fetch = function () {
|
|
81
|
+
var _a;
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var params, response, items, continuation, data;
|
|
84
|
+
var _this = this;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
params = "EgZ2aWRlb3M%3D";
|
|
89
|
+
return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
|
|
90
|
+
data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
|
|
91
|
+
})];
|
|
92
|
+
case 1:
|
|
93
|
+
response = _b.sent();
|
|
94
|
+
items = BaseChannelParser.parseTabData("videos", response.data);
|
|
95
|
+
continuation = getContinuationFromItems(items);
|
|
96
|
+
data = mapFilter(items, "gridVideoRenderer");
|
|
97
|
+
return [2 /*return*/, {
|
|
98
|
+
continuation: continuation,
|
|
99
|
+
items: data.map(function (i) {
|
|
100
|
+
return new VideoCompact({ client: _this.client }).load(i);
|
|
101
|
+
}),
|
|
102
|
+
}];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
return ChannelVideos;
|
|
108
|
+
}(Continuable));
|
|
109
|
+
export { ChannelVideos };
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import { Base } from "../Base";
|
|
15
|
+
import { BaseVideoParser } from "./BaseVideoParser";
|
|
16
|
+
import { VideoRelated } from "./VideoRelated";
|
|
17
|
+
/** Represents a Video */
|
|
18
|
+
var BaseVideo = /** @class */ (function (_super) {
|
|
19
|
+
__extends(BaseVideo, _super);
|
|
20
|
+
/** @hidden */
|
|
21
|
+
function BaseVideo(attr) {
|
|
22
|
+
var _this = _super.call(this, attr.client) || this;
|
|
23
|
+
Object.assign(_this, attr);
|
|
24
|
+
_this.related = new VideoRelated({ client: _this.client, video: _this });
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load this instance with raw data from Youtube
|
|
29
|
+
*
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
BaseVideo.prototype.load = function (data) {
|
|
33
|
+
BaseVideoParser.loadBaseVideo(this, data);
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(BaseVideo.prototype, "upNext", {
|
|
37
|
+
/**
|
|
38
|
+
* Video / playlist to play next after this video, alias to
|
|
39
|
+
* ```js
|
|
40
|
+
* video.related.items[0]
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
get: function () {
|
|
44
|
+
return this.related.items[0];
|
|
45
|
+
},
|
|
46
|
+
enumerable: false,
|
|
47
|
+
configurable: true
|
|
48
|
+
});
|
|
49
|
+
return BaseVideo;
|
|
50
|
+
}(Base));
|
|
51
|
+
export { BaseVideo };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { getContinuationFromItems, stripToInt } from "../../common";
|
|
13
|
+
import { BaseChannel } from "../BaseChannel";
|
|
14
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
15
|
+
import { Thumbnails } from "../Thumbnails";
|
|
16
|
+
import { VideoCompact } from "../VideoCompact";
|
|
17
|
+
var BaseVideoParser = /** @class */ (function () {
|
|
18
|
+
function BaseVideoParser() {
|
|
19
|
+
}
|
|
20
|
+
BaseVideoParser.loadBaseVideo = function (target, data) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
23
|
+
// Basic information
|
|
24
|
+
target.id = videoInfo.videoDetails.videoId;
|
|
25
|
+
target.title = videoInfo.videoDetails.title;
|
|
26
|
+
target.uploadDate = videoInfo.dateText.simpleText;
|
|
27
|
+
target.viewCount = +videoInfo.videoDetails.viewCount || null;
|
|
28
|
+
target.isLiveContent = videoInfo.videoDetails.isLiveContent;
|
|
29
|
+
target.thumbnails = new Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
30
|
+
// Channel
|
|
31
|
+
var _d = videoInfo.owner.videoOwnerRenderer, title = _d.title, thumbnail = _d.thumbnail, subscriberCountText = _d.subscriberCountText;
|
|
32
|
+
target.channel = new BaseChannel({
|
|
33
|
+
client: target.client,
|
|
34
|
+
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
35
|
+
name: title.runs[0].text,
|
|
36
|
+
subscriberCount: subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText,
|
|
37
|
+
thumbnails: new Thumbnails().load(thumbnail.thumbnails),
|
|
38
|
+
});
|
|
39
|
+
// Like Count and Dislike Count
|
|
40
|
+
var topLevelButtons = videoInfo.videoActions.menuRenderer.topLevelButtons;
|
|
41
|
+
target.likeCount = stripToInt(BaseVideoParser.parseButtonRenderer(topLevelButtons[0]));
|
|
42
|
+
// Tags and description
|
|
43
|
+
target.tags =
|
|
44
|
+
((_b = (_a = videoInfo.superTitleLink) === null || _a === void 0 ? void 0 : _a.runs) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.text.trim(); }).filter(function (t) { return t; })) || [];
|
|
45
|
+
target.description =
|
|
46
|
+
((_c = videoInfo.description) === null || _c === void 0 ? void 0 : _c.runs.map(function (d) { return d.text; }).join("")) || "";
|
|
47
|
+
// related videos
|
|
48
|
+
var secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
|
|
49
|
+
.results;
|
|
50
|
+
if (secondaryContents) {
|
|
51
|
+
target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
|
|
52
|
+
target.related.continuation = getContinuationFromItems(secondaryContents);
|
|
53
|
+
}
|
|
54
|
+
return target;
|
|
55
|
+
};
|
|
56
|
+
BaseVideoParser.parseRelated = function (data, client) {
|
|
57
|
+
var secondaryContents = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
|
|
58
|
+
return BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, client);
|
|
59
|
+
};
|
|
60
|
+
BaseVideoParser.parseContinuation = function (data) {
|
|
61
|
+
var secondaryContents = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
|
|
62
|
+
return getContinuationFromItems(secondaryContents);
|
|
63
|
+
};
|
|
64
|
+
BaseVideoParser.parseRawData = function (data) {
|
|
65
|
+
var contents = data[3].response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
66
|
+
var primaryInfo = contents.find(function (c) { return "videoPrimaryInfoRenderer" in c; })
|
|
67
|
+
.videoPrimaryInfoRenderer;
|
|
68
|
+
var secondaryInfo = contents.find(function (c) { return "videoSecondaryInfoRenderer" in c; }).videoSecondaryInfoRenderer;
|
|
69
|
+
var videoDetails = data[2].playerResponse.videoDetails;
|
|
70
|
+
return __assign(__assign(__assign({}, secondaryInfo), primaryInfo), { videoDetails: videoDetails });
|
|
71
|
+
};
|
|
72
|
+
BaseVideoParser.parseCompactRenderer = function (data, client) {
|
|
73
|
+
if ("compactVideoRenderer" in data) {
|
|
74
|
+
return new VideoCompact({ client: client }).load(data.compactVideoRenderer);
|
|
75
|
+
}
|
|
76
|
+
else if ("compactRadioRenderer" in data) {
|
|
77
|
+
return new PlaylistCompact({ client: client }).load(data.compactRadioRenderer);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
BaseVideoParser.parseRelatedFromSecondaryContent = function (secondaryContents, client) {
|
|
81
|
+
return secondaryContents
|
|
82
|
+
.map(function (c) { return BaseVideoParser.parseCompactRenderer(c, client); })
|
|
83
|
+
.filter(function (c) { return c !== undefined; });
|
|
84
|
+
};
|
|
85
|
+
BaseVideoParser.parseButtonRenderer = function (data) {
|
|
86
|
+
var _a;
|
|
87
|
+
var buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
|
|
88
|
+
var accessibilityData = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
|
|
89
|
+
return accessibilityData.label;
|
|
90
|
+
};
|
|
91
|
+
return BaseVideoParser;
|
|
92
|
+
}());
|
|
93
|
+
export { BaseVideoParser };
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { I_END_POINT } from "../../constants";
|
|
51
|
+
import { Continuable } from "../Continuable";
|
|
52
|
+
import { BaseVideoParser } from "./BaseVideoParser";
|
|
53
|
+
/**
|
|
54
|
+
* {@link Continuable} of related videos inside a Video
|
|
55
|
+
*/
|
|
56
|
+
var VideoRelated = /** @class */ (function (_super) {
|
|
57
|
+
__extends(VideoRelated, _super);
|
|
58
|
+
/** @hidden */
|
|
59
|
+
function VideoRelated(_a) {
|
|
60
|
+
var video = _a.video, client = _a.client;
|
|
61
|
+
var _this = _super.call(this, { client: client }) || this;
|
|
62
|
+
_this.video = video;
|
|
63
|
+
return _this;
|
|
64
|
+
}
|
|
65
|
+
VideoRelated.prototype.fetch = function () {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var response, items, continuation;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0: return [4 /*yield*/, this.client.http.post(I_END_POINT + "/next", {
|
|
71
|
+
data: { continuation: this.continuation },
|
|
72
|
+
})];
|
|
73
|
+
case 1:
|
|
74
|
+
response = _a.sent();
|
|
75
|
+
items = BaseVideoParser.parseRelated(response.data, this.client);
|
|
76
|
+
continuation = BaseVideoParser.parseContinuation(response.data);
|
|
77
|
+
return [2 /*return*/, {
|
|
78
|
+
continuation: continuation,
|
|
79
|
+
items: items,
|
|
80
|
+
}];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
return VideoRelated;
|
|
86
|
+
}(Continuable));
|
|
87
|
+
export { VideoRelated };
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { BaseChannel } from "../BaseChannel";
|
|
15
|
+
import { ChannelParser } from "./ChannelParser";
|
|
16
|
+
/** Represents a Youtube Channel */
|
|
17
|
+
var Channel = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Channel, _super);
|
|
19
|
+
/** @hidden */
|
|
20
|
+
function Channel(attr) {
|
|
21
|
+
var _this = _super.call(this, attr) || this;
|
|
22
|
+
_this.shelves = [];
|
|
23
|
+
Object.assign(_this, attr);
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Load this instance with raw data from Youtube
|
|
28
|
+
*
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
Channel.prototype.load = function (data) {
|
|
32
|
+
ChannelParser.loadChannel(this, data);
|
|
33
|
+
return this;
|
|
34
|
+
};
|
|
35
|
+
return Channel;
|
|
36
|
+
}(BaseChannel));
|
|
37
|
+
export { Channel };
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
import { BaseChannel } from "../BaseChannel";
|
|
13
|
+
import { PlaylistCompact } from "../PlaylistCompact";
|
|
14
|
+
import { Thumbnails } from "../Thumbnails";
|
|
15
|
+
import { VideoCompact } from "../VideoCompact";
|
|
16
|
+
var ChannelParser = /** @class */ (function () {
|
|
17
|
+
function ChannelParser() {
|
|
18
|
+
}
|
|
19
|
+
ChannelParser.loadChannel = function (target, data) {
|
|
20
|
+
var _a = data.header.c4TabbedHeaderRenderer, channelId = _a.channelId, title = _a.title, avatar = _a.avatar, subscriberCountText = _a.subscriberCountText;
|
|
21
|
+
target.id = channelId;
|
|
22
|
+
target.name = title;
|
|
23
|
+
target.thumbnails = new Thumbnails().load(avatar.thumbnails);
|
|
24
|
+
target.videoCount = 0; // data not available
|
|
25
|
+
target.subscriberCount = subscriberCountText.simpleText;
|
|
26
|
+
var _b = data.header.c4TabbedHeaderRenderer, tvBanner = _b.tvBanner, mobileBanner = _b.mobileBanner, banner = _b.banner;
|
|
27
|
+
target.banner = new Thumbnails().load((banner === null || banner === void 0 ? void 0 : banner.thumbnails) || []);
|
|
28
|
+
target.tvBanner = new Thumbnails().load((tvBanner === null || tvBanner === void 0 ? void 0 : tvBanner.thumbnails) || []);
|
|
29
|
+
target.mobileBanner = new Thumbnails().load((mobileBanner === null || mobileBanner === void 0 ? void 0 : mobileBanner.thumbnails) || []);
|
|
30
|
+
target.shelves = ChannelParser.parseShelves(target, data);
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
ChannelParser.parseShelves = function (target, data) {
|
|
34
|
+
var e_1, _a;
|
|
35
|
+
var shelves = [];
|
|
36
|
+
var rawShelves = data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
|
|
37
|
+
.sectionListRenderer.contents;
|
|
38
|
+
try {
|
|
39
|
+
for (var rawShelves_1 = __values(rawShelves), rawShelves_1_1 = rawShelves_1.next(); !rawShelves_1_1.done; rawShelves_1_1 = rawShelves_1.next()) {
|
|
40
|
+
var rawShelf = rawShelves_1_1.value;
|
|
41
|
+
var shelfRenderer = rawShelf.itemSectionRenderer.contents[0].shelfRenderer;
|
|
42
|
+
if (!shelfRenderer)
|
|
43
|
+
continue;
|
|
44
|
+
var title = shelfRenderer.title, content = shelfRenderer.content, subtitle = shelfRenderer.subtitle;
|
|
45
|
+
if (!content.horizontalListRenderer)
|
|
46
|
+
continue;
|
|
47
|
+
var items = content.horizontalListRenderer.items
|
|
48
|
+
.map(function (i) {
|
|
49
|
+
if (i.gridVideoRenderer)
|
|
50
|
+
return new VideoCompact({ client: target.client }).load(i.gridVideoRenderer);
|
|
51
|
+
if (i.gridPlaylistRenderer)
|
|
52
|
+
return new PlaylistCompact({ client: target.client }).load(i.gridPlaylistRenderer);
|
|
53
|
+
if (i.gridChannelRenderer)
|
|
54
|
+
return new BaseChannel({ client: target.client }).load(i.gridChannelRenderer);
|
|
55
|
+
return undefined;
|
|
56
|
+
})
|
|
57
|
+
.filter(function (i) { return i !== undefined; });
|
|
58
|
+
var shelf = {
|
|
59
|
+
title: title.runs[0].text,
|
|
60
|
+
subtitle: subtitle === null || subtitle === void 0 ? void 0 : subtitle.simpleText,
|
|
61
|
+
items: items,
|
|
62
|
+
};
|
|
63
|
+
shelves.push(shelf);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
67
|
+
finally {
|
|
68
|
+
try {
|
|
69
|
+
if (rawShelves_1_1 && !rawShelves_1_1.done && (_a = rawShelves_1.return)) _a.call(rawShelves_1);
|
|
70
|
+
}
|
|
71
|
+
finally { if (e_1) throw e_1.error; }
|
|
72
|
+
}
|
|
73
|
+
return shelves;
|
|
74
|
+
};
|
|
75
|
+
return ChannelParser;
|
|
76
|
+
}());
|
|
77
|
+
export { ChannelParser };
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
import { Base } from "../Base";
|
|
15
|
+
import { ChatParser } from "./ChatParser";
|
|
16
|
+
/** Represents a chat in a live stream */
|
|
17
|
+
var Chat = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Chat, _super);
|
|
19
|
+
/** @hidden */
|
|
20
|
+
function Chat(attr) {
|
|
21
|
+
var _this = _super.call(this, attr.client) || this;
|
|
22
|
+
Object.assign(_this, attr);
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Load this instance with raw data from Youtube
|
|
27
|
+
*
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
Chat.prototype.load = function (data) {
|
|
31
|
+
ChatParser.loadChat(this, data);
|
|
32
|
+
return this;
|
|
33
|
+
};
|
|
34
|
+
return Chat;
|
|
35
|
+
}(Base));
|
|
36
|
+
export { Chat };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseChannel } from "../BaseChannel";
|
|
2
|
+
var ChatParser = /** @class */ (function () {
|
|
3
|
+
function ChatParser() {
|
|
4
|
+
}
|
|
5
|
+
ChatParser.loadChat = function (target, data) {
|
|
6
|
+
var id = data.id, message = data.message, authorName = data.authorName, authorPhoto = data.authorPhoto, timestampUsec = data.timestampUsec, authorExternalChannelId = data.authorExternalChannelId;
|
|
7
|
+
// Basic information
|
|
8
|
+
target.id = id;
|
|
9
|
+
target.message = message.runs.map(function (r) { return r.text; }).join("");
|
|
10
|
+
target.author = new BaseChannel({
|
|
11
|
+
id: authorExternalChannelId,
|
|
12
|
+
name: authorName.simpleText,
|
|
13
|
+
thumbnails: authorPhoto.thumbnails,
|
|
14
|
+
client: target.client,
|
|
15
|
+
});
|
|
16
|
+
target.timestamp = +timestampUsec;
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
return ChatParser;
|
|
20
|
+
}());
|
|
21
|
+
export { ChatParser };
|