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,105 +0,0 @@
1
- "use strict";
2
- /** @ignore */ /** */
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
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
- /* eslint-disable @typescript-eslint/no-explicit-any */
17
- const https_1 = __importDefault(require("https"));
18
- const zlib_1 = __importDefault(require("zlib"));
19
- const querystring_1 = __importDefault(require("querystring"));
20
- const constants_1 = require("../constants");
21
- let cookie = "";
22
- /** @hidden */
23
- class HTTP {
24
- /**
25
- * Send request to Youtube
26
- */
27
- static request(partialOptions) {
28
- return new Promise((resolve, reject) => {
29
- const options = Object.assign(Object.assign({ hostname: constants_1.BASE_URL, port: 443 }, partialOptions), { path: `${partialOptions.path}?${querystring_1.default.stringify(partialOptions.params)}`, headers: Object.assign({ "x-youtube-client-version": constants_1.INNERTUBE_CLIENT_VERSION, "x-youtube-client-name": "1", "content-type": "application/json", "accept-encoding": "gzip", cookie }, partialOptions.headers) });
30
- let body = options.data || "";
31
- if (options.data) {
32
- if (options.headers["content-type"] === "application/x-www-form-urlencoded") {
33
- body = querystring_1.default.stringify(body);
34
- }
35
- else if (options.headers["content-type"] === "application/json") {
36
- body = JSON.stringify(body);
37
- }
38
- }
39
- const request = https_1.default.request(options, (res) => {
40
- var _a;
41
- cookie = ((_a = res.headers["set-cookie"]) === null || _a === void 0 ? void 0 : _a.join(";")) || cookie;
42
- if (res.headers["content-encoding"] === "gzip") {
43
- const gunzip = zlib_1.default.createGunzip();
44
- res.pipe(gunzip);
45
- const buffer = [];
46
- gunzip
47
- .on("data", (data) => {
48
- buffer.push(data.toString());
49
- })
50
- .on("end", () => {
51
- const data = JSON.parse(buffer.join("").toString());
52
- resolve({
53
- status: res.statusCode,
54
- headers: res.headers,
55
- data,
56
- });
57
- })
58
- .on("error", reject);
59
- }
60
- else {
61
- let body = "";
62
- res.on("data", (data) => {
63
- body += data;
64
- })
65
- .on("end", () => {
66
- const data = JSON.parse(body);
67
- resolve({
68
- status: res.statusCode,
69
- headers: res.headers,
70
- data,
71
- });
72
- })
73
- .on("error", reject);
74
- }
75
- });
76
- request.on("error", reject);
77
- request.write(body);
78
- request.end();
79
- });
80
- }
81
- /**
82
- * Send GET request to Youtube
83
- */
84
- static get(path, options) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- options = Object.assign({ method: "GET", path }, options);
87
- return yield HTTP.request(options);
88
- });
89
- }
90
- /**
91
- * Send POST request to Youtube
92
- */
93
- static post(path, options) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- options = Object.assign(Object.assign({ method: "POST", path }, options), { params: Object.assign({ key: constants_1.INNERTUBE_API_KEY }, options.params), data: Object.assign({ context: {
96
- client: {
97
- clientName: "WEB",
98
- clientVersion: constants_1.INNERTUBE_CLIENT_VERSION,
99
- },
100
- } }, options.data) });
101
- return yield HTTP.request(options);
102
- });
103
- }
104
- }
105
- exports.default = HTTP;
package/dist/constants.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COMMENT_END_POINT = exports.WATCH_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.WATCH_END_POINT = "/watch";
9
- exports.COMMENT_END_POINT = "/comment_service_ajax";
@@ -1,8 +0,0 @@
1
- /**
2
- * Base class
3
- *
4
- * @hidden
5
- */
6
- export default class Base {
7
- id: string;
8
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Base class
5
- *
6
- * @hidden
7
- */
8
- class Base {
9
- }
10
- exports.default = Base;
@@ -1,37 +0,0 @@
1
- import { YoutubeRawData } from "../common";
2
- import { Base, PlaylistCompact, Thumbnails, VideoCompact } from ".";
3
- /** @hidden */
4
- interface ChannelAttributes {
5
- id: string;
6
- name: string;
7
- url: string;
8
- thumbnails: Thumbnails;
9
- videoCount?: number;
10
- }
11
- /** Represents a Youtube Channel */
12
- export default class Channel extends Base implements ChannelAttributes {
13
- /** The channel's ID */
14
- id: string;
15
- /** The channel's name */
16
- name: string;
17
- /** The URL to the channel page */
18
- url: string;
19
- /** Thumbnails of the Channel with different sizes */
20
- thumbnails: Thumbnails;
21
- /** How many video does this channel have */
22
- videoCount?: number;
23
- /** @hidden */
24
- constructor(channel?: Partial<ChannelAttributes>);
25
- /** Get videos from current Channel */
26
- getVideos(): Promise<VideoCompact[]>;
27
- /** Get playlists from current channel */
28
- getPlaylists(): Promise<PlaylistCompact[]>;
29
- /**
30
- * Load instance attributes from youtube raw data
31
- *
32
- * @param youtubeRawData raw object from youtubei
33
- * @hidden
34
- */
35
- load(youtubeRawData: YoutubeRawData): Channel;
36
- }
37
- export {};
@@ -1,82 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const common_1 = require("../common");
13
- const _1 = require(".");
14
- const constants_1 = require("../constants");
15
- /** Represents a Youtube Channel */
16
- class Channel extends _1.Base {
17
- /** @hidden */
18
- constructor(channel = {}) {
19
- super();
20
- Object.assign(this, channel);
21
- }
22
- /** Get videos from current Channel */
23
- getVideos() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- // TODO: Add continuation support
26
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
27
- data: {
28
- browseId: this.id,
29
- params: "EgZ2aWRlb3M%3D",
30
- },
31
- });
32
- return response.data.contents.twoColumnBrowseResultsRenderer.tabs[1].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer.items
33
- .filter((i) => i.gridVideoRenderer)
34
- .map((i) => new _1.VideoCompact().load(i.gridVideoRenderer));
35
- });
36
- }
37
- /** Get playlists from current channel */
38
- getPlaylists() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- // TODO: Add continuation support
41
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
42
- data: {
43
- browseId: this.id,
44
- params: "EglwbGF5bGlzdHM%3D",
45
- },
46
- });
47
- const section = response.data.contents.twoColumnBrowseResultsRenderer.tabs[2].tabRenderer.content
48
- .sectionListRenderer;
49
- let gridPlaylistRenderer;
50
- // Has category
51
- if ("shelfRenderer" in section.contents[0].itemSectionRenderer.contents[0]) {
52
- gridPlaylistRenderer = section.contents
53
- .map((c) => c.itemSectionRenderer.contents[0].shelfRenderer.content
54
- .horizontalListRenderer.items)
55
- .flat();
56
- }
57
- else {
58
- gridPlaylistRenderer =
59
- section.contents[0].itemSectionRenderer.contents[0].gridRenderer.items;
60
- }
61
- return gridPlaylistRenderer.map((i) => new _1.PlaylistCompact().load(i.gridPlaylistRenderer));
62
- });
63
- }
64
- /**
65
- * Load instance attributes from youtube raw data
66
- *
67
- * @param youtubeRawData raw object from youtubei
68
- * @hidden
69
- */
70
- load(youtubeRawData) {
71
- var _a;
72
- const { channelId, title, thumbnail, videoCountText, navigationEndpoint } = youtubeRawData;
73
- const { browseId, canonicalBaseUrl } = navigationEndpoint.browseEndpoint;
74
- this.id = channelId;
75
- this.name = title.simpleText;
76
- this.thumbnails = new _1.Thumbnails().load(thumbnail.thumbnails);
77
- this.url = "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`);
78
- this.videoCount = (_a = +(videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs[0].text.replace(/[^0-9]/g, ""))) !== null && _a !== void 0 ? _a : 0;
79
- return this;
80
- }
81
- }
82
- exports.default = Channel;
@@ -1,14 +0,0 @@
1
- import { Playlist, Video, SearchResult } from ".";
2
- export declare type SearchType = "video" | "channel" | "playlist" | "all";
3
- export declare type SearchOptions = {
4
- type: SearchType;
5
- };
6
- /** Youtube Client */
7
- export default class Client {
8
- /** Searches for videos / playlists / channels */
9
- search<T extends SearchOptions>(query: string, searchOptions?: Partial<T>): Promise<SearchResult<T>>;
10
- /** Get playlist information and its videos by playlist id or URL */
11
- getPlaylist(playlistIdOrUrl: string): Promise<Playlist | undefined>;
12
- /** Get video information by video id or URL */
13
- getVideo(videoIdOrUrl: string): Promise<Video | undefined>;
14
- }
@@ -1,51 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const constants_1 = require("../constants");
13
- const common_1 = require("../common");
14
- const _1 = require(".");
15
- /** Youtube Client */
16
- class Client {
17
- /** Searches for videos / playlists / channels */
18
- search(query, searchOptions) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const options = Object.assign({ type: "all" }, searchOptions);
21
- const result = new _1.SearchResult();
22
- yield result.init(query, options);
23
- return result;
24
- });
25
- }
26
- /** Get playlist information and its videos by playlist id or URL */
27
- getPlaylist(playlistIdOrUrl) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const playlistId = common_1.getQueryParameter(playlistIdOrUrl, "list");
30
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
31
- data: { browseId: `VL${playlistId}` },
32
- });
33
- if (response.data.error || response.data.alerts)
34
- return undefined;
35
- return new _1.Playlist().load(response.data);
36
- });
37
- }
38
- /** Get video information by video id or URL */
39
- getVideo(videoIdOrUrl) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const videoId = common_1.getQueryParameter(videoIdOrUrl, "v");
42
- const response = yield common_1.http.get(`${constants_1.WATCH_END_POINT}`, {
43
- params: { v: videoId, pbj: "1" },
44
- });
45
- if (!response.data[3].response.contents)
46
- return undefined;
47
- return new _1.Video().load(response.data);
48
- });
49
- }
50
- }
51
- exports.default = Client;
@@ -1,51 +0,0 @@
1
- import { Base, Channel, Video } from ".";
2
- import { YoutubeRawData } from "../common";
3
- /** @hidden */
4
- interface CommentAttributes {
5
- id: string;
6
- video: Video;
7
- author: Channel;
8
- content: string;
9
- publishDate: string;
10
- likeCount: number;
11
- isAuthorChannelOwner: boolean;
12
- isPinnedComment: boolean;
13
- replyCount: number;
14
- }
15
- /**
16
- * Represents a Comment / Reply
17
- */
18
- export default class Comment extends Base implements CommentAttributes {
19
- /** The comment's ID */
20
- id: string;
21
- /** The video this comment belongs to */
22
- video: Video;
23
- /** The comment's author */
24
- author: Channel;
25
- /** The content of this comment */
26
- content: string;
27
- /** The publish date of the comment */
28
- publishDate: string;
29
- /** How many likes does this comment have */
30
- likeCount: number;
31
- /** Whether the comment is posted by the video uploader / owner */
32
- isAuthorChannelOwner: boolean;
33
- /** Whether the comment is pinned */
34
- isPinnedComment: boolean;
35
- /** Comment's reply count */
36
- replyCount: number;
37
- /** @hidden */
38
- constructor(channel?: Partial<CommentAttributes>);
39
- /**
40
- * Load instance attributes from youtube raw data
41
- *
42
- * @param youtubeRawData raw object from youtubei
43
- * @hidden
44
- */
45
- load(data: YoutubeRawData): Comment;
46
- /**
47
- * URL to the video with this comment being highlighted (appears on top of the comment section)
48
- */
49
- get url(): string;
50
- }
51
- export {};
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const _1 = require(".");
4
- /**
5
- * Represents a Comment / Reply
6
- */
7
- class Comment extends _1.Base {
8
- // TODO: Add replies
9
- /** @hidden */
10
- constructor(channel = {}) {
11
- super();
12
- Object.assign(this, channel);
13
- }
14
- /**
15
- * Load instance attributes from youtube raw data
16
- *
17
- * @param youtubeRawData raw object from youtubei
18
- * @hidden
19
- */
20
- load(data) {
21
- const { authorText, authorThumbnail, authorEndpoint, contentText, publishedTimeText, commentId, likeCount, authorIsChannelOwner, pinnedCommentBadge, replyCount, } = data.comment.commentRenderer;
22
- // Basic information
23
- this.id = commentId;
24
- this.content = contentText.runs.map((r) => r.text).join("");
25
- this.publishDate = publishedTimeText.runs.shift().text;
26
- this.likeCount = likeCount;
27
- this.isAuthorChannelOwner = authorIsChannelOwner;
28
- this.isPinnedComment = !!pinnedCommentBadge;
29
- this.replyCount = replyCount;
30
- // Author
31
- const { browseId, canonicalBaseUrl } = authorEndpoint.browseEndpoint;
32
- this.author = new _1.Channel({
33
- id: browseId,
34
- name: authorText.simpleText,
35
- thumbnails: new _1.Thumbnails().load(authorThumbnail.thumbnails),
36
- url: "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`),
37
- });
38
- return this;
39
- }
40
- /**
41
- * URL to the video with this comment being highlighted (appears on top of the comment section)
42
- */
43
- get url() {
44
- return `https://www.youtube.com?watch=${this.video.id}&lc=${this.id}`;
45
- }
46
- }
47
- exports.default = Comment;
@@ -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 getVideos;
64
- private 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 = this.getSideBarInfo(stats[0], true);
42
- this.viewCount = this.getSideBarInfo(stats[1], true);
43
- this.lastUpdatedAt = this.getSideBarInfo(stats[2], false);
44
- }
45
- else if (stats.length === 2) {
46
- this.videoCount = this.getSideBarInfo(stats[0], true);
47
- this.lastUpdatedAt = this.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 = this.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(...this.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
- 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
- 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 {};