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.
Files changed (264) 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/{index.js → cjs/classes/Base/index.js} +13 -13
  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/{classes/client → cjs/classes/BaseChannel}/index.js +16 -19
  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/{common → cjs/classes/BaseVideo}/index.js +15 -21
  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/cjs/classes/LiveVideo/LiveVideo.js +84 -0
  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/{common/types.js → cjs/classes/SearchManager/proto/SearchProto.js} +2 -2
  49. package/dist/cjs/classes/SearchManager/proto/index.js +57 -0
  50. package/dist/cjs/classes/Thumbnails/Thumbnails.js +67 -0
  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/{src → cjs}/common/decorators.js +14 -15
  61. package/dist/cjs/common/helper.js +45 -0
  62. package/dist/{src → cjs}/common/index.js +16 -21
  63. package/dist/cjs/common/mixins.js +14 -0
  64. package/dist/{classes/client → cjs/common}/types.js +2 -2
  65. package/dist/{src → cjs}/constants.js +10 -9
  66. package/dist/{src → 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/{common/index.d.ts → esm/common/index.js} +4 -4
  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/{index.d.ts → esm/index.js} +1 -1
  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/typings/classes/LiveVideo/LiveVideo.d.ts +46 -0
  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/typings/classes/Thumbnails/Thumbnails.d.ts +41 -0
  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/{src → typings}/common/decorators.d.ts +5 -7
  189. package/dist/typings/common/helper.d.ts +5 -0
  190. package/dist/{src → typings}/common/index.d.ts +4 -4
  191. package/dist/typings/common/mixins.d.ts +1 -0
  192. package/dist/{common → typings/common}/types.d.ts +1 -2
  193. package/dist/{constants.d.ts → typings/constants.d.ts} +7 -6
  194. package/dist/{src → 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 -8
  198. package/dist/classes/Base.js +0 -10
  199. package/dist/classes/Channel.d.ts +0 -63
  200. package/dist/classes/Channel.js +0 -115
  201. package/dist/classes/Comment.d.ts +0 -51
  202. package/dist/classes/Comment.js +0 -47
  203. package/dist/classes/LiveVideo.d.ts +0 -3
  204. package/dist/classes/LiveVideo.js +0 -12
  205. package/dist/classes/Playlist.d.ts +0 -66
  206. package/dist/classes/Playlist.js +0 -133
  207. package/dist/classes/PlaylistCompact.d.ts +0 -35
  208. package/dist/classes/PlaylistCompact.js +0 -47
  209. package/dist/classes/SearchResult.d.ts +0 -52
  210. package/dist/classes/SearchResult.js +0 -121
  211. package/dist/classes/Test.d.ts +0 -7
  212. package/dist/classes/Test.js +0 -9
  213. package/dist/classes/Thumbnails.d.ts +0 -23
  214. package/dist/classes/Thumbnails.js +0 -42
  215. package/dist/classes/Video.d.ts +0 -90
  216. package/dist/classes/Video.js +0 -153
  217. package/dist/classes/VideoCompact.d.ts +0 -46
  218. package/dist/classes/VideoCompact.js +0 -53
  219. package/dist/classes/client/Client.d.ts +0 -26
  220. package/dist/classes/client/Client.js +0 -63
  221. package/dist/classes/client/index.d.ts +0 -2
  222. package/dist/classes/client/types.d.ts +0 -12
  223. package/dist/classes/client.d.ts +0 -17
  224. package/dist/classes/client.js +0 -57
  225. package/dist/classes/index.d.ts +0 -10
  226. package/dist/classes/index.js +0 -26
  227. package/dist/common/decorators.d.ts +0 -7
  228. package/dist/common/decorators.js +0 -15
  229. package/dist/common/helper.d.ts +0 -4
  230. package/dist/common/helper.js +0 -39
  231. package/dist/common/http.d.ts +0 -33
  232. package/dist/common/http.js +0 -105
  233. package/dist/constants.js +0 -9
  234. package/dist/src/classes/Base.d.ts +0 -8
  235. package/dist/src/classes/Base.js +0 -10
  236. package/dist/src/classes/Channel.d.ts +0 -37
  237. package/dist/src/classes/Channel.js +0 -82
  238. package/dist/src/classes/Client.d.ts +0 -14
  239. package/dist/src/classes/Client.js +0 -51
  240. package/dist/src/classes/Comment.d.ts +0 -51
  241. package/dist/src/classes/Comment.js +0 -47
  242. package/dist/src/classes/Playlist.d.ts +0 -66
  243. package/dist/src/classes/Playlist.js +0 -133
  244. package/dist/src/classes/PlaylistCompact.d.ts +0 -35
  245. package/dist/src/classes/PlaylistCompact.js +0 -47
  246. package/dist/src/classes/SearchResult.d.ts +0 -53
  247. package/dist/src/classes/SearchResult.js +0 -122
  248. package/dist/src/classes/Thumbnails.d.ts +0 -24
  249. package/dist/src/classes/Thumbnails.js +0 -42
  250. package/dist/src/classes/Video.d.ts +0 -90
  251. package/dist/src/classes/Video.js +0 -153
  252. package/dist/src/classes/VideoCompact.d.ts +0 -46
  253. package/dist/src/classes/VideoCompact.js +0 -53
  254. package/dist/src/classes/index.d.ts +0 -10
  255. package/dist/src/classes/index.js +0 -26
  256. package/dist/src/common/helper.d.ts +0 -4
  257. package/dist/src/common/helper.js +0 -39
  258. package/dist/src/common/http.d.ts +0 -33
  259. package/dist/src/common/http.js +0 -105
  260. package/dist/src/common/types.d.ts +0 -2
  261. package/dist/src/common/types.js +0 -2
  262. package/dist/src/constants.d.ts +0 -6
  263. package/dist/tempCodeRunnerFile.d.ts +0 -8
  264. package/dist/tempCodeRunnerFile.js +0 -15
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelParser = void 0;
4
+ const BaseChannel_1 = require("../BaseChannel");
5
+ const PlaylistCompact_1 = require("../PlaylistCompact");
6
+ const Thumbnails_1 = require("../Thumbnails");
7
+ const VideoCompact_1 = require("../VideoCompact");
8
+ class ChannelParser {
9
+ static loadChannel(target, data) {
10
+ const { channelId, title, avatar, subscriberCountText, } = data.header.c4TabbedHeaderRenderer;
11
+ target.id = channelId;
12
+ target.name = title;
13
+ target.thumbnails = new Thumbnails_1.Thumbnails().load(avatar.thumbnails);
14
+ target.videoCount = 0; // data not available
15
+ target.subscriberCount = subscriberCountText.simpleText;
16
+ const { tvBanner, mobileBanner, banner } = data.header.c4TabbedHeaderRenderer;
17
+ target.banner = new Thumbnails_1.Thumbnails().load((banner === null || banner === void 0 ? void 0 : banner.thumbnails) || []);
18
+ target.tvBanner = new Thumbnails_1.Thumbnails().load((tvBanner === null || tvBanner === void 0 ? void 0 : tvBanner.thumbnails) || []);
19
+ target.mobileBanner = new Thumbnails_1.Thumbnails().load((mobileBanner === null || mobileBanner === void 0 ? void 0 : mobileBanner.thumbnails) || []);
20
+ target.shelves = ChannelParser.parseShelves(target, data);
21
+ return target;
22
+ }
23
+ static parseShelves(target, data) {
24
+ const shelves = [];
25
+ const rawShelves = data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
26
+ .sectionListRenderer.contents;
27
+ for (const rawShelf of rawShelves) {
28
+ const shelfRenderer = rawShelf.itemSectionRenderer.contents[0].shelfRenderer;
29
+ if (!shelfRenderer)
30
+ continue;
31
+ const { title, content, subtitle } = shelfRenderer;
32
+ if (!content.horizontalListRenderer)
33
+ continue;
34
+ const items = content.horizontalListRenderer.items
35
+ .map((i) => {
36
+ if (i.gridVideoRenderer)
37
+ return new VideoCompact_1.VideoCompact({ client: target.client }).load(i.gridVideoRenderer);
38
+ if (i.gridPlaylistRenderer)
39
+ return new PlaylistCompact_1.PlaylistCompact({ client: target.client }).load(i.gridPlaylistRenderer);
40
+ if (i.gridChannelRenderer)
41
+ return new BaseChannel_1.BaseChannel({ client: target.client }).load(i.gridChannelRenderer);
42
+ return undefined;
43
+ })
44
+ .filter((i) => i !== undefined);
45
+ const shelf = {
46
+ title: title.runs[0].text,
47
+ subtitle: subtitle === null || subtitle === void 0 ? void 0 : subtitle.simpleText,
48
+ items,
49
+ };
50
+ shelves.push(shelf);
51
+ }
52
+ return shelves;
53
+ }
54
+ }
55
+ exports.ChannelParser = ChannelParser;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Channel"), exports);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Chat = void 0;
4
+ const Base_1 = require("../Base");
5
+ const ChatParser_1 = require("./ChatParser");
6
+ /** Represents a chat in a live stream */
7
+ class Chat extends Base_1.Base {
8
+ /** @hidden */
9
+ constructor(attr) {
10
+ super(attr.client);
11
+ Object.assign(this, attr);
12
+ }
13
+ /**
14
+ * Load this instance with raw data from Youtube
15
+ *
16
+ * @hidden
17
+ */
18
+ load(data) {
19
+ ChatParser_1.ChatParser.loadChat(this, data);
20
+ return this;
21
+ }
22
+ }
23
+ exports.Chat = Chat;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatParser = void 0;
4
+ const BaseChannel_1 = require("../BaseChannel");
5
+ class ChatParser {
6
+ static loadChat(target, data) {
7
+ const { id, message, authorName, authorPhoto, timestampUsec, authorExternalChannelId, } = data;
8
+ // Basic information
9
+ target.id = id;
10
+ target.message = message.runs.map((r) => r.text).join("");
11
+ target.author = new BaseChannel_1.BaseChannel({
12
+ id: authorExternalChannelId,
13
+ name: authorName.simpleText,
14
+ thumbnails: authorPhoto.thumbnails,
15
+ client: target.client,
16
+ });
17
+ target.timestamp = +timestampUsec;
18
+ return target;
19
+ }
20
+ }
21
+ exports.ChatParser = ChatParser;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Chat"), exports);
@@ -0,0 +1,101 @@
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
+ exports.Client = void 0;
13
+ const constants_1 = require("../../constants");
14
+ const Channel_1 = require("../Channel");
15
+ const LiveVideo_1 = require("../LiveVideo");
16
+ const MixPlaylist_1 = require("../MixPlaylist");
17
+ const Playlist_1 = require("../Playlist");
18
+ const SearchManager_1 = require("../SearchManager");
19
+ const Video_1 = require("../Video");
20
+ const HTTP_1 = require("./HTTP");
21
+ /** Youtube Client */
22
+ class Client {
23
+ constructor(options = {}) {
24
+ const fullOptions = Object.assign(Object.assign({ initialCookie: "", fetchOptions: {} }, options), { youtubeClientOptions: Object.assign({ hl: "en", gl: "US" }, options.youtubeClientOptions) });
25
+ this.http = new HTTP_1.HTTP(fullOptions);
26
+ }
27
+ /**
28
+ * Searches for videos / playlists / channels
29
+ *
30
+ * @param query The search query
31
+ * @param options Search options
32
+ *
33
+ */
34
+ search(query, options) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const manager = new SearchManager_1.SearchManager({ client: this });
37
+ yield manager.search(query, options || {});
38
+ return manager;
39
+ });
40
+ }
41
+ /**
42
+ * Search for videos / playlists / channels and returns the first result
43
+ *
44
+ * @return Can be {@link VideoCompact} | {@link PlaylistCompact} | {@link BaseChannel} | `undefined`
45
+ */
46
+ findOne(query, options) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const result = yield this.search(query, options);
49
+ return result.items[0] || undefined;
50
+ });
51
+ }
52
+ /** Get playlist information and its videos by playlist id or URL */
53
+ getPlaylist(playlistId) {
54
+ var _a, _b, _c;
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (playlistId.startsWith("RD")) {
57
+ const response = yield this.http.post(`${constants_1.I_END_POINT}/next`, {
58
+ data: { playlistId },
59
+ });
60
+ if (response.data.error) {
61
+ return undefined;
62
+ }
63
+ return new MixPlaylist_1.MixPlaylist({ client: this }).load(response.data);
64
+ }
65
+ const response = yield this.http.post(`${constants_1.I_END_POINT}/browse`, {
66
+ data: { browseId: `VL${playlistId}` },
67
+ });
68
+ if (response.data.error || ((_c = (_b = (_a = response.data.alerts) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.alertRenderer) === null || _c === void 0 ? void 0 : _c.type) === "ERROR") {
69
+ return undefined;
70
+ }
71
+ return new Playlist_1.Playlist({ client: this }).load(response.data);
72
+ });
73
+ }
74
+ /** Get video information by video id or URL */
75
+ getVideo(videoId) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const response = yield this.http.get(`${constants_1.WATCH_END_POINT}`, {
78
+ params: { v: videoId, pbj: "1" },
79
+ });
80
+ if (!response.data[3].response.contents)
81
+ return undefined;
82
+ return (!response.data[2].playerResponse.playabilityStatus.liveStreamability
83
+ ? new Video_1.Video({ client: this }).load(response.data)
84
+ : new LiveVideo_1.LiveVideo({ client: this }).load(response.data));
85
+ });
86
+ }
87
+ /** Get channel information by channel id+ */
88
+ getChannel(channelId) {
89
+ var _a, _b, _c;
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const response = yield this.http.post(`${constants_1.I_END_POINT}/browse`, {
92
+ data: { browseId: channelId },
93
+ });
94
+ if (response.data.error || ((_c = (_b = (_a = response.data.alerts) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.alertRenderer) === null || _c === void 0 ? void 0 : _c.type) === "ERROR") {
95
+ return undefined;
96
+ }
97
+ return new Channel_1.Channel({ client: this }).load(response.data);
98
+ });
99
+ }
100
+ }
101
+ exports.Client = Client;
@@ -0,0 +1,59 @@
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
+ exports.HTTP = void 0;
16
+ const node_fetch_1 = __importDefault(require("node-fetch"));
17
+ const url_1 = require("url");
18
+ const constants_1 = require("../../constants");
19
+ class HTTP {
20
+ constructor(options) {
21
+ this.cookie = options.initialCookie || "";
22
+ this.defaultHeaders = {
23
+ "x-youtube-client-version": constants_1.INNERTUBE_CLIENT_VERSION,
24
+ "x-youtube-client-name": "1",
25
+ "content-type": "application/json",
26
+ "accept-encoding": "gzip, deflate, br",
27
+ };
28
+ this.defaultFetchOptions = options.fetchOptions || {};
29
+ this.defaultClientOptions = options.youtubeClientOptions || {};
30
+ }
31
+ get(url, options) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return yield this.request(url, Object.assign(Object.assign({}, options), { params: Object.assign({ prettyPrint: "false" }, options === null || options === void 0 ? void 0 : options.params), method: "GET" }));
34
+ });
35
+ }
36
+ post(url, options) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return yield this.request(url, Object.assign(Object.assign({}, options), { method: "POST", params: Object.assign({ key: constants_1.INNERTUBE_API_KEY, prettyPrint: "false" }, options === null || options === void 0 ? void 0 : options.params), data: Object.assign({ context: {
39
+ client: Object.assign({ clientName: "WEB", clientVersion: constants_1.INNERTUBE_CLIENT_VERSION }, this.defaultClientOptions),
40
+ } }, options === null || options === void 0 ? void 0 : options.data) }));
41
+ });
42
+ }
43
+ request(url, partialOptions) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const options = Object.assign(Object.assign(Object.assign({}, partialOptions), this.defaultFetchOptions), { headers: Object.assign(Object.assign(Object.assign(Object.assign({}, this.defaultHeaders), { cookie: this.cookie }), partialOptions.headers), this.defaultFetchOptions.headers), body: partialOptions.data ? JSON.stringify(partialOptions.data) : undefined });
46
+ const finalUrl = `https://${constants_1.BASE_URL}/${url}?${new url_1.URLSearchParams(partialOptions.params)}`;
47
+ const response = yield node_fetch_1.default(finalUrl, options);
48
+ const data = yield response.json();
49
+ this.parseCookie(response);
50
+ return { data };
51
+ });
52
+ }
53
+ parseCookie(response) {
54
+ const cookie = response.headers.get("set-cookie");
55
+ if (cookie)
56
+ this.cookie = cookie;
57
+ }
58
+ }
59
+ exports.HTTP = HTTP;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Client"), exports);
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Comment = void 0;
4
+ const Base_1 = require("../Base");
5
+ const CommentParser_1 = require("./CommentParser");
6
+ const CommentReplies_1 = require("./CommentReplies");
7
+ /** Represents a Comment / Reply */
8
+ class Comment extends Base_1.Base {
9
+ /** @hidden */
10
+ constructor(attr) {
11
+ super(attr.client);
12
+ Object.assign(this, attr);
13
+ this.replies = new CommentReplies_1.CommentReplies({ client: attr.client, comment: this });
14
+ }
15
+ /**
16
+ * Load this instance with raw data from Youtube
17
+ *
18
+ * @hidden
19
+ */
20
+ load(data) {
21
+ CommentParser_1.CommentParser.loadComment(this, data);
22
+ return this;
23
+ }
24
+ /** URL to the video with this comment being highlighted (appears on top of the comment section) */
25
+ get url() {
26
+ return `https://www.youtube.com/watch?v=${this.video.id}&lc=${this.id}`;
27
+ }
28
+ }
29
+ exports.Comment = Comment;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommentParser = void 0;
4
+ const common_1 = require("../../common");
5
+ const BaseChannel_1 = require("../BaseChannel");
6
+ const Reply_1 = require("../Reply");
7
+ const Thumbnails_1 = require("../Thumbnails");
8
+ class CommentParser {
9
+ static loadComment(target, data) {
10
+ const { authorText, authorThumbnail, authorEndpoint, contentText, publishedTimeText, commentId, voteCount, authorIsChannelOwner, pinnedCommentBadge, replyCount, } = data.comment.commentRenderer;
11
+ // Basic information
12
+ target.id = commentId;
13
+ target.content = contentText.runs.map((r) => r.text).join("");
14
+ target.publishDate = publishedTimeText.runs.shift().text;
15
+ target.likeCount = +((voteCount === null || voteCount === void 0 ? void 0 : voteCount.simpleText) || 0);
16
+ target.isAuthorChannelOwner = authorIsChannelOwner;
17
+ target.isPinned = !!pinnedCommentBadge;
18
+ target.replyCount = replyCount;
19
+ // Reply Continuation
20
+ target.replies.continuation = data.replies
21
+ ? common_1.getContinuationFromItems(data.replies.commentRepliesRenderer.contents)
22
+ : undefined;
23
+ // Author
24
+ const { browseId } = authorEndpoint.browseEndpoint;
25
+ target.author = new BaseChannel_1.BaseChannel({
26
+ id: browseId,
27
+ name: authorText.simpleText,
28
+ thumbnails: new Thumbnails_1.Thumbnails().load(authorThumbnail.thumbnails),
29
+ client: target.client,
30
+ });
31
+ return target;
32
+ }
33
+ static parseContinuation(data) {
34
+ const continuationItems = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
35
+ return common_1.getContinuationFromItems(continuationItems, ["button", "buttonRenderer", "command"]);
36
+ }
37
+ static parseReplies(data, comment) {
38
+ const continuationItems = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
39
+ const rawReplies = common_1.mapFilter(continuationItems, "commentRenderer");
40
+ return rawReplies.map((i) => new Reply_1.Reply({ video: comment.video, comment, client: comment.client }).load(i));
41
+ }
42
+ }
43
+ exports.CommentParser = CommentParser;
@@ -0,0 +1,36 @@
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
+ exports.CommentReplies = void 0;
13
+ const constants_1 = require("../../constants");
14
+ const Continuable_1 = require("../Continuable");
15
+ const CommentParser_1 = require("./CommentParser");
16
+ /**
17
+ * {@link Continuable} of replies inside a {@link Comment}
18
+ */
19
+ class CommentReplies extends Continuable_1.Continuable {
20
+ /** @hidden */
21
+ constructor({ client, comment }) {
22
+ super({ client, strictContinuationCheck: true });
23
+ this.comment = comment;
24
+ }
25
+ fetch() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const response = yield this.client.http.post(`${constants_1.I_END_POINT}/next`, {
28
+ data: { continuation: this.continuation },
29
+ });
30
+ const continuation = CommentParser_1.CommentParser.parseContinuation(response.data);
31
+ const items = CommentParser_1.CommentParser.parseReplies(response.data, this.comment);
32
+ return { continuation, items };
33
+ });
34
+ }
35
+ }
36
+ exports.CommentReplies = CommentReplies;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Comment"), exports);
@@ -0,0 +1,43 @@
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
+ exports.Continuable = void 0;
13
+ const Base_1 = require("../Base");
14
+ /** Represents a continuable list of items `T` (like pagination) */
15
+ class Continuable extends Base_1.Base {
16
+ /** @hidden */
17
+ constructor({ client, strictContinuationCheck }) {
18
+ super(client);
19
+ this.items = [];
20
+ this.strictContinuationCheck = !!strictContinuationCheck;
21
+ if (this.strictContinuationCheck)
22
+ this.continuation = null;
23
+ }
24
+ /** Fetch next items using continuation token */
25
+ next(count = 1) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const newItems = [];
28
+ for (let i = 0; i < count || count == 0; i++) {
29
+ if (!this.hasContinuation)
30
+ break;
31
+ const { items, continuation } = yield this.fetch();
32
+ this.continuation = continuation;
33
+ newItems.push(...items);
34
+ }
35
+ this.items.push(...newItems);
36
+ return newItems;
37
+ });
38
+ }
39
+ get hasContinuation() {
40
+ return this.strictContinuationCheck ? this.continuation !== undefined : !!this.continuation;
41
+ }
42
+ }
43
+ exports.Continuable = Continuable;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Continuable"), exports);
@@ -0,0 +1,84 @@
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
+ exports.LiveVideo = void 0;
13
+ const events_1 = require("events");
14
+ const common_1 = require("../../common");
15
+ const constants_1 = require("../../constants");
16
+ const BaseVideo_1 = require("../BaseVideo");
17
+ const Chat_1 = require("../Chat");
18
+ const LiveVideoParser_1 = require("./LiveVideoParser");
19
+ /** Represents a video that's currently live, usually returned from `client.getVideo()` */
20
+ class LiveVideo extends BaseVideo_1.BaseVideo {
21
+ /** @hidden */
22
+ constructor(attr) {
23
+ super(attr);
24
+ this._delay = 0;
25
+ this._timeoutMs = 0;
26
+ this._isChatPlaying = false;
27
+ this._chatQueue = [];
28
+ Object.assign(this, attr);
29
+ }
30
+ /**
31
+ * Load this instance with raw data from Youtube
32
+ *
33
+ * @hidden
34
+ */
35
+ load(data) {
36
+ super.load(data);
37
+ LiveVideoParser_1.LiveVideoParser.loadLiveVideo(this, data);
38
+ return this;
39
+ }
40
+ /**
41
+ * Start polling for get live chat request
42
+ *
43
+ * @param delay chat delay in millisecond
44
+ */
45
+ playChat(delay = 0) {
46
+ if (this._isChatPlaying)
47
+ return;
48
+ this._delay = delay;
49
+ this._isChatPlaying = true;
50
+ this.pollChatContinuation();
51
+ }
52
+ /** Stop request polling for live chat */
53
+ stopChat() {
54
+ if (!this._chatRequestPoolingTimeout)
55
+ return;
56
+ this._isChatPlaying = false;
57
+ clearTimeout(this._chatRequestPoolingTimeout);
58
+ }
59
+ /** Start request polling */
60
+ pollChatContinuation() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const response = yield this.client.http.post(constants_1.LIVE_CHAT_END_POINT, {
63
+ data: { continuation: this.chatContinuation },
64
+ });
65
+ if (!response.data.continuationContents)
66
+ return;
67
+ const chats = LiveVideoParser_1.LiveVideoParser.parseChats(response.data);
68
+ for (const c of chats) {
69
+ const chat = new Chat_1.Chat({ client: this.client }).load(c);
70
+ if (this._chatQueue.find((c) => c.id === chat.id))
71
+ continue;
72
+ this._chatQueue.push(chat);
73
+ const timeout = chat.timestamp / 1000 - (new Date().getTime() - this._delay);
74
+ setTimeout(() => this.emit("chat", chat), timeout);
75
+ }
76
+ const { timeout, continuation } = LiveVideoParser_1.LiveVideoParser.parseContinuation(response.data);
77
+ this._timeoutMs = timeout;
78
+ this.chatContinuation = continuation;
79
+ this._chatRequestPoolingTimeout = setTimeout(() => this.pollChatContinuation(), this._timeoutMs);
80
+ });
81
+ }
82
+ }
83
+ exports.LiveVideo = LiveVideo;
84
+ common_1.applyMixins(LiveVideo, [events_1.EventEmitter]);
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiveVideoParser = void 0;
4
+ const BaseVideo_1 = require("../BaseVideo");
5
+ class LiveVideoParser {
6
+ static loadLiveVideo(target, data) {
7
+ var _a;
8
+ const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
9
+ target.watchingCount = +videoInfo.viewCount.videoViewCountRenderer.viewCount.runs
10
+ .map((r) => r.text)
11
+ .join(" ")
12
+ .replace(/[^0-9]/g, "");
13
+ target.chatContinuation = (_a = data[3].response.contents.twoColumnWatchNextResults.conversationBar.liveChatRenderer) === null || _a === void 0 ? void 0 : _a.continuations[0].reloadContinuationData.continuation;
14
+ return target;
15
+ }
16
+ static parseChats(data) {
17
+ var _a;
18
+ return (((_a = data.continuationContents.liveChatContinuation.actions) === null || _a === void 0 ? void 0 : _a.flatMap((a) => { var _a; return ((_a = a.addChatItemAction) === null || _a === void 0 ? void 0 : _a.item.liveChatTextMessageRenderer) || []; })) || []);
19
+ }
20
+ static parseContinuation(data) {
21
+ const continuation = data.continuationContents.liveChatContinuation.continuations[0];
22
+ const continuationData = continuation.timedContinuationData || continuation.invalidationContinuationData;
23
+ return {
24
+ timeout: continuationData.timeoutMs,
25
+ continuation: continuationData.continuation,
26
+ };
27
+ }
28
+ }
29
+ exports.LiveVideoParser = LiveVideoParser;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./LiveVideo"), exports);
14
+ __exportStar(require("./LiveVideoParser"), exports);
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MixPlaylist = void 0;
4
+ const Base_1 = require("../Base");
5
+ const MixPlaylistParser_1 = require("./MixPlaylistParser");
6
+ /** Represents a MixPlaylist, usually returned from `client.getPlaylist()` */
7
+ class MixPlaylist extends Base_1.Base {
8
+ /** @hidden */
9
+ constructor(attr) {
10
+ super(attr.client);
11
+ /** How many viewers does this playlist have */
12
+ this.videos = [];
13
+ Object.assign(this, attr);
14
+ }
15
+ /**
16
+ * Load this instance with raw data from Youtube
17
+ *
18
+ * @hidden
19
+ */
20
+ load(data) {
21
+ MixPlaylistParser_1.MixPlaylistParser.loadMixPlaylist(this, data);
22
+ return this;
23
+ }
24
+ }
25
+ exports.MixPlaylist = MixPlaylist;