youtubei 1.3.7 → 1.4.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 (59) hide show
  1. package/dist/cjs/common/shared/HTTP/HTTP.js +18 -7
  2. package/dist/cjs/youtube/BaseVideo/BaseVideoParser.js +7 -2
  3. package/dist/cjs/youtube/BaseVideo/VideoCaptions.js +81 -0
  4. package/dist/cjs/youtube/BaseVideo/index.js +1 -0
  5. package/dist/cjs/youtube/Caption/Caption.js +17 -0
  6. package/dist/cjs/youtube/Caption/CaptionLanguage.js +17 -0
  7. package/dist/cjs/youtube/{Transcript/proto → Caption}/index.js +2 -1
  8. package/dist/cjs/youtube/Channel/ChannelParser.js +28 -7
  9. package/dist/cjs/youtube/Client/Client.js +9 -13
  10. package/dist/cjs/youtube/Comment/CommentParser.js +11 -12
  11. package/dist/cjs/youtube/LiveVideo/LiveVideo.js +15 -15
  12. package/dist/cjs/youtube/Video/Video.js +4 -6
  13. package/dist/cjs/youtube/Video/VideoParser.js +3 -3
  14. package/dist/cjs/youtube/VideoCompact/VideoCompact.js +2 -2
  15. package/dist/cjs/youtube/VideoCompact/VideoCompactParser.js +4 -2
  16. package/dist/cjs/youtube/index.js +1 -1
  17. package/dist/esm/common/shared/HTTP/HTTP.js +59 -12
  18. package/dist/esm/youtube/BaseVideo/BaseVideoParser.js +7 -2
  19. package/dist/esm/youtube/BaseVideo/VideoCaptions.js +133 -0
  20. package/dist/esm/youtube/BaseVideo/index.js +1 -0
  21. package/dist/esm/youtube/Caption/Caption.js +19 -0
  22. package/dist/esm/youtube/Caption/CaptionLanguage.js +15 -0
  23. package/dist/esm/youtube/Caption/index.js +2 -0
  24. package/dist/esm/youtube/Channel/ChannelParser.js +28 -7
  25. package/dist/esm/youtube/Client/Client.js +13 -18
  26. package/dist/esm/youtube/Comment/CommentParser.js +11 -12
  27. package/dist/esm/youtube/LiveVideo/LiveVideo.js +15 -15
  28. package/dist/esm/youtube/Video/Video.js +5 -7
  29. package/dist/esm/youtube/Video/VideoParser.js +4 -4
  30. package/dist/esm/youtube/VideoCompact/VideoCompact.js +2 -2
  31. package/dist/esm/youtube/VideoCompact/VideoCompactParser.js +4 -2
  32. package/dist/esm/youtube/index.js +1 -1
  33. package/dist/typings/common/shared/HTTP/HTTP.d.ts +2 -2
  34. package/dist/typings/youtube/BaseVideo/BaseVideo.d.ts +3 -0
  35. package/dist/typings/youtube/BaseVideo/VideoCaptions.d.ts +40 -0
  36. package/dist/typings/youtube/BaseVideo/index.d.ts +1 -0
  37. package/dist/typings/youtube/Caption/Caption.d.ts +22 -0
  38. package/dist/typings/youtube/Caption/CaptionLanguage.d.ts +30 -0
  39. package/dist/typings/youtube/Caption/index.d.ts +2 -0
  40. package/dist/typings/youtube/Client/Client.d.ts +8 -3
  41. package/dist/typings/youtube/LiveVideo/LiveVideo.d.ts +5 -5
  42. package/dist/typings/youtube/Video/Video.d.ts +3 -6
  43. package/dist/typings/youtube/VideoCompact/VideoCompact.d.ts +2 -2
  44. package/dist/typings/youtube/index.d.ts +1 -1
  45. package/package.json +2 -2
  46. package/dist/cjs/youtube/Transcript/Transcript.js +0 -27
  47. package/dist/cjs/youtube/Transcript/TranscriptParser.js +0 -13
  48. package/dist/cjs/youtube/Transcript/index.js +0 -15
  49. package/dist/cjs/youtube/Transcript/proto/TranscriptParamsProto.js +0 -12
  50. package/dist/esm/youtube/Transcript/Transcript.js +0 -29
  51. package/dist/esm/youtube/Transcript/TranscriptParser.js +0 -13
  52. package/dist/esm/youtube/Transcript/index.js +0 -3
  53. package/dist/esm/youtube/Transcript/proto/TranscriptParamsProto.js +0 -2
  54. package/dist/esm/youtube/Transcript/proto/index.js +0 -1
  55. package/dist/typings/youtube/Transcript/Transcript.d.ts +0 -29
  56. package/dist/typings/youtube/Transcript/TranscriptParser.d.ts +0 -5
  57. package/dist/typings/youtube/Transcript/index.d.ts +0 -3
  58. package/dist/typings/youtube/Transcript/proto/TranscriptParamsProto.d.ts +0 -7
  59. package/dist/typings/youtube/Transcript/proto/index.d.ts +0 -1
@@ -1,23 +1,25 @@
1
1
  import { RequestInit } from "node-fetch";
2
2
  import { HTTP } from "../../common";
3
+ import { Caption } from "../Caption";
3
4
  import { Channel } from "../Channel";
4
5
  import { LiveVideo } from "../LiveVideo";
5
6
  import { MixPlaylist } from "../MixPlaylist";
6
7
  import { Playlist } from "../Playlist";
7
8
  import { SearchOptions, SearchResult, SearchResultItem } from "../SearchResult";
8
- import { Transcript } from "../Transcript";
9
9
  import { Video } from "../Video";
10
10
  export declare type ClientOptions = {
11
11
  initialCookie: string;
12
12
  /** Optional options for http client */
13
13
  fetchOptions: Partial<RequestInit>;
14
14
  /** Optional options passed when sending a request to youtube (context.client) */
15
- youtubeClientOptions: Record<string, unknown>;
15
+ youtubeClientOptions: Record<string, string>;
16
16
  };
17
17
  /** Youtube Client */
18
18
  export declare class Client {
19
19
  /** @hidden */
20
20
  http: HTTP;
21
+ /** @hidden */
22
+ options: ClientOptions;
21
23
  constructor(options?: Partial<ClientOptions>);
22
24
  /**
23
25
  * Searches for videos / playlists / channels
@@ -39,5 +41,8 @@ export declare class Client {
39
41
  getVideo<T extends Video | LiveVideo | undefined>(videoId: string): Promise<T>;
40
42
  /** Get channel information by channel id+ */
41
43
  getChannel(channelId: string): Promise<Channel | undefined>;
42
- getVideoTranscript(videoId: string): Promise<Transcript[] | undefined>;
44
+ /**
45
+ * Get video transcript / caption by video id
46
+ */
47
+ getVideoTranscript(videoId: string, languageCode?: string): Promise<Caption[] | undefined>;
43
48
  }
@@ -19,11 +19,11 @@ declare class LiveVideo extends BaseVideo implements LiveVideoProperties {
19
19
  watchingCount: number;
20
20
  /** Current continuation token to load next chat */
21
21
  chatContinuation: string;
22
- private _delay;
23
- private _chatRequestPoolingTimeout;
24
- private _timeoutMs;
25
- private _isChatPlaying;
26
- private _chatQueue;
22
+ private delay;
23
+ private chatRequestPoolingTimeout;
24
+ private timeoutMs;
25
+ private isChatPlaying;
26
+ private chatQueue;
27
27
  /** @hidden */
28
28
  constructor(attr: LiveVideoProperties);
29
29
  /**
@@ -1,6 +1,6 @@
1
1
  import { Thumbnails, YoutubeRawData } from "../../common";
2
2
  import { BaseVideo, BaseVideoProperties } from "../BaseVideo";
3
- import { Transcript } from "../Transcript";
3
+ import { Caption } from "../Caption";
4
4
  import { VideoComments } from "./VideoComments";
5
5
  export declare type Chapter = {
6
6
  title: string;
@@ -32,11 +32,8 @@ export declare class Video extends BaseVideo implements VideoProperties {
32
32
  /**
33
33
  * Get Video transcript (if exists)
34
34
  *
35
- * Equivalent to
36
- * ```js
37
- * client.getVideoTranscript(video.id);
38
- * ```
35
+ * @deprecated use `video.captions.get()` instead
39
36
  */
40
- getTranscript(): Promise<Transcript[] | undefined>;
37
+ getTranscript(languageCode?: string): Promise<Caption[] | undefined>;
41
38
  }
42
39
  export {};
@@ -1,8 +1,8 @@
1
1
  import { Thumbnails, YoutubeRawData } from "../../common";
2
2
  import { Base, BaseProperties } from "../Base";
3
3
  import { BaseChannel } from "../BaseChannel";
4
+ import { Caption } from "../Caption";
4
5
  import { LiveVideo } from "../LiveVideo";
5
- import { Transcript } from "../Transcript";
6
6
  import { Video } from "../Video";
7
7
  /** @hidden */
8
8
  interface VideoCompactProperties extends BaseProperties {
@@ -61,6 +61,6 @@ export declare class VideoCompact extends Base implements VideoCompactProperties
61
61
  * client.getVideoTranscript(video.id);
62
62
  * ```
63
63
  */
64
- getTranscript(): Promise<Transcript[] | undefined>;
64
+ getTranscript(languageCode?: string): Promise<Caption[] | undefined>;
65
65
  }
66
66
  export {};
@@ -1,6 +1,7 @@
1
1
  export * from "./Base";
2
2
  export * from "./BaseChannel";
3
3
  export * from "./BaseVideo";
4
+ export * from "./Caption";
4
5
  export * from "./Channel";
5
6
  export * from "./Chat";
6
7
  export * from "./Client";
@@ -12,6 +13,5 @@ export * from "./Playlist";
12
13
  export * from "./PlaylistCompact";
13
14
  export * from "./Reply";
14
15
  export * from "./SearchResult";
15
- export * from "./Transcript";
16
16
  export * from "./Video";
17
17
  export * from "./VideoCompact";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.3.7",
3
+ "version": "1.4.1",
4
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
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -63,6 +63,6 @@
63
63
  "homepage": "https://suspiciouslookingowl.github.io/youtubei",
64
64
  "dependencies": {
65
65
  "node-fetch": "2.6.7",
66
- "protobufjs": "7.2.4"
66
+ "protobufjs": "7.2.6"
67
67
  }
68
68
  }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transcript = void 0;
4
- const TranscriptParser_1 = require("./TranscriptParser");
5
- /**
6
- * Represent a single video transcript entry
7
- */
8
- class Transcript {
9
- /** @hidden */
10
- constructor(attr) {
11
- Object.assign(this, attr);
12
- }
13
- /** transcript end time in miliseconds */
14
- get end() {
15
- return this.start + this.duration;
16
- }
17
- /**
18
- * Load this instance with raw data from Youtube
19
- *
20
- * @hidden
21
- */
22
- load(data) {
23
- TranscriptParser_1.TranscriptParser.loadTranscript(this, data);
24
- return this;
25
- }
26
- }
27
- exports.Transcript = Transcript;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TranscriptParser = void 0;
4
- class TranscriptParser {
5
- static loadTranscript(target, data) {
6
- const { cue, startOffsetMs, durationMs } = data;
7
- target.text = cue.simpleText;
8
- target.duration = +durationMs;
9
- target.start = +startOffsetMs;
10
- return target;
11
- }
12
- }
13
- exports.TranscriptParser = TranscriptParser;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./proto"), exports);
14
- __exportStar(require("./Transcript"), exports);
15
- __exportStar(require("./TranscriptParser"), exports);
@@ -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
- exports.TranscriptParamsProto = void 0;
7
- const protobufjs_1 = __importDefault(require("protobufjs"));
8
- exports.TranscriptParamsProto = protobufjs_1.default.parse(`
9
- message TranscriptParams {
10
- optional string videoId = 1;
11
- }
12
- `).root.lookupType("TranscriptParams");
@@ -1,29 +0,0 @@
1
- import { TranscriptParser } from "./TranscriptParser";
2
- /**
3
- * Represent a single video transcript entry
4
- */
5
- var Transcript = /** @class */ (function () {
6
- /** @hidden */
7
- function Transcript(attr) {
8
- Object.assign(this, attr);
9
- }
10
- Object.defineProperty(Transcript.prototype, "end", {
11
- /** transcript end time in miliseconds */
12
- get: function () {
13
- return this.start + this.duration;
14
- },
15
- enumerable: false,
16
- configurable: true
17
- });
18
- /**
19
- * Load this instance with raw data from Youtube
20
- *
21
- * @hidden
22
- */
23
- Transcript.prototype.load = function (data) {
24
- TranscriptParser.loadTranscript(this, data);
25
- return this;
26
- };
27
- return Transcript;
28
- }());
29
- export { Transcript };
@@ -1,13 +0,0 @@
1
- var TranscriptParser = /** @class */ (function () {
2
- function TranscriptParser() {
3
- }
4
- TranscriptParser.loadTranscript = function (target, data) {
5
- var cue = data.cue, startOffsetMs = data.startOffsetMs, durationMs = data.durationMs;
6
- target.text = cue.simpleText;
7
- target.duration = +durationMs;
8
- target.start = +startOffsetMs;
9
- return target;
10
- };
11
- return TranscriptParser;
12
- }());
13
- export { TranscriptParser };
@@ -1,3 +0,0 @@
1
- export * from "./proto";
2
- export * from "./Transcript";
3
- export * from "./TranscriptParser";
@@ -1,2 +0,0 @@
1
- import protobuf from "protobufjs";
2
- export var TranscriptParamsProto = protobuf.parse("\n\tmessage TranscriptParams {\n\t\toptional string videoId = 1;\n\t}\n").root.lookupType("TranscriptParams");
@@ -1 +0,0 @@
1
- export * from "./TranscriptParamsProto";
@@ -1,29 +0,0 @@
1
- import { YoutubeRawData } from "../../common";
2
- /** @hidden */
3
- interface TranscriptProperties {
4
- text?: string;
5
- start?: number;
6
- duration?: number;
7
- }
8
- /**
9
- * Represent a single video transcript entry
10
- */
11
- export declare class Transcript implements TranscriptProperties {
12
- /** transcript content */
13
- text: string;
14
- /** transcript start time in miliseconds */
15
- start: number;
16
- /** transcript duration in miliseconds */
17
- duration: number;
18
- /** @hidden */
19
- constructor(attr?: TranscriptProperties);
20
- /** transcript end time in miliseconds */
21
- get end(): number;
22
- /**
23
- * Load this instance with raw data from Youtube
24
- *
25
- * @hidden
26
- */
27
- load(data: YoutubeRawData): Transcript;
28
- }
29
- export {};
@@ -1,5 +0,0 @@
1
- import { YoutubeRawData } from "../../common";
2
- import { Transcript } from "./Transcript";
3
- export declare class TranscriptParser {
4
- static loadTranscript(target: Transcript, data: YoutubeRawData): Transcript;
5
- }
@@ -1,3 +0,0 @@
1
- export * from "./proto";
2
- export * from "./Transcript";
3
- export * from "./TranscriptParser";
@@ -1,7 +0,0 @@
1
- import protobuf from "protobufjs";
2
- export declare type TranscriptParams = {
3
- TranscriptParams: {
4
- videoId: string;
5
- };
6
- };
7
- export declare const TranscriptParamsProto: protobuf.Type;
@@ -1 +0,0 @@
1
- export * from "./TranscriptParamsProto";