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.
Files changed (227) 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 +14 -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 +14 -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 +15 -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/SearchResult/SearchResult.js +85 -0
  46. package/dist/cjs/classes/SearchResult/SearchResultParser.js +40 -0
  47. package/dist/cjs/classes/SearchResult/index.js +14 -0
  48. package/dist/cjs/classes/SearchResult/proto/SearchProto.js +2 -0
  49. package/dist/cjs/classes/SearchResult/proto/index.js +57 -0
  50. package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -50
  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 +15 -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 -15
  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 +2 -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 +2 -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 +3 -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/SearchResult/SearchResult.js +161 -0
  110. package/dist/esm/classes/SearchResult/SearchResultParser.js +62 -0
  111. package/dist/esm/classes/SearchResult/index.js +2 -0
  112. package/dist/esm/classes/SearchResult/proto/SearchProto.js +1 -0
  113. package/dist/esm/classes/SearchResult/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 +3 -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 +2 -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 +2 -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 +3 -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/SearchResult/SearchResult.d.ts +53 -0
  174. package/dist/typings/classes/SearchResult/SearchResultParser.d.ts +13 -0
  175. package/dist/typings/classes/SearchResult/index.d.ts +2 -0
  176. package/dist/typings/classes/SearchResult/proto/SearchProto.d.ts +13 -0
  177. package/dist/typings/classes/SearchResult/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 +3 -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 -7
  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 -2
  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 -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/Chat.d.ts +0 -35
  202. package/dist/classes/Chat.js +0 -34
  203. package/dist/classes/Client.d.ts +0 -17
  204. package/dist/classes/Client.js +0 -59
  205. package/dist/classes/Comment.d.ts +0 -51
  206. package/dist/classes/Comment.js +0 -47
  207. package/dist/classes/LiveVideo.d.ts +0 -20
  208. package/dist/classes/LiveVideo.js +0 -59
  209. package/dist/classes/Playlist.d.ts +0 -66
  210. package/dist/classes/Playlist.js +0 -133
  211. package/dist/classes/PlaylistCompact.d.ts +0 -35
  212. package/dist/classes/PlaylistCompact.js +0 -47
  213. package/dist/classes/SearchResult.d.ts +0 -51
  214. package/dist/classes/SearchResult.js +0 -121
  215. package/dist/classes/Thumbnails.d.ts +0 -26
  216. package/dist/classes/Video.d.ts +0 -90
  217. package/dist/classes/Video.js +0 -153
  218. package/dist/classes/VideoCompact.d.ts +0 -46
  219. package/dist/classes/VideoCompact.js +0 -53
  220. package/dist/classes/index.d.ts +0 -12
  221. package/dist/classes/index.js +0 -30
  222. package/dist/common/helper.d.ts +0 -4
  223. package/dist/common/helper.js +0 -39
  224. package/dist/common/http.d.ts +0 -33
  225. package/dist/common/http.js +0 -105
  226. package/dist/common/index.d.ts +0 -5
  227. package/dist/common/mixins.d.ts +0 -2
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Video = void 0;
4
+ const BaseVideo_1 = require("../BaseVideo");
5
+ const VideoComments_1 = require("./VideoComments");
6
+ const VideoParser_1 = require("./VideoParser");
7
+ /** Represents a Video, usually returned from `client.getVideo()` */
8
+ class Video extends BaseVideo_1.BaseVideo {
9
+ /** @hidden */
10
+ constructor(attr) {
11
+ super(attr);
12
+ Object.assign(this, attr);
13
+ this.comments = new VideoComments_1.VideoComments({ client: attr.client, video: this });
14
+ }
15
+ /**
16
+ * Load this instance with raw data from Youtube
17
+ *
18
+ * @hidden
19
+ */
20
+ load(data) {
21
+ super.load(data);
22
+ VideoParser_1.VideoParser.loadVideo(this, data);
23
+ return this;
24
+ }
25
+ }
26
+ exports.Video = Video;
@@ -0,0 +1,53 @@
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.VideoComments = void 0;
13
+ const constants_1 = require("../../constants");
14
+ const Continuable_1 = require("../Continuable");
15
+ const VideoParser_1 = require("./VideoParser");
16
+ /**
17
+ * {@link Continuable} of videos inside a {@link Video}
18
+ *
19
+ * @example
20
+ * ```js
21
+ * const video = await youtube.getVideo(VIDEO_ID);
22
+ * await video.comments.next();
23
+ * console.log(video.comments) // first 20 comments
24
+ *
25
+ * let newComments = await video.comments.next();
26
+ * console.log(newComments) // 20 loaded comments
27
+ * console.log(video.comments) // first 40 comments
28
+ *
29
+ * await video.comments.next(0); // load the rest of the comments in the video
30
+ * ```
31
+ *
32
+ * @param count How many times to load the next comments. Set 0 to load all comments (might take a while on a video with many comments!)
33
+ *
34
+ * @returns Loaded comments
35
+ */
36
+ class VideoComments extends Continuable_1.Continuable {
37
+ /** @hidden */
38
+ constructor({ client, video }) {
39
+ super({ client, strictContinuationCheck: true });
40
+ this.video = video;
41
+ }
42
+ fetch() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const response = yield this.client.http.post(`${constants_1.I_END_POINT}/next`, {
45
+ data: { continuation: this.continuation },
46
+ });
47
+ const items = VideoParser_1.VideoParser.parseComments(response.data, this.video);
48
+ const continuation = VideoParser_1.VideoParser.parseCommentContinuation(response.data);
49
+ return { continuation, items };
50
+ });
51
+ }
52
+ }
53
+ exports.VideoComments = VideoComments;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoParser = void 0;
4
+ const common_1 = require("../../common");
5
+ const BaseVideo_1 = require("../BaseVideo");
6
+ const Comment_1 = require("../Comment");
7
+ class VideoParser {
8
+ static loadVideo(target, data) {
9
+ const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
10
+ target.duration = +videoInfo.videoDetails.lengthSeconds;
11
+ const itemSectionRenderer = data[3].response.contents.twoColumnWatchNextResults.results.results.contents
12
+ .reverse()
13
+ .find((c) => c.itemSectionRenderer).itemSectionRenderer;
14
+ target.comments.continuation = common_1.getContinuationFromItems(itemSectionRenderer.contents);
15
+ return target;
16
+ }
17
+ static parseComments(data, video) {
18
+ const endpoints = data.onResponseReceivedEndpoints.at(-1);
19
+ const continuationItems = (endpoints.reloadContinuationItemsCommand || endpoints.appendContinuationItemsAction).continuationItems;
20
+ const comments = common_1.mapFilter(continuationItems, "commentThreadRenderer");
21
+ return comments.map((c) => new Comment_1.Comment({ video, client: video.client }).load(c));
22
+ }
23
+ static parseCommentContinuation(data) {
24
+ const endpoints = data.onResponseReceivedEndpoints.at(-1);
25
+ const continuationItems = (endpoints.reloadContinuationItemsCommand || endpoints.appendContinuationItemsAction).continuationItems;
26
+ return common_1.getContinuationFromItems(continuationItems);
27
+ }
28
+ }
29
+ exports.VideoParser = VideoParser;
@@ -0,0 +1,15 @@
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("./Video"), exports);
14
+ __exportStar(require("./VideoComments"), exports);
15
+ __exportStar(require("./VideoParser"), exports);
@@ -0,0 +1,49 @@
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.VideoCompact = void 0;
13
+ const Base_1 = require("../Base");
14
+ const VideoCompactParser_1 = require("./VideoCompactParser");
15
+ /** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
16
+ class VideoCompact extends Base_1.Base {
17
+ /** @hidden */
18
+ constructor(attr) {
19
+ super(attr.client);
20
+ Object.assign(this, attr);
21
+ }
22
+ /** Whether this video is private / deleted or not, only useful in playlist's videos */
23
+ get isPrivateOrDeleted() {
24
+ return !this.duration;
25
+ }
26
+ /**
27
+ * Load this instance with raw data from Youtube
28
+ *
29
+ * @hidden
30
+ */
31
+ load(data) {
32
+ VideoCompactParser_1.VideoCompactParser.loadVideoCompact(this, data);
33
+ return this;
34
+ }
35
+ /**
36
+ * Get {@link Video} object based on current video id
37
+ *
38
+ * Equivalent to
39
+ * ```js
40
+ * client.getVideo(videoCompact.id);
41
+ * ```
42
+ */
43
+ getVideo() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ return yield this.client.getVideo(this.id);
46
+ });
47
+ }
48
+ }
49
+ exports.VideoCompact = VideoCompact;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoCompactParser = void 0;
4
+ const common_1 = require("../../common");
5
+ const BaseChannel_1 = require("../BaseChannel");
6
+ const Thumbnails_1 = require("../Thumbnails");
7
+ class VideoCompactParser {
8
+ static loadVideoCompact(target, data) {
9
+ var _a, _b;
10
+ const { videoId, title, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
11
+ target.id = videoId;
12
+ target.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
13
+ target.thumbnails = new Thumbnails_1.Thumbnails().load(thumbnail.thumbnails);
14
+ target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
15
+ target.description =
16
+ (detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs.map((r) => r.text).join("")) || "";
17
+ target.duration =
18
+ common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_b = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _b === void 0 ? void 0 : _b.text.simpleText) ||
19
+ "") || null;
20
+ target.isLive = !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW");
21
+ // Channel
22
+ if (ownerText || shortBylineText) {
23
+ const { browseId } = (ownerText || shortBylineText).runs[0].navigationEndpoint.browseEndpoint;
24
+ const thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
25
+ target.channel = new BaseChannel_1.BaseChannel({
26
+ id: browseId,
27
+ name: (ownerText || shortBylineText).runs[0].text,
28
+ thumbnails: thumbnails ? new Thumbnails_1.Thumbnails().load(thumbnails) : undefined,
29
+ client: target.client,
30
+ });
31
+ }
32
+ target.viewCount = common_1.stripToInt((viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) || (viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text));
33
+ return target;
34
+ }
35
+ }
36
+ exports.VideoCompactParser = VideoCompactParser;
@@ -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("./VideoCompact"), exports);
14
+ __exportStar(require("./VideoCompactParser"), exports);
@@ -0,0 +1,29 @@
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("./Base"), exports);
14
+ __exportStar(require("./BaseChannel"), exports);
15
+ __exportStar(require("./BaseVideo"), exports);
16
+ __exportStar(require("./Channel"), exports);
17
+ __exportStar(require("./Chat"), exports);
18
+ __exportStar(require("./Client"), exports);
19
+ __exportStar(require("./Comment"), exports);
20
+ __exportStar(require("./Continuable"), exports);
21
+ __exportStar(require("./LiveVideo"), exports);
22
+ __exportStar(require("./MixPlaylist"), exports);
23
+ __exportStar(require("./Playlist"), exports);
24
+ __exportStar(require("./PlaylistCompact"), exports);
25
+ __exportStar(require("./Reply"), exports);
26
+ __exportStar(require("./SearchResult"), exports);
27
+ __exportStar(require("./Thumbnails"), exports);
28
+ __exportStar(require("./Video"), exports);
29
+ __exportStar(require("./VideoCompact"), exports);
@@ -1,15 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extendsBuiltIn = void 0;
4
- /** @hidden */
5
- function extendsBuiltIn() {
6
- return (target) => {
7
- return class extends target {
8
- constructor(...args) {
9
- super(args);
10
- Object.setPrototypeOf(this, target.prototype);
11
- }
12
- };
13
- };
14
- }
15
- exports.extendsBuiltIn = extendsBuiltIn;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendsBuiltIn = void 0;
4
+ function extendsBuiltIn() {
5
+ return (target) => {
6
+ return class extends target {
7
+ constructor(...args) {
8
+ super(args);
9
+ Object.setPrototypeOf(this, target.prototype);
10
+ }
11
+ };
12
+ };
13
+ }
14
+ exports.extendsBuiltIn = extendsBuiltIn;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapFilter = exports.getContinuationFromItems = exports.stripToInt = exports.getDuration = void 0;
4
+ const getDuration = (s) => {
5
+ s = s.replace(/:/g, ".");
6
+ const spl = s.split(".");
7
+ if (spl.length === 0)
8
+ return +spl;
9
+ else {
10
+ const sumStr = spl.pop();
11
+ let sum = +sumStr;
12
+ if (spl.length === 1)
13
+ sum += +spl[0] * 60;
14
+ if (spl.length === 2) {
15
+ sum += +spl[1] * 60;
16
+ sum += +spl[0] * 3600;
17
+ }
18
+ return sum;
19
+ }
20
+ };
21
+ exports.getDuration = getDuration;
22
+ const stripToInt = (string) => {
23
+ if (!string)
24
+ return null;
25
+ return +string.replace(/[^0-9]/g, "");
26
+ };
27
+ exports.stripToInt = stripToInt;
28
+ const getContinuationFromItems = (items, accessors = ["continuationEndpoint"]) => {
29
+ const continuation = items[items.length - 1];
30
+ const renderer = continuation === null || continuation === void 0 ? void 0 : continuation.continuationItemRenderer;
31
+ if (!renderer)
32
+ return;
33
+ let current = renderer;
34
+ for (const accessor of accessors) {
35
+ current = current[accessor];
36
+ }
37
+ return current.continuationCommand.token;
38
+ };
39
+ exports.getContinuationFromItems = getContinuationFromItems;
40
+ const mapFilter = (items, key) => {
41
+ return items
42
+ .filter((item) => item[key])
43
+ .map((item) => item[key]);
44
+ };
45
+ exports.mapFilter = mapFilter;
@@ -1,23 +1,16 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.applyMixins = exports.http = void 0;
17
- var http_1 = require("./http");
18
- Object.defineProperty(exports, "http", { enumerable: true, get: function () { return __importDefault(http_1).default; } });
19
- __exportStar(require("./helper"), exports);
20
- __exportStar(require("./types"), exports);
21
- __exportStar(require("./decorators"), exports);
22
- var mixins_1 = require("./mixins");
23
- Object.defineProperty(exports, "applyMixins", { enumerable: true, get: function () { return __importDefault(mixins_1).default; } });
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("./decorators"), exports);
14
+ __exportStar(require("./helper"), exports);
15
+ __exportStar(require("./mixins"), exports);
16
+ __exportStar(require("./types"), exports);
@@ -1,12 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
4
- exports.default = (derivedCtor, baseCtors) => {
5
- baseCtors.forEach((baseCtor) => {
6
- Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
7
- if (name !== "constructor") {
8
- derivedCtor.prototype[name] = baseCtor.prototype[name];
9
- }
10
- });
11
- });
12
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyMixins = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
5
+ const applyMixins = (derivedCtor, baseCtors) => {
6
+ baseCtors.forEach((baseCtor) => {
7
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
8
+ if (name !== "constructor") {
9
+ derivedCtor.prototype[name] = baseCtor.prototype[name];
10
+ }
11
+ });
12
+ });
13
+ };
14
+ exports.applyMixins = applyMixins;
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COMMENT_END_POINT = exports.WATCH_END_POINT = exports.LIVE_CHAT_END_POINT = exports.I_END_POINT = exports.BASE_URL = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_VERSION = void 0;
4
- exports.INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
5
- exports.INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
6
- exports.BASE_URL = "www.youtube.com";
7
- exports.I_END_POINT = "/youtubei/v1";
8
- exports.LIVE_CHAT_END_POINT = `${exports.I_END_POINT}/live_chat/get_live_chat`;
9
- exports.WATCH_END_POINT = "/watch";
10
- exports.COMMENT_END_POINT = "/comment_service_ajax";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMMENT_END_POINT = exports.WATCH_END_POINT = exports.LIVE_CHAT_END_POINT = exports.I_END_POINT = exports.BASE_URL = exports.INNERTUBE_API_KEY = exports.INNERTUBE_CLIENT_VERSION = void 0;
4
+ exports.INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
5
+ exports.INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
6
+ exports.BASE_URL = "www.youtube.com";
7
+ exports.I_END_POINT = "/youtubei/v1";
8
+ exports.LIVE_CHAT_END_POINT = `${exports.I_END_POINT}/live_chat/get_live_chat`;
9
+ exports.WATCH_END_POINT = "/watch";
10
+ exports.COMMENT_END_POINT = "/comment_service_ajax";
@@ -1,13 +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("./classes"), exports);
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("./classes"), exports);
@@ -0,0 +1,8 @@
1
+ var Base = /** @class */ (function () {
2
+ /** @hidden */
3
+ function Base(client) {
4
+ this.client = client;
5
+ }
6
+ return Base;
7
+ }());
8
+ export { Base };
@@ -0,0 +1 @@
1
+ export * from "./Base";
@@ -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 };