youtubei 0.0.1-rc.7 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +50 -53
  3. package/dist/cjs/classes/Base/Base.js +10 -0
  4. package/dist/{index.js → cjs/classes/Base/index.js} +13 -13
  5. package/dist/cjs/classes/BaseChannel/BaseChannel.js +31 -0
  6. package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +24 -0
  7. package/dist/cjs/classes/BaseChannel/ChannelPlaylists.js +57 -0
  8. package/dist/cjs/classes/BaseChannel/ChannelVideos.js +57 -0
  9. package/dist/{classes/client → cjs/classes/BaseChannel}/index.js +16 -19
  10. package/dist/cjs/classes/BaseVideo/BaseVideo.js +34 -0
  11. package/dist/cjs/classes/BaseVideo/BaseVideoParser.js +82 -0
  12. package/dist/cjs/classes/BaseVideo/VideoRelated.js +39 -0
  13. package/dist/{common → cjs/classes/BaseVideo}/index.js +15 -21
  14. package/dist/cjs/classes/Channel/Channel.js +24 -0
  15. package/dist/cjs/classes/Channel/ChannelParser.js +55 -0
  16. package/dist/cjs/classes/Channel/index.js +13 -0
  17. package/dist/cjs/classes/Chat/Chat.js +23 -0
  18. package/dist/cjs/classes/Chat/ChatParser.js +21 -0
  19. package/dist/cjs/classes/Chat/index.js +13 -0
  20. package/dist/cjs/classes/Client/Client.js +101 -0
  21. package/dist/cjs/classes/Client/HTTP.js +59 -0
  22. package/dist/cjs/classes/Client/index.js +13 -0
  23. package/dist/cjs/classes/Comment/Comment.js +29 -0
  24. package/dist/cjs/classes/Comment/CommentParser.js +43 -0
  25. package/dist/cjs/classes/Comment/CommentReplies.js +36 -0
  26. package/dist/cjs/classes/Comment/index.js +13 -0
  27. package/dist/cjs/classes/Continuable/Continuable.js +43 -0
  28. package/dist/cjs/classes/Continuable/index.js +13 -0
  29. package/dist/cjs/classes/LiveVideo/LiveVideo.js +84 -0
  30. package/dist/cjs/classes/LiveVideo/LiveVideoParser.js +29 -0
  31. package/dist/cjs/classes/LiveVideo/index.js +14 -0
  32. package/dist/cjs/classes/MixPlaylist/MixPlaylist.js +25 -0
  33. package/dist/cjs/classes/MixPlaylist/MixPlaylistParser.js +27 -0
  34. package/dist/cjs/classes/MixPlaylist/index.js +14 -0
  35. package/dist/cjs/classes/Playlist/Playlist.js +25 -0
  36. package/dist/cjs/classes/Playlist/PlaylistParser.js +83 -0
  37. package/dist/cjs/classes/Playlist/PlaylistVideos.js +50 -0
  38. package/dist/cjs/classes/Playlist/index.js +15 -0
  39. package/dist/cjs/classes/PlaylistCompact/PlaylistCompact.js +45 -0
  40. package/dist/cjs/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
  41. package/dist/cjs/classes/PlaylistCompact/index.js +14 -0
  42. package/dist/cjs/classes/Reply/Reply.js +23 -0
  43. package/dist/cjs/classes/Reply/ReplyParser.js +26 -0
  44. package/dist/cjs/classes/Reply/index.js +14 -0
  45. package/dist/cjs/classes/SearchManager/SearchManager.js +83 -0
  46. package/dist/cjs/classes/SearchManager/SearchManagerParser.js +40 -0
  47. package/dist/cjs/classes/SearchManager/index.js +14 -0
  48. package/dist/{common/types.js → cjs/classes/SearchManager/proto/SearchProto.js} +2 -2
  49. package/dist/cjs/classes/SearchManager/proto/index.js +57 -0
  50. package/dist/cjs/classes/Thumbnails/Thumbnails.js +67 -0
  51. package/dist/cjs/classes/Thumbnails/index.js +13 -0
  52. package/dist/cjs/classes/Video/Video.js +26 -0
  53. package/dist/cjs/classes/Video/VideoComments.js +53 -0
  54. package/dist/cjs/classes/Video/VideoParser.js +29 -0
  55. package/dist/cjs/classes/Video/index.js +14 -0
  56. package/dist/cjs/classes/VideoCompact/VideoCompact.js +49 -0
  57. package/dist/cjs/classes/VideoCompact/VideoCompactParser.js +36 -0
  58. package/dist/cjs/classes/VideoCompact/index.js +14 -0
  59. package/dist/cjs/classes/index.js +29 -0
  60. package/dist/{src → cjs}/common/decorators.js +14 -15
  61. package/dist/cjs/common/helper.js +45 -0
  62. package/dist/{src → cjs}/common/index.js +16 -21
  63. package/dist/cjs/common/mixins.js +14 -0
  64. package/dist/{classes/client → cjs/common}/types.js +2 -2
  65. package/dist/{src → cjs}/constants.js +10 -9
  66. package/dist/{src → cjs}/index.js +13 -13
  67. package/dist/esm/classes/Base/Base.js +8 -0
  68. package/dist/esm/classes/Base/index.js +1 -0
  69. package/dist/esm/classes/BaseChannel/BaseChannel.js +48 -0
  70. package/dist/esm/classes/BaseChannel/BaseChannelParser.js +24 -0
  71. package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +109 -0
  72. package/dist/esm/classes/BaseChannel/ChannelVideos.js +109 -0
  73. package/dist/esm/classes/BaseChannel/index.js +4 -0
  74. package/dist/esm/classes/BaseVideo/BaseVideo.js +51 -0
  75. package/dist/esm/classes/BaseVideo/BaseVideoParser.js +93 -0
  76. package/dist/esm/classes/BaseVideo/VideoRelated.js +87 -0
  77. package/dist/esm/classes/BaseVideo/index.js +3 -0
  78. package/dist/esm/classes/Channel/Channel.js +37 -0
  79. package/dist/esm/classes/Channel/ChannelParser.js +77 -0
  80. package/dist/esm/classes/Channel/index.js +1 -0
  81. package/dist/esm/classes/Chat/Chat.js +36 -0
  82. package/dist/esm/classes/Chat/ChatParser.js +21 -0
  83. package/dist/esm/classes/Chat/index.js +1 -0
  84. package/dist/esm/classes/Client/Client.js +176 -0
  85. package/dist/esm/classes/Client/HTTP.js +112 -0
  86. package/dist/esm/classes/Client/index.js +1 -0
  87. package/dist/esm/classes/Comment/Comment.js +46 -0
  88. package/dist/esm/classes/Comment/CommentParser.js +45 -0
  89. package/dist/esm/classes/Comment/CommentReplies.js +84 -0
  90. package/dist/esm/classes/Comment/index.js +1 -0
  91. package/dist/esm/classes/Continuable/Continuable.js +125 -0
  92. package/dist/esm/classes/Continuable/index.js +1 -0
  93. package/dist/esm/classes/LiveVideo/LiveVideo.js +160 -0
  94. package/dist/esm/classes/LiveVideo/LiveVideoParser.js +29 -0
  95. package/dist/esm/classes/LiveVideo/index.js +2 -0
  96. package/dist/esm/classes/MixPlaylist/MixPlaylist.js +38 -0
  97. package/dist/esm/classes/MixPlaylist/MixPlaylistParser.js +49 -0
  98. package/dist/esm/classes/MixPlaylist/index.js +2 -0
  99. package/dist/esm/classes/Playlist/Playlist.js +38 -0
  100. package/dist/esm/classes/Playlist/PlaylistParser.js +105 -0
  101. package/dist/esm/classes/Playlist/PlaylistVideos.js +98 -0
  102. package/dist/esm/classes/Playlist/index.js +3 -0
  103. package/dist/esm/classes/PlaylistCompact/PlaylistCompact.js +90 -0
  104. package/dist/esm/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
  105. package/dist/esm/classes/PlaylistCompact/index.js +2 -0
  106. package/dist/esm/classes/Reply/Reply.js +36 -0
  107. package/dist/esm/classes/Reply/ReplyParser.js +26 -0
  108. package/dist/esm/classes/Reply/index.js +2 -0
  109. package/dist/esm/classes/SearchManager/SearchManager.js +159 -0
  110. package/dist/esm/classes/SearchManager/SearchManagerParser.js +62 -0
  111. package/dist/esm/classes/SearchManager/index.js +2 -0
  112. package/dist/esm/classes/SearchManager/proto/SearchProto.js +1 -0
  113. package/dist/esm/classes/SearchManager/proto/index.js +39 -0
  114. package/dist/esm/classes/Thumbnails/Thumbnails.js +109 -0
  115. package/dist/esm/classes/Thumbnails/index.js +1 -0
  116. package/dist/esm/classes/Video/Video.js +39 -0
  117. package/dist/esm/classes/Video/VideoComments.js +101 -0
  118. package/dist/esm/classes/Video/VideoParser.js +31 -0
  119. package/dist/esm/classes/Video/index.js +2 -0
  120. package/dist/esm/classes/VideoCompact/VideoCompact.js +98 -0
  121. package/dist/esm/classes/VideoCompact/VideoCompactParser.js +36 -0
  122. package/dist/esm/classes/VideoCompact/index.js +2 -0
  123. package/dist/esm/classes/index.js +17 -0
  124. package/dist/esm/common/decorators.js +30 -0
  125. package/dist/esm/common/helper.js +61 -0
  126. package/dist/{common/index.d.ts → esm/common/index.js} +4 -4
  127. package/dist/esm/common/mixins.js +10 -0
  128. package/dist/esm/common/types.js +1 -0
  129. package/dist/esm/constants.js +7 -0
  130. package/dist/{index.d.ts → esm/index.js} +1 -1
  131. package/dist/typings/classes/Base/Base.d.ts +11 -0
  132. package/dist/typings/classes/Base/index.d.ts +1 -0
  133. package/dist/typings/classes/BaseChannel/BaseChannel.d.ts +43 -0
  134. package/dist/typings/classes/BaseChannel/BaseChannelParser.d.ts +7 -0
  135. package/dist/typings/classes/BaseChannel/ChannelPlaylists.d.ts +30 -0
  136. package/dist/typings/classes/BaseChannel/ChannelVideos.d.ts +30 -0
  137. package/dist/typings/classes/BaseChannel/index.d.ts +4 -0
  138. package/dist/typings/classes/BaseVideo/BaseVideo.d.ts +59 -0
  139. package/dist/typings/classes/BaseVideo/BaseVideoParser.d.ts +14 -0
  140. package/dist/typings/classes/BaseVideo/VideoRelated.d.ts +21 -0
  141. package/dist/typings/classes/BaseVideo/index.d.ts +3 -0
  142. package/dist/typings/classes/Channel/Channel.d.ts +33 -0
  143. package/dist/typings/classes/Channel/ChannelParser.d.ts +6 -0
  144. package/dist/typings/classes/Channel/index.d.ts +1 -0
  145. package/dist/typings/classes/Chat/Chat.d.ts +33 -0
  146. package/dist/typings/classes/Chat/ChatParser.d.ts +5 -0
  147. package/dist/typings/classes/Chat/index.d.ts +1 -0
  148. package/dist/typings/classes/Client/Client.d.ts +41 -0
  149. package/dist/typings/classes/Client/HTTP.d.ts +21 -0
  150. package/dist/typings/classes/Client/index.d.ts +1 -0
  151. package/dist/typings/classes/Comment/Comment.d.ts +51 -0
  152. package/dist/typings/classes/Comment/CommentParser.d.ts +8 -0
  153. package/dist/typings/classes/Comment/CommentReplies.d.ts +17 -0
  154. package/dist/typings/classes/Comment/index.d.ts +1 -0
  155. package/dist/typings/classes/Continuable/Continuable.d.ts +24 -0
  156. package/dist/typings/classes/Continuable/index.d.ts +1 -0
  157. package/dist/typings/classes/LiveVideo/LiveVideo.d.ts +46 -0
  158. package/dist/typings/classes/LiveVideo/LiveVideoParser.d.ts +10 -0
  159. package/dist/typings/classes/LiveVideo/index.d.ts +2 -0
  160. package/dist/typings/classes/MixPlaylist/MixPlaylist.d.ts +29 -0
  161. package/dist/typings/classes/MixPlaylist/MixPlaylistParser.d.ts +6 -0
  162. package/dist/typings/classes/MixPlaylist/index.d.ts +2 -0
  163. package/dist/typings/classes/Playlist/Playlist.d.ts +39 -0
  164. package/dist/typings/classes/Playlist/PlaylistParser.d.ts +16 -0
  165. package/dist/typings/classes/Playlist/PlaylistVideos.d.ts +31 -0
  166. package/dist/typings/classes/Playlist/index.d.ts +3 -0
  167. package/dist/typings/classes/PlaylistCompact/PlaylistCompact.d.ts +43 -0
  168. package/dist/typings/classes/PlaylistCompact/PlaylistCompactParser.d.ts +5 -0
  169. package/dist/typings/classes/PlaylistCompact/index.d.ts +2 -0
  170. package/dist/typings/classes/Reply/Reply.d.ts +43 -0
  171. package/dist/typings/classes/Reply/ReplyParser.d.ts +5 -0
  172. package/dist/typings/classes/Reply/index.d.ts +2 -0
  173. package/dist/typings/classes/SearchManager/SearchManager.d.ts +51 -0
  174. package/dist/typings/classes/SearchManager/SearchManagerParser.d.ts +13 -0
  175. package/dist/typings/classes/SearchManager/index.d.ts +2 -0
  176. package/dist/typings/classes/SearchManager/proto/SearchProto.d.ts +13 -0
  177. package/dist/typings/classes/SearchManager/proto/index.d.ts +24 -0
  178. package/dist/typings/classes/Thumbnails/Thumbnails.d.ts +41 -0
  179. package/dist/typings/classes/Thumbnails/index.d.ts +1 -0
  180. package/dist/typings/classes/Video/Video.d.ts +24 -0
  181. package/dist/typings/classes/Video/VideoComments.d.ts +34 -0
  182. package/dist/typings/classes/Video/VideoParser.d.ts +8 -0
  183. package/dist/typings/classes/Video/index.d.ts +2 -0
  184. package/dist/typings/classes/VideoCompact/VideoCompact.d.ts +57 -0
  185. package/dist/typings/classes/VideoCompact/VideoCompactParser.d.ts +5 -0
  186. package/dist/typings/classes/VideoCompact/index.d.ts +2 -0
  187. package/dist/typings/classes/index.d.ts +17 -0
  188. package/dist/{src → typings}/common/decorators.d.ts +5 -7
  189. package/dist/typings/common/helper.d.ts +5 -0
  190. package/dist/{src → typings}/common/index.d.ts +4 -4
  191. package/dist/typings/common/mixins.d.ts +1 -0
  192. package/dist/{common → typings/common}/types.d.ts +1 -2
  193. package/dist/{constants.d.ts → typings/constants.d.ts} +7 -6
  194. package/dist/{src → typings}/index.d.ts +1 -1
  195. package/package.json +68 -53
  196. package/CHANGELOG.md +0 -6
  197. package/dist/classes/Base.d.ts +0 -8
  198. package/dist/classes/Base.js +0 -10
  199. package/dist/classes/Channel.d.ts +0 -63
  200. package/dist/classes/Channel.js +0 -115
  201. package/dist/classes/Comment.d.ts +0 -51
  202. package/dist/classes/Comment.js +0 -47
  203. package/dist/classes/LiveVideo.d.ts +0 -3
  204. package/dist/classes/LiveVideo.js +0 -12
  205. package/dist/classes/Playlist.d.ts +0 -66
  206. package/dist/classes/Playlist.js +0 -133
  207. package/dist/classes/PlaylistCompact.d.ts +0 -35
  208. package/dist/classes/PlaylistCompact.js +0 -47
  209. package/dist/classes/SearchResult.d.ts +0 -52
  210. package/dist/classes/SearchResult.js +0 -121
  211. package/dist/classes/Test.d.ts +0 -7
  212. package/dist/classes/Test.js +0 -9
  213. package/dist/classes/Thumbnails.d.ts +0 -23
  214. package/dist/classes/Thumbnails.js +0 -42
  215. package/dist/classes/Video.d.ts +0 -90
  216. package/dist/classes/Video.js +0 -153
  217. package/dist/classes/VideoCompact.d.ts +0 -46
  218. package/dist/classes/VideoCompact.js +0 -53
  219. package/dist/classes/client/Client.d.ts +0 -26
  220. package/dist/classes/client/Client.js +0 -63
  221. package/dist/classes/client/index.d.ts +0 -2
  222. package/dist/classes/client/types.d.ts +0 -12
  223. package/dist/classes/client.d.ts +0 -17
  224. package/dist/classes/client.js +0 -57
  225. package/dist/classes/index.d.ts +0 -10
  226. package/dist/classes/index.js +0 -26
  227. package/dist/common/decorators.d.ts +0 -7
  228. package/dist/common/decorators.js +0 -15
  229. package/dist/common/helper.d.ts +0 -4
  230. package/dist/common/helper.js +0 -39
  231. package/dist/common/http.d.ts +0 -33
  232. package/dist/common/http.js +0 -105
  233. package/dist/constants.js +0 -9
  234. package/dist/src/classes/Base.d.ts +0 -8
  235. package/dist/src/classes/Base.js +0 -10
  236. package/dist/src/classes/Channel.d.ts +0 -37
  237. package/dist/src/classes/Channel.js +0 -82
  238. package/dist/src/classes/Client.d.ts +0 -14
  239. package/dist/src/classes/Client.js +0 -51
  240. package/dist/src/classes/Comment.d.ts +0 -51
  241. package/dist/src/classes/Comment.js +0 -47
  242. package/dist/src/classes/Playlist.d.ts +0 -66
  243. package/dist/src/classes/Playlist.js +0 -133
  244. package/dist/src/classes/PlaylistCompact.d.ts +0 -35
  245. package/dist/src/classes/PlaylistCompact.js +0 -47
  246. package/dist/src/classes/SearchResult.d.ts +0 -53
  247. package/dist/src/classes/SearchResult.js +0 -122
  248. package/dist/src/classes/Thumbnails.d.ts +0 -24
  249. package/dist/src/classes/Thumbnails.js +0 -42
  250. package/dist/src/classes/Video.d.ts +0 -90
  251. package/dist/src/classes/Video.js +0 -153
  252. package/dist/src/classes/VideoCompact.d.ts +0 -46
  253. package/dist/src/classes/VideoCompact.js +0 -53
  254. package/dist/src/classes/index.d.ts +0 -10
  255. package/dist/src/classes/index.js +0 -26
  256. package/dist/src/common/helper.d.ts +0 -4
  257. package/dist/src/common/helper.js +0 -39
  258. package/dist/src/common/http.d.ts +0 -33
  259. package/dist/src/common/http.js +0 -105
  260. package/dist/src/common/types.d.ts +0 -2
  261. package/dist/src/common/types.js +0 -2
  262. package/dist/src/constants.d.ts +0 -6
  263. package/dist/tempCodeRunnerFile.d.ts +0 -8
  264. package/dist/tempCodeRunnerFile.js +0 -15
@@ -0,0 +1,24 @@
1
+ import { YoutubeRawData } from "../../common";
2
+ import { BaseVideo, BaseVideoProperties } from "../BaseVideo";
3
+ import { VideoComments } from "./VideoComments";
4
+ /** @hidden */
5
+ interface VideoProperties extends BaseVideoProperties {
6
+ duration?: number;
7
+ comments?: VideoComments;
8
+ }
9
+ /** Represents a Video, usually returned from `client.getVideo()` */
10
+ export declare class Video extends BaseVideo implements VideoProperties {
11
+ /** The duration of this video in second */
12
+ duration: number;
13
+ /** {@link Continuable} of videos inside a {@link Video} */
14
+ comments: VideoComments;
15
+ /** @hidden */
16
+ constructor(attr: VideoProperties);
17
+ /**
18
+ * Load this instance with raw data from Youtube
19
+ *
20
+ * @hidden
21
+ */
22
+ load(data: YoutubeRawData): Video;
23
+ }
24
+ export {};
@@ -0,0 +1,34 @@
1
+ import { Comment } from "../Comment";
2
+ import { Continuable, ContinuableConstructorParams, FetchResult } from "../Continuable";
3
+ import { Video } from "./Video";
4
+ declare type ConstructorParams = ContinuableConstructorParams & {
5
+ video: Video;
6
+ };
7
+ /**
8
+ * {@link Continuable} of videos inside a {@link Video}
9
+ *
10
+ * @example
11
+ * ```js
12
+ * const video = await youtube.getVideo(VIDEO_ID);
13
+ * await video.comments.next();
14
+ * console.log(video.comments) // first 20 comments
15
+ *
16
+ * let newComments = await video.comments.next();
17
+ * console.log(newComments) // 20 loaded comments
18
+ * console.log(video.comments) // first 40 comments
19
+ *
20
+ * await video.comments.next(0); // load the rest of the comments in the video
21
+ * ```
22
+ *
23
+ * @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!)
24
+ *
25
+ * @returns Loaded comments
26
+ */
27
+ export declare class VideoComments extends Continuable<Comment> {
28
+ /** The playlist this videos belongs to */
29
+ video: Video;
30
+ /** @hidden */
31
+ constructor({ client, video }: ConstructorParams);
32
+ protected fetch(): Promise<FetchResult<Comment>>;
33
+ }
34
+ export {};
@@ -0,0 +1,8 @@
1
+ import { YoutubeRawData } from "../../common";
2
+ import { Comment } from "../Comment";
3
+ import { Video } from "./Video";
4
+ export declare class VideoParser {
5
+ static loadVideo(target: Video, data: YoutubeRawData): Video;
6
+ static parseComments(data: YoutubeRawData, video: Video): Comment[];
7
+ static parseCommentContinuation(data: YoutubeRawData): string | undefined;
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Video";
2
+ export * from "./VideoParser";
@@ -0,0 +1,57 @@
1
+ import { YoutubeRawData } from "../../common";
2
+ import { Base, BaseProperties } from "../Base";
3
+ import { BaseChannel } from "../BaseChannel";
4
+ import { LiveVideo } from "../LiveVideo";
5
+ import { Thumbnails } from "../Thumbnails";
6
+ import { Video } from "../Video";
7
+ /** @hidden */
8
+ interface VideoCompactProperties extends BaseProperties {
9
+ id?: string;
10
+ title?: string;
11
+ thumbnails?: Thumbnails;
12
+ duration?: number | null;
13
+ isLive?: boolean;
14
+ channel?: BaseChannel;
15
+ uploadDate?: string;
16
+ viewCount?: number | null;
17
+ }
18
+ /** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
19
+ export declare class VideoCompact extends Base implements VideoCompactProperties {
20
+ id: string;
21
+ /** The title of the video */
22
+ title: string;
23
+ /** Thumbnails of the video with different sizes */
24
+ thumbnails: Thumbnails;
25
+ /** Description of the video (not a full description, rather a preview / snippet) */
26
+ description: string;
27
+ /** The duration of this video in second, null if the video is live */
28
+ duration: number | null;
29
+ /** Whether this video is a live now or not */
30
+ isLive: boolean;
31
+ /** The channel who uploads this video */
32
+ channel?: BaseChannel;
33
+ /** The date this video is uploaded at */
34
+ uploadDate?: string;
35
+ /** How many view does this video have, null if the view count is hidden */
36
+ viewCount?: number | null;
37
+ /** @hidden */
38
+ constructor(attr: VideoCompactProperties);
39
+ /** Whether this video is private / deleted or not, only useful in playlist's videos */
40
+ get isPrivateOrDeleted(): boolean;
41
+ /**
42
+ * Load this instance with raw data from Youtube
43
+ *
44
+ * @hidden
45
+ */
46
+ load(data: YoutubeRawData): VideoCompact;
47
+ /**
48
+ * Get {@link Video} object based on current video id
49
+ *
50
+ * Equivalent to
51
+ * ```js
52
+ * client.getVideo(videoCompact.id);
53
+ * ```
54
+ */
55
+ getVideo<T extends Video | LiveVideo>(): Promise<T>;
56
+ }
57
+ export {};
@@ -0,0 +1,5 @@
1
+ import { YoutubeRawData } from "../../common";
2
+ import { VideoCompact } from "./VideoCompact";
3
+ export declare class VideoCompactParser {
4
+ static loadVideoCompact(target: VideoCompact, data: YoutubeRawData): VideoCompact;
5
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./VideoCompact";
2
+ export * from "./VideoCompactParser";
@@ -0,0 +1,17 @@
1
+ export * from "./Base";
2
+ export * from "./BaseVideo";
3
+ export * from "./Channel";
4
+ export * from "./BaseChannel";
5
+ export * from "./Chat";
6
+ export * from "./Client";
7
+ export * from "./Continuable";
8
+ export * from "./Comment";
9
+ export * from "./LiveVideo";
10
+ export * from "./MixPlaylist";
11
+ export * from "./Playlist";
12
+ export * from "./PlaylistCompact";
13
+ export * from "./Reply";
14
+ export * from "./SearchManager";
15
+ export * from "./Thumbnails";
16
+ export * from "./Video";
17
+ export * from "./VideoCompact";
@@ -1,7 +1,5 @@
1
- /** @hidden */
2
- interface Constructor<T> {
3
- new (...args: any[]): T;
4
- }
5
- /** @hidden */
6
- export declare function extendsBuiltIn(): (target: Constructor<any>) => any;
7
- export {};
1
+ interface Constructor<T> {
2
+ new (...args: any[]): T;
3
+ }
4
+ export declare function extendsBuiltIn(): (target: Constructor<any>) => any;
5
+ export {};
@@ -0,0 +1,5 @@
1
+ import { YoutubeRawData } from "./types";
2
+ export declare const getDuration: (s: string) => number;
3
+ export declare const stripToInt: (string: string) => number | null;
4
+ export declare const getContinuationFromItems: (items: YoutubeRawData, accessors?: string[]) => string | undefined;
5
+ export declare const mapFilter: (items: YoutubeRawData, key: string) => YoutubeRawData;
@@ -1,4 +1,4 @@
1
- export { default as http } from "./http";
2
- export * from "./helper";
3
- export * from "./types";
4
- export * from "./decorators";
1
+ export * from "./decorators";
2
+ export * from "./helper";
3
+ export * from "./mixins";
4
+ export * from "./types";
@@ -0,0 +1 @@
1
+ export declare const applyMixins: (derivedCtor: any, baseCtors: any[]) => void;
@@ -1,2 +1 @@
1
- /** @hidden */
2
- export declare type YoutubeRawData = Record<string, any>;
1
+ export declare type YoutubeRawData = Record<string, any>;
@@ -1,6 +1,7 @@
1
- export declare const INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
2
- export declare const INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
3
- export declare const BASE_URL = "www.youtube.com";
4
- export declare const I_END_POINT = "/youtubei/v1";
5
- export declare const WATCH_END_POINT = "/watch";
6
- export declare const COMMENT_END_POINT = "/comment_service_ajax";
1
+ export declare const INNERTUBE_CLIENT_VERSION = "2.20201209.01.00";
2
+ export declare const INNERTUBE_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
3
+ export declare const BASE_URL = "www.youtube.com";
4
+ export declare const I_END_POINT = "/youtubei/v1";
5
+ export declare const LIVE_CHAT_END_POINT: string;
6
+ export declare const WATCH_END_POINT = "/watch";
7
+ export declare const COMMENT_END_POINT = "/comment_service_ajax";
@@ -1 +1 @@
1
- export * from "./classes";
1
+ export * from "./classes";
package/package.json CHANGED
@@ -1,53 +1,68 @@
1
- {
2
- "name": "youtubei",
3
- "version": "0.0.1-rc.7",
4
- "description": "Simple package to get information from youtube such as videos, playlists, channels, video information & comments, related videos, up next video, and more!",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "directories": {
8
- "test": "test"
9
- },
10
- "dependencies": {},
11
- "devDependencies": {
12
- "@types/jest": "^26.0.19",
13
- "@types/node": "^14.14.12",
14
- "@typescript-eslint/eslint-plugin": "^4.9.1",
15
- "@typescript-eslint/parser": "^4.9.1",
16
- "eslint": "^7.15.0",
17
- "eslint-plugin-prettier": "^3.2.0",
18
- "jest": "^26.6.3",
19
- "jest-extended": "^0.11.5",
20
- "prettier": "^2.2.1",
21
- "ts-jest": "^26.4.4",
22
- "typescript": "^4.1.2"
23
- },
24
- "scripts": {
25
- "test": "jest",
26
- "dev": "tsc --watch",
27
- "build": "tsc",
28
- "lint:check": "eslint src && prettier -c src",
29
- "lint:fix": "eslint --fix && prettier --write src"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/SuspiciousLookingOwl/youtubei.git"
34
- },
35
- "keywords": [
36
- "youtube",
37
- "yt",
38
- "search",
39
- "video",
40
- "videos",
41
- "playlist",
42
- "channel",
43
- "related",
44
- "comment",
45
- "comments"
46
- ],
47
- "author": "Vincent Jonathan",
48
- "license": "MIT",
49
- "bugs": {
50
- "url": "https://github.com/SuspiciousLookingOwl/youtubei/issues"
51
- },
52
- "homepage": "https://github.com/SuspiciousLookingOwl/youtubei#readme"
53
- }
1
+ {
2
+ "name": "youtubei",
3
+ "version": "1.0.0-rc.1",
4
+ "description": "Simple package to get information from youtube such as videos, playlists, channels, video information & comments, related videos, up next video, and more!",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/typings/index.d.ts",
8
+ "directories": {
9
+ "test": "test"
10
+ },
11
+ "devDependencies": {
12
+ "@trivago/prettier-plugin-sort-imports": "3.2.0",
13
+ "@types/node": "14.14.12",
14
+ "@types/node-fetch": "2.6.2",
15
+ "@typescript-eslint/eslint-plugin": "4.9.1",
16
+ "@typescript-eslint/parser": "4.9.1",
17
+ "c8": "7.11.3",
18
+ "eslint": "7.15.0",
19
+ "eslint-plugin-prettier": "3.2.0",
20
+ "jest-extended": "0.11.5",
21
+ "prettier": "2.2.1",
22
+ "rimraf": "3.0.2",
23
+ "typescript": "4.1.2",
24
+ "vite": "2.9.14",
25
+ "vitest": "0.18.0"
26
+ },
27
+ "scripts": {
28
+ "dev": "tsc -w --noEmit",
29
+ "test": "vitest",
30
+ "test:coverage": "vitest run --coverage",
31
+ "build": "pnpm clean && pnpm build:cjs && pnpm build:esm && pnpm build:types",
32
+ "build:cjs": "tsc -p ./typescript/tsconfig.cjs.json",
33
+ "build:esm": "tsc -p ./typescript/tsconfig.esm.json",
34
+ "build:types": "tsc -p ./typescript/tsconfig.types.json",
35
+ "clean": "rimraf ./dist",
36
+ "lint:check": "eslint src && prettier -c src tests",
37
+ "lint:fix": "eslint --fix && prettier --write src tests"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/SuspiciousLookingOwl/youtubei.git"
42
+ },
43
+ "keywords": [
44
+ "youtube",
45
+ "yt",
46
+ "search",
47
+ "video",
48
+ "videos",
49
+ "playlist",
50
+ "channel",
51
+ "related",
52
+ "comment",
53
+ "comments",
54
+ "live",
55
+ "chat",
56
+ "live chat"
57
+ ],
58
+ "author": "Vincent Jonathan",
59
+ "license": "MIT",
60
+ "bugs": {
61
+ "url": "https://github.com/SuspiciousLookingOwl/youtubei/issues"
62
+ },
63
+ "homepage": "https://suspiciouslookingowl.github.io/youtubei",
64
+ "dependencies": {
65
+ "node-fetch": "2.6.7",
66
+ "protocol-buffers": "5.0.0"
67
+ }
68
+ }
package/CHANGELOG.md DELETED
@@ -1,6 +0,0 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
@@ -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,63 +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
- /** Loaded videos on the channel, fetched from `channel.nextVideos()` */
24
- videos: VideoCompact[];
25
- /** Loaded playlists on the channel, fetched from `channel.nextPlaylists()` */
26
- playlists: PlaylistCompact[];
27
- private _videoContinuation?;
28
- private _playlistContinuation?;
29
- /** @hidden */
30
- constructor(channel?: Partial<ChannelAttributes>);
31
- /**
32
- * Load next 30 videos made by the channel
33
- *
34
- * @return New fetched videos
35
- */
36
- nextVideos(count?: number): Promise<VideoCompact[]>;
37
- /**
38
- * Load next 30 playlists made by the channel
39
- *
40
- * @return New fetched playlists
41
- */
42
- nextPlaylists(count?: number): Promise<PlaylistCompact[]>;
43
- /**
44
- * Load instance attributes from youtube raw data
45
- *
46
- * @param youtubeRawData raw object from youtubei
47
- * @hidden
48
- */
49
- load(youtubeRawData: YoutubeRawData): Channel;
50
- /**
51
- * Get tab data from youtube
52
- */
53
- private getTabData;
54
- /**
55
- * Parse tab data from request, tab name is ignored if it's a continuation data
56
- */
57
- private static parseTabData;
58
- /**
59
- * Get continuation token from items (if exists)
60
- */
61
- private static getContinuationFromItems;
62
- }
63
- export {};
@@ -1,115 +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
- this._videoContinuation = null;
21
- this._playlistContinuation = null;
22
- Object.assign(this, channel);
23
- }
24
- /**
25
- * Load next 30 videos made by the channel
26
- *
27
- * @return New fetched videos
28
- */
29
- nextVideos(count = 1) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const newVideos = [];
32
- for (let i = 0; i < count || count == 0; i++) {
33
- if (this._videoContinuation === undefined)
34
- break;
35
- const items = yield this.getTabData("videos");
36
- this._videoContinuation = Channel.getContinuationFromItems(items);
37
- newVideos.push(...items
38
- .filter((i) => i.gridVideoRenderer)
39
- .map((i) => new _1.VideoCompact().load(i.gridVideoRenderer)));
40
- }
41
- this.videos.push(...newVideos);
42
- return newVideos;
43
- });
44
- }
45
- /**
46
- * Load next 30 playlists made by the channel
47
- *
48
- * @return New fetched playlists
49
- */
50
- nextPlaylists(count = 1) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const newPlaylists = [];
53
- for (let i = 0; i < count || count == 0; i++) {
54
- if (this._playlistContinuation === undefined)
55
- break;
56
- const items = yield this.getTabData("playlists");
57
- this._playlistContinuation = Channel.getContinuationFromItems(items);
58
- newPlaylists.push(...items
59
- .filter((i) => i.gridPlaylistRenderer)
60
- .map((i) => new _1.PlaylistCompact().load(i.gridPlaylistRenderer)));
61
- }
62
- this.playlists.push(...newPlaylists);
63
- return newPlaylists;
64
- });
65
- }
66
- /**
67
- * Load instance attributes from youtube raw data
68
- *
69
- * @param youtubeRawData raw object from youtubei
70
- * @hidden
71
- */
72
- load(youtubeRawData) {
73
- var _a;
74
- const { channelId, title, thumbnail, videoCountText, navigationEndpoint } = youtubeRawData;
75
- const { browseId, canonicalBaseUrl } = navigationEndpoint.browseEndpoint;
76
- this.id = channelId;
77
- this.name = title.simpleText;
78
- this.thumbnails = new _1.Thumbnails().load(thumbnail.thumbnails);
79
- this.url = "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`);
80
- this.videoCount = (_a = +(videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs[0].text.replace(/[^0-9]/g, ""))) !== null && _a !== void 0 ? _a : 0;
81
- this.videos = [];
82
- this.playlists = [];
83
- return this;
84
- }
85
- /**
86
- * Get tab data from youtube
87
- */
88
- getTabData(name) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const params = name === "videos" ? "EgZ2aWRlb3M%3D" : "EglwbGF5bGlzdHMgAQ%3D%3D";
91
- const continuation = name === "videos" ? this._videoContinuation : this._playlistContinuation;
92
- const response = yield common_1.http.post(`${constants_1.I_END_POINT}/browse`, {
93
- data: { browseId: this.id, params, continuation },
94
- });
95
- return Channel.parseTabData(name, response.data);
96
- });
97
- }
98
- /**
99
- * Parse tab data from request, tab name is ignored if it's a continuation data
100
- */
101
- static parseTabData(name, data) {
102
- var _a;
103
- const index = name === "videos" ? 1 : 2;
104
- return (((_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs[index].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer.items) ||
105
- data.onResponseReceivedActions[0].appendContinuationItemsAction.continuationItems);
106
- }
107
- /**
108
- * Get continuation token from items (if exists)
109
- */
110
- static getContinuationFromItems(items) {
111
- var _a;
112
- return (_a = items[items.length - 1].continuationItemRenderer) === null || _a === void 0 ? void 0 : _a.continuationEndpoint.continuationCommand.token;
113
- }
114
- }
115
- exports.default = Channel;
@@ -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,3 +0,0 @@
1
- import { Video } from ".";
2
- export default class LiveVideo extends Video {
3
- }