youtubei 1.3.6 → 1.4.0
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.
- package/dist/cjs/common/shared/HTTP/HTTP.js +18 -7
- package/dist/cjs/youtube/BaseVideo/BaseVideoParser.js +9 -4
- package/dist/cjs/youtube/BaseVideo/VideoCaptions.js +81 -0
- package/dist/cjs/youtube/BaseVideo/index.js +1 -0
- package/dist/cjs/youtube/Caption/Caption.js +17 -0
- package/dist/cjs/youtube/Caption/CaptionLanguage.js +17 -0
- package/dist/cjs/youtube/{Transcript/proto → Caption}/index.js +2 -1
- package/dist/cjs/youtube/Client/Client.js +16 -18
- package/dist/cjs/youtube/Comment/CommentParser.js +11 -12
- package/dist/cjs/youtube/LiveVideo/LiveVideo.js +15 -15
- package/dist/cjs/youtube/LiveVideo/LiveVideoParser.js +1 -1
- package/dist/cjs/youtube/Video/Video.js +4 -6
- package/dist/cjs/youtube/Video/VideoParser.js +5 -5
- package/dist/cjs/youtube/VideoCompact/VideoCompact.js +2 -2
- package/dist/cjs/youtube/VideoCompact/VideoCompactParser.js +9 -5
- package/dist/cjs/youtube/index.js +0 -1
- package/dist/esm/common/shared/HTTP/HTTP.js +59 -12
- package/dist/esm/youtube/BaseVideo/BaseVideoParser.js +9 -4
- package/dist/esm/youtube/BaseVideo/VideoCaptions.js +133 -0
- package/dist/esm/youtube/BaseVideo/index.js +1 -0
- package/dist/esm/youtube/Caption/Caption.js +19 -0
- package/dist/esm/youtube/Caption/CaptionLanguage.js +15 -0
- package/dist/esm/youtube/Caption/index.js +2 -0
- package/dist/esm/youtube/Client/Client.js +21 -24
- package/dist/esm/youtube/Comment/CommentParser.js +11 -12
- package/dist/esm/youtube/LiveVideo/LiveVideo.js +15 -15
- package/dist/esm/youtube/LiveVideo/LiveVideoParser.js +1 -1
- package/dist/esm/youtube/Video/Video.js +5 -7
- package/dist/esm/youtube/Video/VideoParser.js +6 -6
- package/dist/esm/youtube/VideoCompact/VideoCompact.js +2 -2
- package/dist/esm/youtube/VideoCompact/VideoCompactParser.js +9 -5
- package/dist/esm/youtube/index.js +0 -1
- package/dist/typings/common/shared/HTTP/HTTP.d.ts +2 -2
- package/dist/typings/youtube/BaseVideo/BaseVideo.d.ts +3 -0
- package/dist/typings/youtube/BaseVideo/VideoCaptions.d.ts +40 -0
- package/dist/typings/youtube/BaseVideo/index.d.ts +1 -0
- package/dist/typings/youtube/Caption/Caption.d.ts +22 -0
- package/dist/typings/youtube/Caption/CaptionLanguage.d.ts +30 -0
- package/dist/typings/youtube/Caption/index.d.ts +2 -0
- package/dist/typings/youtube/Client/Client.d.ts +8 -3
- package/dist/typings/youtube/LiveVideo/LiveVideo.d.ts +5 -5
- package/dist/typings/youtube/Video/Video.d.ts +3 -6
- package/dist/typings/youtube/VideoCompact/VideoCompact.d.ts +2 -2
- package/dist/typings/youtube/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/youtube/Transcript/Transcript.js +0 -27
- package/dist/cjs/youtube/Transcript/TranscriptParser.js +0 -13
- package/dist/cjs/youtube/Transcript/index.js +0 -15
- package/dist/cjs/youtube/Transcript/proto/TranscriptParamsProto.js +0 -12
- package/dist/esm/youtube/Transcript/Transcript.js +0 -29
- package/dist/esm/youtube/Transcript/TranscriptParser.js +0 -13
- package/dist/esm/youtube/Transcript/index.js +0 -3
- package/dist/esm/youtube/Transcript/proto/TranscriptParamsProto.js +0 -2
- package/dist/esm/youtube/Transcript/proto/index.js +0 -1
- package/dist/typings/youtube/Transcript/Transcript.d.ts +0 -29
- package/dist/typings/youtube/Transcript/TranscriptParser.d.ts +0 -5
- package/dist/typings/youtube/Transcript/index.d.ts +0 -3
- package/dist/typings/youtube/Transcript/proto/TranscriptParamsProto.d.ts +0 -7
- package/dist/typings/youtube/Transcript/proto/index.d.ts +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VideoCaptions } from "../BaseVideo";
|
|
2
|
+
import { Caption } from "./Caption";
|
|
3
|
+
/** @hidden */
|
|
4
|
+
interface CaptionLanguageProperties {
|
|
5
|
+
name?: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
isTranslatable?: boolean;
|
|
8
|
+
url?: string;
|
|
9
|
+
captions?: VideoCaptions;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Represents a caption language option
|
|
13
|
+
*/
|
|
14
|
+
export declare class CaptionLanguage implements CaptionLanguageProperties {
|
|
15
|
+
/** Caption language name */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Caption language code */
|
|
18
|
+
code: string;
|
|
19
|
+
/** Whether this language is translatable */
|
|
20
|
+
isTranslatable: boolean;
|
|
21
|
+
/** Caption language url */
|
|
22
|
+
url: string;
|
|
23
|
+
/** @hidden */
|
|
24
|
+
captions: VideoCaptions;
|
|
25
|
+
/** @hidden */
|
|
26
|
+
constructor(attr?: CaptionLanguageProperties);
|
|
27
|
+
/** Get the captions of this language using the url */
|
|
28
|
+
get(translationLanguageCode?: string): Promise<Caption[] | undefined>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -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,
|
|
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
|
-
|
|
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
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
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 {
|
|
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
|
-
*
|
|
36
|
-
* ```js
|
|
37
|
-
* client.getVideoTranscript(video.id);
|
|
38
|
-
* ```
|
|
35
|
+
* @deprecated use `video.captions.get()` instead
|
|
39
36
|
*/
|
|
40
|
-
getTranscript(): Promise<
|
|
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<
|
|
64
|
+
getTranscript(languageCode?: string): Promise<Caption[] | undefined>;
|
|
65
65
|
}
|
|
66
66
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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",
|
|
@@ -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 +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 +0,0 @@
|
|
|
1
|
-
export * from "./TranscriptParamsProto";
|