youtubei 0.0.1-rc.9 → 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.
Files changed (225) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +50 -53
  3. package/dist/cjs/classes/Base/Base.js +10 -0
  4. package/dist/cjs/classes/Base/index.js +13 -0
  5. package/dist/cjs/classes/BaseChannel/BaseChannel.js +31 -0
  6. package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +24 -0
  7. package/dist/cjs/classes/BaseChannel/ChannelPlaylists.js +57 -0
  8. package/dist/cjs/classes/BaseChannel/ChannelVideos.js +57 -0
  9. package/dist/cjs/classes/BaseChannel/index.js +16 -0
  10. package/dist/cjs/classes/BaseVideo/BaseVideo.js +34 -0
  11. package/dist/cjs/classes/BaseVideo/BaseVideoParser.js +82 -0
  12. package/dist/cjs/classes/BaseVideo/VideoRelated.js +39 -0
  13. package/dist/cjs/classes/BaseVideo/index.js +15 -0
  14. package/dist/cjs/classes/Channel/Channel.js +24 -0
  15. package/dist/cjs/classes/Channel/ChannelParser.js +55 -0
  16. package/dist/cjs/classes/Channel/index.js +13 -0
  17. package/dist/cjs/classes/Chat/Chat.js +23 -0
  18. package/dist/cjs/classes/Chat/ChatParser.js +21 -0
  19. package/dist/cjs/classes/Chat/index.js +13 -0
  20. package/dist/cjs/classes/Client/Client.js +101 -0
  21. package/dist/cjs/classes/Client/HTTP.js +59 -0
  22. package/dist/cjs/classes/Client/index.js +13 -0
  23. package/dist/cjs/classes/Comment/Comment.js +29 -0
  24. package/dist/cjs/classes/Comment/CommentParser.js +43 -0
  25. package/dist/cjs/classes/Comment/CommentReplies.js +36 -0
  26. package/dist/cjs/classes/Comment/index.js +13 -0
  27. package/dist/cjs/classes/Continuable/Continuable.js +43 -0
  28. package/dist/cjs/classes/Continuable/index.js +13 -0
  29. package/dist/{classes → cjs/classes/LiveVideo}/LiveVideo.js +84 -89
  30. package/dist/cjs/classes/LiveVideo/LiveVideoParser.js +29 -0
  31. package/dist/cjs/classes/LiveVideo/index.js +14 -0
  32. package/dist/cjs/classes/MixPlaylist/MixPlaylist.js +25 -0
  33. package/dist/cjs/classes/MixPlaylist/MixPlaylistParser.js +27 -0
  34. package/dist/cjs/classes/MixPlaylist/index.js +14 -0
  35. package/dist/cjs/classes/Playlist/Playlist.js +25 -0
  36. package/dist/cjs/classes/Playlist/PlaylistParser.js +83 -0
  37. package/dist/cjs/classes/Playlist/PlaylistVideos.js +50 -0
  38. package/dist/cjs/classes/Playlist/index.js +15 -0
  39. package/dist/cjs/classes/PlaylistCompact/PlaylistCompact.js +45 -0
  40. package/dist/cjs/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
  41. package/dist/cjs/classes/PlaylistCompact/index.js +14 -0
  42. package/dist/cjs/classes/Reply/Reply.js +23 -0
  43. package/dist/cjs/classes/Reply/ReplyParser.js +26 -0
  44. package/dist/cjs/classes/Reply/index.js +14 -0
  45. package/dist/cjs/classes/SearchManager/SearchManager.js +83 -0
  46. package/dist/cjs/classes/SearchManager/SearchManagerParser.js +40 -0
  47. package/dist/cjs/classes/SearchManager/index.js +14 -0
  48. package/dist/{classes/Base.js → cjs/classes/SearchManager/proto/SearchProto.js} +2 -5
  49. package/dist/cjs/classes/SearchManager/proto/index.js +57 -0
  50. package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -66
  51. package/dist/cjs/classes/Thumbnails/index.js +13 -0
  52. package/dist/cjs/classes/Video/Video.js +26 -0
  53. package/dist/cjs/classes/Video/VideoComments.js +53 -0
  54. package/dist/cjs/classes/Video/VideoParser.js +29 -0
  55. package/dist/cjs/classes/Video/index.js +14 -0
  56. package/dist/cjs/classes/VideoCompact/VideoCompact.js +49 -0
  57. package/dist/cjs/classes/VideoCompact/VideoCompactParser.js +36 -0
  58. package/dist/cjs/classes/VideoCompact/index.js +14 -0
  59. package/dist/cjs/classes/index.js +29 -0
  60. package/dist/{common → cjs/common}/decorators.js +14 -14
  61. package/dist/cjs/common/helper.js +45 -0
  62. package/dist/{common → cjs/common}/index.js +16 -23
  63. package/dist/{common → cjs/common}/mixins.js +14 -12
  64. package/dist/{common → cjs/common}/types.js +2 -2
  65. package/dist/{constants.js → cjs/constants.js} +10 -10
  66. package/dist/{index.js → cjs/index.js} +13 -13
  67. package/dist/esm/classes/Base/Base.js +8 -0
  68. package/dist/esm/classes/Base/index.js +1 -0
  69. package/dist/esm/classes/BaseChannel/BaseChannel.js +48 -0
  70. package/dist/esm/classes/BaseChannel/BaseChannelParser.js +24 -0
  71. package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +109 -0
  72. package/dist/esm/classes/BaseChannel/ChannelVideos.js +109 -0
  73. package/dist/esm/classes/BaseChannel/index.js +4 -0
  74. package/dist/esm/classes/BaseVideo/BaseVideo.js +51 -0
  75. package/dist/esm/classes/BaseVideo/BaseVideoParser.js +93 -0
  76. package/dist/esm/classes/BaseVideo/VideoRelated.js +87 -0
  77. package/dist/esm/classes/BaseVideo/index.js +3 -0
  78. package/dist/esm/classes/Channel/Channel.js +37 -0
  79. package/dist/esm/classes/Channel/ChannelParser.js +77 -0
  80. package/dist/esm/classes/Channel/index.js +1 -0
  81. package/dist/esm/classes/Chat/Chat.js +36 -0
  82. package/dist/esm/classes/Chat/ChatParser.js +21 -0
  83. package/dist/esm/classes/Chat/index.js +1 -0
  84. package/dist/esm/classes/Client/Client.js +176 -0
  85. package/dist/esm/classes/Client/HTTP.js +112 -0
  86. package/dist/esm/classes/Client/index.js +1 -0
  87. package/dist/esm/classes/Comment/Comment.js +46 -0
  88. package/dist/esm/classes/Comment/CommentParser.js +45 -0
  89. package/dist/esm/classes/Comment/CommentReplies.js +84 -0
  90. package/dist/esm/classes/Comment/index.js +1 -0
  91. package/dist/esm/classes/Continuable/Continuable.js +125 -0
  92. package/dist/esm/classes/Continuable/index.js +1 -0
  93. package/dist/esm/classes/LiveVideo/LiveVideo.js +160 -0
  94. package/dist/esm/classes/LiveVideo/LiveVideoParser.js +29 -0
  95. package/dist/esm/classes/LiveVideo/index.js +2 -0
  96. package/dist/esm/classes/MixPlaylist/MixPlaylist.js +38 -0
  97. package/dist/esm/classes/MixPlaylist/MixPlaylistParser.js +49 -0
  98. package/dist/esm/classes/MixPlaylist/index.js +2 -0
  99. package/dist/esm/classes/Playlist/Playlist.js +38 -0
  100. package/dist/esm/classes/Playlist/PlaylistParser.js +105 -0
  101. package/dist/esm/classes/Playlist/PlaylistVideos.js +98 -0
  102. package/dist/esm/classes/Playlist/index.js +3 -0
  103. package/dist/esm/classes/PlaylistCompact/PlaylistCompact.js +90 -0
  104. package/dist/esm/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
  105. package/dist/esm/classes/PlaylistCompact/index.js +2 -0
  106. package/dist/esm/classes/Reply/Reply.js +36 -0
  107. package/dist/esm/classes/Reply/ReplyParser.js +26 -0
  108. package/dist/esm/classes/Reply/index.js +2 -0
  109. package/dist/esm/classes/SearchManager/SearchManager.js +159 -0
  110. package/dist/esm/classes/SearchManager/SearchManagerParser.js +62 -0
  111. package/dist/esm/classes/SearchManager/index.js +2 -0
  112. package/dist/esm/classes/SearchManager/proto/SearchProto.js +1 -0
  113. package/dist/esm/classes/SearchManager/proto/index.js +39 -0
  114. package/dist/esm/classes/Thumbnails/Thumbnails.js +109 -0
  115. package/dist/esm/classes/Thumbnails/index.js +1 -0
  116. package/dist/esm/classes/Video/Video.js +39 -0
  117. package/dist/esm/classes/Video/VideoComments.js +101 -0
  118. package/dist/esm/classes/Video/VideoParser.js +31 -0
  119. package/dist/esm/classes/Video/index.js +2 -0
  120. package/dist/esm/classes/VideoCompact/VideoCompact.js +98 -0
  121. package/dist/esm/classes/VideoCompact/VideoCompactParser.js +36 -0
  122. package/dist/esm/classes/VideoCompact/index.js +2 -0
  123. package/dist/esm/classes/index.js +17 -0
  124. package/dist/esm/common/decorators.js +30 -0
  125. package/dist/esm/common/helper.js +61 -0
  126. package/dist/esm/common/index.js +4 -0
  127. package/dist/esm/common/mixins.js +10 -0
  128. package/dist/esm/common/types.js +1 -0
  129. package/dist/esm/constants.js +7 -0
  130. package/dist/esm/index.js +1 -0
  131. package/dist/typings/classes/Base/Base.d.ts +11 -0
  132. package/dist/typings/classes/Base/index.d.ts +1 -0
  133. package/dist/typings/classes/BaseChannel/BaseChannel.d.ts +43 -0
  134. package/dist/typings/classes/BaseChannel/BaseChannelParser.d.ts +7 -0
  135. package/dist/typings/classes/BaseChannel/ChannelPlaylists.d.ts +30 -0
  136. package/dist/typings/classes/BaseChannel/ChannelVideos.d.ts +30 -0
  137. package/dist/typings/classes/BaseChannel/index.d.ts +4 -0
  138. package/dist/typings/classes/BaseVideo/BaseVideo.d.ts +59 -0
  139. package/dist/typings/classes/BaseVideo/BaseVideoParser.d.ts +14 -0
  140. package/dist/typings/classes/BaseVideo/VideoRelated.d.ts +21 -0
  141. package/dist/typings/classes/BaseVideo/index.d.ts +3 -0
  142. package/dist/typings/classes/Channel/Channel.d.ts +33 -0
  143. package/dist/typings/classes/Channel/ChannelParser.d.ts +6 -0
  144. package/dist/typings/classes/Channel/index.d.ts +1 -0
  145. package/dist/typings/classes/Chat/Chat.d.ts +33 -0
  146. package/dist/typings/classes/Chat/ChatParser.d.ts +5 -0
  147. package/dist/typings/classes/Chat/index.d.ts +1 -0
  148. package/dist/typings/classes/Client/Client.d.ts +41 -0
  149. package/dist/typings/classes/Client/HTTP.d.ts +21 -0
  150. package/dist/typings/classes/Client/index.d.ts +1 -0
  151. package/dist/typings/classes/Comment/Comment.d.ts +51 -0
  152. package/dist/typings/classes/Comment/CommentParser.d.ts +8 -0
  153. package/dist/typings/classes/Comment/CommentReplies.d.ts +17 -0
  154. package/dist/typings/classes/Comment/index.d.ts +1 -0
  155. package/dist/typings/classes/Continuable/Continuable.d.ts +24 -0
  156. package/dist/typings/classes/Continuable/index.d.ts +1 -0
  157. package/dist/{classes → typings/classes/LiveVideo}/LiveVideo.d.ts +46 -44
  158. package/dist/typings/classes/LiveVideo/LiveVideoParser.d.ts +10 -0
  159. package/dist/typings/classes/LiveVideo/index.d.ts +2 -0
  160. package/dist/typings/classes/MixPlaylist/MixPlaylist.d.ts +29 -0
  161. package/dist/typings/classes/MixPlaylist/MixPlaylistParser.d.ts +6 -0
  162. package/dist/typings/classes/MixPlaylist/index.d.ts +2 -0
  163. package/dist/typings/classes/Playlist/Playlist.d.ts +39 -0
  164. package/dist/typings/classes/Playlist/PlaylistParser.d.ts +16 -0
  165. package/dist/typings/classes/Playlist/PlaylistVideos.d.ts +31 -0
  166. package/dist/typings/classes/Playlist/index.d.ts +3 -0
  167. package/dist/typings/classes/PlaylistCompact/PlaylistCompact.d.ts +43 -0
  168. package/dist/typings/classes/PlaylistCompact/PlaylistCompactParser.d.ts +5 -0
  169. package/dist/typings/classes/PlaylistCompact/index.d.ts +2 -0
  170. package/dist/typings/classes/Reply/Reply.d.ts +43 -0
  171. package/dist/typings/classes/Reply/ReplyParser.d.ts +5 -0
  172. package/dist/typings/classes/Reply/index.d.ts +2 -0
  173. package/dist/typings/classes/SearchManager/SearchManager.d.ts +51 -0
  174. package/dist/typings/classes/SearchManager/SearchManagerParser.d.ts +13 -0
  175. package/dist/typings/classes/SearchManager/index.d.ts +2 -0
  176. package/dist/typings/classes/SearchManager/proto/SearchProto.d.ts +13 -0
  177. package/dist/typings/classes/SearchManager/proto/index.d.ts +24 -0
  178. package/dist/{classes → typings/classes/Thumbnails}/Thumbnails.d.ts +41 -42
  179. package/dist/typings/classes/Thumbnails/index.d.ts +1 -0
  180. package/dist/typings/classes/Video/Video.d.ts +24 -0
  181. package/dist/typings/classes/Video/VideoComments.d.ts +34 -0
  182. package/dist/typings/classes/Video/VideoParser.d.ts +8 -0
  183. package/dist/typings/classes/Video/index.d.ts +2 -0
  184. package/dist/typings/classes/VideoCompact/VideoCompact.d.ts +57 -0
  185. package/dist/typings/classes/VideoCompact/VideoCompactParser.d.ts +5 -0
  186. package/dist/typings/classes/VideoCompact/index.d.ts +2 -0
  187. package/dist/typings/classes/index.d.ts +17 -0
  188. package/dist/{common → typings/common}/decorators.d.ts +5 -5
  189. package/dist/typings/common/helper.d.ts +5 -0
  190. package/dist/typings/common/index.d.ts +4 -0
  191. package/dist/typings/common/mixins.d.ts +1 -0
  192. package/dist/{common → typings/common}/types.d.ts +1 -1
  193. package/dist/{constants.d.ts → typings/constants.d.ts} +7 -7
  194. package/dist/{index.d.ts → typings/index.d.ts} +1 -1
  195. package/package.json +68 -53
  196. package/CHANGELOG.md +0 -6
  197. package/dist/classes/Base.d.ts +0 -7
  198. package/dist/classes/BaseVideo.d.ts +0 -54
  199. package/dist/classes/BaseVideo.js +0 -82
  200. package/dist/classes/Channel.d.ts +0 -83
  201. package/dist/classes/Channel.js +0 -138
  202. package/dist/classes/Chat.d.ts +0 -29
  203. package/dist/classes/Chat.js +0 -31
  204. package/dist/classes/Client.d.ts +0 -30
  205. package/dist/classes/Client.js +0 -69
  206. package/dist/classes/Comment.d.ts +0 -43
  207. package/dist/classes/Comment.js +0 -42
  208. package/dist/classes/Playlist.d.ts +0 -61
  209. package/dist/classes/Playlist.js +0 -127
  210. package/dist/classes/PlaylistCompact.d.ts +0 -30
  211. package/dist/classes/PlaylistCompact.js +0 -45
  212. package/dist/classes/SearchResult.d.ts +0 -69
  213. package/dist/classes/SearchResult.js +0 -139
  214. package/dist/classes/Video.d.ts +0 -49
  215. package/dist/classes/Video.js +0 -102
  216. package/dist/classes/VideoCompact.d.ts +0 -40
  217. package/dist/classes/VideoCompact.js +0 -50
  218. package/dist/classes/index.d.ts +0 -13
  219. package/dist/classes/index.js +0 -32
  220. package/dist/common/helper.d.ts +0 -2
  221. package/dist/common/helper.js +0 -37
  222. package/dist/common/http.d.ts +0 -30
  223. package/dist/common/http.js +0 -108
  224. package/dist/common/index.d.ts +0 -5
  225. package/dist/common/mixins.d.ts +0 -2
@@ -0,0 +1,48 @@
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 { BaseChannelParser } from "./BaseChannelParser";
16
+ import { ChannelPlaylists } from "./ChannelPlaylists";
17
+ import { ChannelVideos } from "./ChannelVideos";
18
+ /** Represents a Youtube Channel */
19
+ var BaseChannel = /** @class */ (function (_super) {
20
+ __extends(BaseChannel, _super);
21
+ /** @hidden */
22
+ function BaseChannel(attr) {
23
+ var _this = _super.call(this, attr.client) || this;
24
+ Object.assign(_this, attr);
25
+ _this.videos = new ChannelVideos({ channel: _this, client: _this.client });
26
+ _this.playlists = new ChannelPlaylists({ channel: _this, client: _this.client });
27
+ return _this;
28
+ }
29
+ Object.defineProperty(BaseChannel.prototype, "url", {
30
+ /** The URL of the channel page */
31
+ get: function () {
32
+ return "https://www.youtube.com/channel/" + this.id;
33
+ },
34
+ enumerable: false,
35
+ configurable: true
36
+ });
37
+ /**
38
+ * Load this instance with raw data from Youtube
39
+ *
40
+ * @hidden
41
+ */
42
+ BaseChannel.prototype.load = function (data) {
43
+ BaseChannelParser.loadBaseChannel(this, data);
44
+ return this;
45
+ };
46
+ return BaseChannel;
47
+ }(Base));
48
+ export { BaseChannel };
@@ -0,0 +1,24 @@
1
+ import { stripToInt } from "../../common";
2
+ import { Thumbnails } from "../Thumbnails";
3
+ var BaseChannelParser = /** @class */ (function () {
4
+ function BaseChannelParser() {
5
+ }
6
+ BaseChannelParser.loadBaseChannel = function (target, data) {
7
+ var channelId = data.channelId, title = data.title, thumbnail = data.thumbnail, videoCountText = data.videoCountText, subscriberCountText = data.subscriberCountText;
8
+ target.id = channelId;
9
+ target.name = title.simpleText;
10
+ target.thumbnails = new Thumbnails().load(thumbnail.thumbnails);
11
+ target.videoCount = stripToInt(videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs[0].text) || 0;
12
+ target.subscriberCount = subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText;
13
+ return target;
14
+ };
15
+ /** Parse tab data from request, tab name is ignored if it's a continuation data */
16
+ BaseChannelParser.parseTabData = function (name, data) {
17
+ var _a;
18
+ var index = name === "videos" ? 1 : 2;
19
+ return (((_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs[index].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer.items) ||
20
+ data.onResponseReceivedActions[0].appendContinuationItemsAction.continuationItems);
21
+ };
22
+ return BaseChannelParser;
23
+ }());
24
+ export { BaseChannelParser };
@@ -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,4 @@
1
+ export * from "./BaseChannel";
2
+ export * from "./BaseChannelParser";
3
+ export * from "./ChannelPlaylists";
4
+ export * from "./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,3 @@
1
+ export * from "./BaseVideo";
2
+ export * from "./BaseVideoParser";
3
+ export * from "./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 @@
1
+ export * from "./Channel";