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
@@ -1,12 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const _1 = require(".");
7
- const util_1 = require("util");
8
- const events_1 = __importDefault(require("events"));
9
- class LiveVideo extends _1.Video {
10
- }
11
- exports.default = LiveVideo;
12
- util_1.inherits(LiveVideo, events_1.default);
@@ -1,66 +0,0 @@
1
- import { YoutubeRawData } from "../common";
2
- import Channel from "./Channel";
3
- import VideoCompact from "./VideoCompact";
4
- /** @hidden */
5
- interface PlaylistAttributes {
6
- id: string;
7
- title: string;
8
- videoCount: number;
9
- viewCount: number;
10
- lastUpdatedAt: string;
11
- channel?: Channel;
12
- videos: VideoCompact[];
13
- }
14
- /** Represents a Playlist, usually returned from `client.getPlaylist()` */
15
- export default class Playlist implements PlaylistAttributes {
16
- /** The playlist's ID */
17
- id: string;
18
- /** The title of this playlist */
19
- title: string;
20
- /** How many videos in this playlist */
21
- videoCount: number;
22
- /** How many viewers does this playlist have */
23
- viewCount: number;
24
- /** Last time this playlist is updated */
25
- lastUpdatedAt: string;
26
- /** The channel that made this playlist */
27
- channel?: Channel;
28
- /** Videos in the playlist */
29
- videos: VideoCompact[];
30
- private _continuation;
31
- /** @hidden */
32
- constructor(playlist?: Partial<Playlist>);
33
- /**
34
- * Load instance attributes from youtube raw data
35
- *
36
- * @param youtubeRawData raw object from youtubei
37
- * @hidden
38
- */
39
- load(youtubeRawData: YoutubeRawData): Playlist;
40
- /**
41
- * Load next 100 videos of the playlist
42
- *
43
- * @example
44
- * ```js
45
- * const playlist = await youtube.getPlaylist(PLAYLIST_ID);
46
- * console.log(playlist.videos) // first 100 videos
47
- *
48
- * let newVideos = await playlist.next();
49
- * console.log(newVideos) // 100 loaded videos
50
- * console.log(playlist.videos) // first 200 videos
51
- *
52
- * await playlist.next(0); // load the rest of the videos in the playlist
53
- * ```
54
- *
55
- * @param count How many times to load the next videos. Set 0 to load all videos (might take a while on a large playlist!)
56
- */
57
- next(count?: number): Promise<VideoCompact[]>;
58
- /**
59
- * Get compact videos
60
- *
61
- * @param playlistContents raw object from youtubei
62
- */
63
- private static getVideos;
64
- private static getSideBarInfo;
65
- }
66
- export {};
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const _1 = require(".");
16
- const common_1 = require("../common");
17
- const constants_1 = require("../constants");
18
- const Channel_1 = __importDefault(require("./Channel"));
19
- const VideoCompact_1 = __importDefault(require("./VideoCompact"));
20
- /** Represents a Playlist, usually returned from `client.getPlaylist()` */
21
- class Playlist {
22
- /** @hidden */
23
- constructor(playlist = {}) {
24
- Object.assign(this, playlist);
25
- }
26
- /**
27
- * Load instance attributes from youtube raw data
28
- *
29
- * @param youtubeRawData raw object from youtubei
30
- * @hidden
31
- */
32
- load(youtubeRawData) {
33
- var _a, _b;
34
- const sidebarRenderer = youtubeRawData.sidebar.playlistSidebarRenderer.items;
35
- const primaryRenderer = sidebarRenderer[0].playlistSidebarPrimaryInfoRenderer;
36
- // Basic information
37
- this.id = primaryRenderer.title.runs[0].navigationEndpoint.watchEndpoint.playlistId;
38
- this.title = primaryRenderer.title.runs[0].text;
39
- const { stats } = primaryRenderer;
40
- if (primaryRenderer.stats.length === 3) {
41
- this.videoCount = Playlist.getSideBarInfo(stats[0], true);
42
- this.viewCount = Playlist.getSideBarInfo(stats[1], true);
43
- this.lastUpdatedAt = Playlist.getSideBarInfo(stats[2], false);
44
- }
45
- else if (stats.length === 2) {
46
- this.videoCount = Playlist.getSideBarInfo(stats[0], true);
47
- this.lastUpdatedAt = Playlist.getSideBarInfo(stats[1], false);
48
- }
49
- // Videos
50
- const playlistContents = youtubeRawData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
51
- .sectionListRenderer.contents[0].itemSectionRenderer.contents[0]
52
- .playlistVideoListRenderer.contents;
53
- const videos = Playlist.getVideos(playlistContents);
54
- // Video Continuation Token
55
- this._continuation = (_a = playlistContents[100]) === null || _a === void 0 ? void 0 : _a.continuationItemRenderer.continuationEndpoint.continuationCommand.token;
56
- this.videos = videos;
57
- // Channel
58
- const videoOwner = ((_b = sidebarRenderer[1]) === null || _b === void 0 ? void 0 : _b.playlistSidebarSecondaryInfoRenderer.videoOwner) || undefined;
59
- if (videoOwner) {
60
- const { title, thumbnail } = videoOwner.videoOwnerRenderer;
61
- this.channel = new Channel_1.default({
62
- id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
63
- name: title.runs[0].text,
64
- thumbnails: new _1.Thumbnails().load(thumbnail.thumbnails),
65
- url: "https://www.youtube.com" +
66
- title.runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url,
67
- });
68
- }
69
- return this;
70
- }
71
- /**
72
- * Load next 100 videos of the playlist
73
- *
74
- * @example
75
- * ```js
76
- * const playlist = await youtube.getPlaylist(PLAYLIST_ID);
77
- * console.log(playlist.videos) // first 100 videos
78
- *
79
- * let newVideos = await playlist.next();
80
- * console.log(newVideos) // 100 loaded videos
81
- * console.log(playlist.videos) // first 200 videos
82
- *
83
- * await playlist.next(0); // load the rest of the videos in the playlist
84
- * ```
85
- *
86
- * @param count How many times to load the next videos. Set 0 to load all videos (might take a while on a large playlist!)
87
- */
88
- next(count = 1) {
89
- var _a;
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const newVideos = [];
92
- for (let i = 0; i < count || count == 0; i++) {
93
- if (!this._continuation)
94
- break;
95
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
96
- data: { continuation: this._continuation },
97
- });
98
- const playlistContents = response.data.onResponseReceivedActions[0].appendContinuationItemsAction
99
- .continuationItems;
100
- newVideos.push(...Playlist.getVideos(playlistContents));
101
- this._continuation = (_a = playlistContents[100]) === null || _a === void 0 ? void 0 : _a.continuationItemRenderer.continuationEndpoint.continuationCommand.token;
102
- }
103
- this.videos.push(...newVideos);
104
- return newVideos;
105
- });
106
- }
107
- /**
108
- * Get compact videos
109
- *
110
- * @param playlistContents raw object from youtubei
111
- */
112
- static getVideos(playlistContents) {
113
- const videosRenderer = playlistContents.map((c) => c.playlistVideoRenderer);
114
- const videos = [];
115
- for (const videoRenderer of videosRenderer) {
116
- if (!videoRenderer)
117
- continue;
118
- videos.push(new VideoCompact_1.default().load(videoRenderer));
119
- }
120
- return videos;
121
- }
122
- static getSideBarInfo(stats, parseInt) {
123
- let data;
124
- if ("runs" in stats)
125
- data = stats.runs.map((r) => r.text).join("");
126
- else
127
- data = stats.simpleText.replace(/[^0-9]/g, "");
128
- if (parseInt)
129
- data = +data.replace(/[^0-9]/g, "");
130
- return data;
131
- }
132
- }
133
- exports.default = Playlist;
@@ -1,35 +0,0 @@
1
- import { Thumbnails } from ".";
2
- import { YoutubeRawData } from "../common";
3
- import Base from "./Base";
4
- import Channel from "./Channel";
5
- /** @hidden */
6
- interface PlaylistCompactAttributes {
7
- id: string;
8
- title: string;
9
- thumbnails: Thumbnails;
10
- channel?: Channel;
11
- videoCount: number;
12
- }
13
- /** Represents a Compact Playlist (e.g. from search result, upNext / related of a video) */
14
- export default class PlaylistCompact extends Base implements PlaylistCompactAttributes {
15
- /** The playlist's ID */
16
- id: string;
17
- /** The playlist's title */
18
- title: string;
19
- /** Thumbnails of the playlist with different sizes */
20
- thumbnails: Thumbnails;
21
- /** The channel that made this playlist */
22
- channel?: Channel;
23
- /** How many videos in this playlist */
24
- videoCount: number;
25
- /** @hidden */
26
- constructor(playlist?: Partial<PlaylistCompactAttributes>);
27
- /**
28
- * Load instance attributes from youtube raw data
29
- *
30
- * @param youtubeRawData raw object from youtubei
31
- * @hidden
32
- */
33
- load(youtubeRawData: YoutubeRawData): PlaylistCompact;
34
- }
35
- export {};
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const _1 = require(".");
7
- const Base_1 = __importDefault(require("./Base"));
8
- const Channel_1 = __importDefault(require("./Channel"));
9
- /** Represents a Compact Playlist (e.g. from search result, upNext / related of a video) */
10
- class PlaylistCompact extends Base_1.default {
11
- /** @hidden */
12
- constructor(playlist = {}) {
13
- super();
14
- Object.assign(this, playlist);
15
- }
16
- /**
17
- * Load instance attributes from youtube raw data
18
- *
19
- * @param youtubeRawData raw object from youtubei
20
- * @hidden
21
- */
22
- load(youtubeRawData) {
23
- var _a;
24
- const { playlistId, title, thumbnail, shortBylineText, videoCount, videoCountShortText, } = youtubeRawData;
25
- this.id = playlistId;
26
- this.title = title.simpleText || title.runs[0].text;
27
- this.videoCount =
28
- +((_a = (videoCount !== null && videoCount !== void 0 ? videoCount : videoCountShortText.simpleText)) === null || _a === void 0 ? void 0 : _a.replace(/[^0-9]/g, "")) || 0;
29
- // Thumbnail
30
- let { thumbnails } = youtubeRawData;
31
- if (!thumbnails)
32
- thumbnails = thumbnail.thumbnails;
33
- else
34
- thumbnails = thumbnails[0].thumbnails;
35
- this.thumbnails = new _1.Thumbnails().load(thumbnails);
36
- // Channel
37
- if (shortBylineText && shortBylineText.simpleText !== "YouTube") {
38
- this.channel = new Channel_1.default({
39
- id: shortBylineText.runs[0].navigationEndpoint.browseEndpoint.browseId,
40
- name: shortBylineText.runs[0].text,
41
- url: `https://www.youtube.com${shortBylineText.runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url}`,
42
- });
43
- }
44
- return this;
45
- }
46
- }
47
- exports.default = PlaylistCompact;
@@ -1,52 +0,0 @@
1
- import { SearchOptions } from "./Client";
2
- import { Channel, PlaylistCompact, VideoCompact } from "..";
3
- export declare type SearchResultType<T> = T extends {
4
- type: "video";
5
- } ? VideoCompact : T extends {
6
- type: "channel";
7
- } ? Channel : T extends {
8
- type: "playlist";
9
- } ? PlaylistCompact : VideoCompact | Channel | PlaylistCompact;
10
- /**
11
- * Represents search result, usually returned from `client.search();`
12
- *
13
- * @noInheritDoc
14
- */
15
- export default class SearchResult<T> extends Array<SearchResultType<T>> {
16
- private _continuation;
17
- /** @hidden */
18
- constructor();
19
- /**
20
- * Initialize data from search
21
- *
22
- * @param query Search query
23
- * @param options Search Options
24
- * @hidden
25
- */
26
- init(query: string, options: SearchOptions): Promise<SearchResult<T>>;
27
- /**
28
- * Load next search data. Youtube returns inconsistent amount of search result, it usually varies from 18 to 20
29
- *
30
- * @example
31
- * ```js
32
- * const videos = await youtube.search("keyword", { type: "video" });
33
- * console.log(videos) // first 18-20 videos from the search result
34
- *
35
- * let newVideos = await videos.next();
36
- * console.log(newVideos) // 18-20 loaded videos
37
- * console.log(videos) // 36-40 first videos from the search result
38
- * ```
39
- *
40
- * @param count How many times to load the next data
41
- */
42
- next(count?: number): Promise<Array<SearchResultType<T>>>;
43
- /** Load videos data from youtube */
44
- private loadSearchResult;
45
- /**
46
- * Get type query value
47
- *
48
- * @param type Search type
49
- * @hidden
50
- */
51
- static getSearchTypeParam(type: "video" | "playlist" | "channel" | "all"): string;
52
- }
@@ -1,121 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
- var SearchResult_1;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- const constants_1 = require("../constants");
20
- const common_1 = require("../common");
21
- const __1 = require("..");
22
- /**
23
- * Represents search result, usually returned from `client.search();`
24
- *
25
- * @noInheritDoc
26
- */
27
- let SearchResult = SearchResult_1 = class SearchResult extends Array {
28
- /** @hidden */
29
- constructor() {
30
- super();
31
- }
32
- /**
33
- * Initialize data from search
34
- *
35
- * @param query Search query
36
- * @param options Search Options
37
- * @hidden
38
- */
39
- init(query, options) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/search`, {
42
- data: { query, params: SearchResult_1.getSearchTypeParam(options.type) },
43
- });
44
- this.loadSearchResult(response.data.contents.twoColumnSearchResultsRenderer.primaryContents
45
- .sectionListRenderer.contents);
46
- return this;
47
- });
48
- }
49
- /**
50
- * Load next search data. Youtube returns inconsistent amount of search result, it usually varies from 18 to 20
51
- *
52
- * @example
53
- * ```js
54
- * const videos = await youtube.search("keyword", { type: "video" });
55
- * console.log(videos) // first 18-20 videos from the search result
56
- *
57
- * let newVideos = await videos.next();
58
- * console.log(newVideos) // 18-20 loaded videos
59
- * console.log(videos) // 36-40 first videos from the search result
60
- * ```
61
- *
62
- * @param count How many times to load the next data
63
- */
64
- next(count = 1) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const newSearchResults = [];
67
- for (let i = 0; i < count; i++) {
68
- if (!this._continuation)
69
- break;
70
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/search`, {
71
- data: { continuation: this._continuation },
72
- });
73
- newSearchResults.push(...this.loadSearchResult(response.data.onResponseReceivedCommands[0].appendContinuationItemsAction
74
- .continuationItems));
75
- }
76
- this.push(...newSearchResults);
77
- return newSearchResults;
78
- });
79
- }
80
- /** Load videos data from youtube */
81
- loadSearchResult(sectionListContents) {
82
- var _a, _b;
83
- const contents = sectionListContents
84
- .filter((c) => "itemSectionRenderer" in c)
85
- .pop().itemSectionRenderer.contents;
86
- const continuationToken = (_b = (_a = sectionListContents
87
- .filter((c) => "continuationItemRenderer" in c)
88
- .pop().continuationItemRenderer) === null || _a === void 0 ? void 0 : _a.continuationEndpoint) === null || _b === void 0 ? void 0 : _b.continuationCommand.token;
89
- this._continuation = continuationToken;
90
- const newContent = [];
91
- for (const content of contents) {
92
- if ("playlistRenderer" in content)
93
- newContent.push(new __1.PlaylistCompact().load(content.playlistRenderer));
94
- else if ("videoRenderer" in content)
95
- newContent.push(new __1.VideoCompact().load(content.videoRenderer));
96
- else if ("channelRenderer" in content)
97
- newContent.push(new __1.Channel().load(content.channelRenderer));
98
- }
99
- this.push(...newContent);
100
- return newContent;
101
- }
102
- /**
103
- * Get type query value
104
- *
105
- * @param type Search type
106
- * @hidden
107
- */
108
- static getSearchTypeParam(type) {
109
- const searchType = {
110
- video: "EgIQAQ%3D%3D",
111
- playlist: "EgIQAw%3D%3D",
112
- channel: "EgIQAg%3D%3D",
113
- all: "",
114
- };
115
- return type in searchType ? searchType[type] : "";
116
- }
117
- };
118
- SearchResult = SearchResult_1 = __decorate([
119
- common_1.extendsBuiltIn()
120
- ], SearchResult);
121
- exports.default = SearchResult;
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from "events";
3
- /**
4
- * @noInheritDoc
5
- */
6
- export default class Test extends EventEmitter {
7
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const events_1 = require("events");
4
- /**
5
- * @noInheritDoc
6
- */
7
- class Test extends events_1.EventEmitter {
8
- }
9
- exports.default = Test;
@@ -1,23 +0,0 @@
1
- interface Thumbnail {
2
- url: string;
3
- width: number;
4
- height: number;
5
- }
6
- /**
7
- * Represents Thumbnails, usually found inside Playlist / Channel / Video, etc.
8
- *
9
- * @noInheritDoc
10
- */
11
- export default class Thumbnails extends Array<Thumbnail> {
12
- /** @hidden */
13
- constructor();
14
- /**
15
- * Load instance attributes from youtube raw data
16
- *
17
- * @hidden
18
- */
19
- load(thumbnails: Thumbnail[]): Thumbnails;
20
- /** Returns thumbnail with the highest resolution */
21
- get best(): string;
22
- }
23
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const common_1 = require("../common");
10
- /**
11
- * Represents Thumbnails, usually found inside Playlist / Channel / Video, etc.
12
- *
13
- * @noInheritDoc
14
- */
15
- let Thumbnails = class Thumbnails extends Array {
16
- /** @hidden */
17
- constructor() {
18
- super();
19
- }
20
- /**
21
- * Load instance attributes from youtube raw data
22
- *
23
- * @hidden
24
- */
25
- load(thumbnails) {
26
- this.push(...thumbnails);
27
- return this;
28
- }
29
- /** Returns thumbnail with the highest resolution */
30
- get best() {
31
- const thumbnail = this[this.length - 1].url;
32
- if (thumbnail.startsWith("//"))
33
- return `https:${thumbnail}`;
34
- if (!thumbnail.startsWith("https://"))
35
- return `https://${thumbnail}`;
36
- return thumbnail;
37
- }
38
- };
39
- Thumbnails = __decorate([
40
- common_1.extendsBuiltIn()
41
- ], Thumbnails);
42
- exports.default = Thumbnails;
@@ -1,90 +0,0 @@
1
- import { PlaylistCompact, VideoCompact, Channel, Base, Comment, Thumbnails } from ".";
2
- import { YoutubeRawData } from "../common";
3
- /**
4
- * @hidden
5
- * @ignore
6
- * @internal
7
- */
8
- interface VideoAttributes {
9
- id: string;
10
- title: string;
11
- duration: number | null;
12
- thumbnails: Thumbnails;
13
- description: string;
14
- channel: Channel;
15
- uploadDate: string;
16
- viewCount: number | null;
17
- likeCount: number | null;
18
- dislikeCount: number | null;
19
- isLiveContent: boolean;
20
- tags: string[];
21
- upNext: VideoCompact | PlaylistCompact;
22
- related: (VideoCompact | PlaylistCompact)[];
23
- comments: Comment[];
24
- }
25
- /** Represents a Video, usually returned from `client.getVideo()` */
26
- export default class Video extends Base implements VideoAttributes {
27
- /** The video's ID */
28
- id: string;
29
- /** The title of this video */
30
- title: string;
31
- /** The duration of this video in second, null if the video is live */
32
- duration: number | null;
33
- /** Thumbnails of the video with different sizes */
34
- thumbnails: Thumbnails;
35
- /** The description of this video */
36
- description: string;
37
- /** The channel who uploads this video */
38
- channel: Channel;
39
- /** The date this video is uploaded at */
40
- uploadDate: string;
41
- /** How many view does this video have, null if the view count is hidden */
42
- viewCount: number | null;
43
- /** How many like does this video have, null if the like count hidden */
44
- likeCount: number | null;
45
- /** How many dislike does this video have, null if the dislike count is hidden */
46
- dislikeCount: number | null;
47
- /** Whether this video is a live content or not */
48
- isLiveContent: boolean;
49
- /** The tags of this video */
50
- tags: string[];
51
- /** Next video / playlist recommended by Youtube */
52
- upNext: VideoCompact | PlaylistCompact;
53
- /** Videos / playlists related to this video */
54
- related: (VideoCompact | PlaylistCompact)[];
55
- /**
56
- * Comments of this video
57
- *
58
- * You need to load the comment first by calling `video.nextComments()` as youtube doesn't send any comments data when loading the video (from `client.getVideo()`)
59
- */
60
- comments: Comment[];
61
- private _commentContinuation?;
62
- /** @hidden */
63
- constructor(video?: Partial<VideoAttributes>);
64
- /**
65
- * Load instance attributes from youtube raw data
66
- *
67
- * @param youtubeRawData raw object from youtubei
68
- * @hidden
69
- */
70
- load(youtubeRawData: YoutubeRawData): Video;
71
- /**
72
- * Load next 20 comments of the video
73
- *
74
- * @example
75
- * ```js
76
- * const video = await youtube.getVideo(VIDEO_ID);
77
- * console.log(video.comments) // first 20 comments
78
- *
79
- * let newComments = await video.nextComments();
80
- * console.log(newComments) // 20 loaded comments
81
- * console.log(video.comments) // first 40 comments
82
- *
83
- * await video.nextComments(0); // load the rest of the comments in the playlist
84
- * ```
85
- *
86
- * @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!)
87
- */
88
- nextComments(count?: number): Promise<Comment[]>;
89
- }
90
- export {};