youtubei 1.4.0 → 1.4.2
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/youtube/BaseChannel/BaseChannelParser.js +1 -3
- package/dist/cjs/youtube/BaseVideo/VideoCaptions.js +2 -2
- package/dist/cjs/youtube/Channel/ChannelParser.js +30 -8
- package/dist/cjs/youtube/index.js +1 -0
- package/dist/esm/youtube/BaseChannel/BaseChannelParser.js +2 -4
- package/dist/esm/youtube/BaseVideo/VideoCaptions.js +2 -2
- package/dist/esm/youtube/Channel/ChannelParser.js +30 -8
- package/dist/esm/youtube/index.js +1 -0
- package/dist/typings/youtube/BaseChannel/BaseChannel.d.ts +0 -3
- package/dist/typings/youtube/BaseVideo/VideoCaptions.d.ts +2 -2
- package/dist/typings/youtube/Channel/Channel.d.ts +3 -0
- package/dist/typings/youtube/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -4,12 +4,10 @@ exports.BaseChannelParser = void 0;
|
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
class BaseChannelParser {
|
|
6
6
|
static loadBaseChannel(target, data) {
|
|
7
|
-
|
|
8
|
-
const { channelId, title, thumbnail, videoCountText, subscriberCountText } = data;
|
|
7
|
+
const { channelId, title, thumbnail, subscriberCountText } = data;
|
|
9
8
|
target.id = channelId;
|
|
10
9
|
target.name = title.simpleText;
|
|
11
10
|
target.thumbnails = new common_1.Thumbnails().load(thumbnail.thumbnails);
|
|
12
|
-
target.videoCount = common_1.stripToInt((_a = videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs) === null || _a === void 0 ? void 0 : _a[0].text) || 0; // TODO this sometimes contains subscriber count for some reason
|
|
13
11
|
target.subscriberCount = subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText;
|
|
14
12
|
return target;
|
|
15
13
|
}
|
|
@@ -18,9 +18,9 @@ const Caption_1 = require("../Caption");
|
|
|
18
18
|
* @example
|
|
19
19
|
* ```js
|
|
20
20
|
*
|
|
21
|
-
* console.log(
|
|
21
|
+
* console.log(video.captions.languages.map((l) => `${l.code} - ${l.name}`)); // printing out available languages for captions
|
|
22
22
|
*
|
|
23
|
-
* console.log(await
|
|
23
|
+
* console.log(await video.captions.get("en")); // printing out captions of a specific language using language code
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
class VideoCaptions extends Base_1.Base {
|
|
@@ -7,16 +7,38 @@ const PlaylistCompact_1 = require("../PlaylistCompact");
|
|
|
7
7
|
const VideoCompact_1 = require("../VideoCompact");
|
|
8
8
|
class ChannelParser {
|
|
9
9
|
static loadChannel(target, data) {
|
|
10
|
-
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
11
|
+
let channelId, title, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
|
|
12
|
+
const { c4TabbedHeaderRenderer, pageHeaderRenderer } = data.header;
|
|
13
|
+
if (c4TabbedHeaderRenderer) {
|
|
14
|
+
channelId = c4TabbedHeaderRenderer.channelId;
|
|
15
|
+
title = c4TabbedHeaderRenderer.title;
|
|
16
|
+
subscriberCountText = (_a = c4TabbedHeaderRenderer.subscriberCountText) === null || _a === void 0 ? void 0 : _a.simpleText;
|
|
17
|
+
videoCountText = (_d = (_c = (_b = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.videosCountText) === null || _b === void 0 ? void 0 : _b.runs) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text;
|
|
18
|
+
avatar = (_e = c4TabbedHeaderRenderer.avatar) === null || _e === void 0 ? void 0 : _e.thumbnails;
|
|
19
|
+
tvBanner = (_f = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.tvBanner) === null || _f === void 0 ? void 0 : _f.thumbnails;
|
|
20
|
+
mobileBanner = (_g = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.mobileBanner) === null || _g === void 0 ? void 0 : _g.thumbnails;
|
|
21
|
+
banner = (_h = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.banner) === null || _h === void 0 ? void 0 : _h.thumbnails;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
channelId =
|
|
25
|
+
data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.endpoint
|
|
26
|
+
.browseEndpoint.browseId;
|
|
27
|
+
title = pageHeaderRenderer.pageTitle;
|
|
28
|
+
const { metadata, image: imageModel, banner: bannerModel, } = pageHeaderRenderer.content.pageHeaderViewModel;
|
|
29
|
+
subscriberCountText =
|
|
30
|
+
metadata.contentMetadataViewModel.metadataRows[1].metadataParts[0].text.content;
|
|
31
|
+
avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
|
|
32
|
+
banner = bannerModel.imageBannerViewModel.image.sources;
|
|
33
|
+
}
|
|
11
34
|
target.id = channelId;
|
|
12
35
|
target.name = title;
|
|
13
|
-
target.thumbnails = new common_1.Thumbnails().load(avatar
|
|
14
|
-
target.videoCount =
|
|
15
|
-
target.subscriberCount = subscriberCountText
|
|
16
|
-
|
|
17
|
-
target.
|
|
18
|
-
target.
|
|
19
|
-
target.mobileBanner = new common_1.Thumbnails().load((mobileBanner === null || mobileBanner === void 0 ? void 0 : mobileBanner.thumbnails) || []);
|
|
36
|
+
target.thumbnails = new common_1.Thumbnails().load(avatar);
|
|
37
|
+
target.videoCount = videoCountText;
|
|
38
|
+
target.subscriberCount = subscriberCountText;
|
|
39
|
+
target.banner = new common_1.Thumbnails().load(banner || []);
|
|
40
|
+
target.tvBanner = new common_1.Thumbnails().load(tvBanner || []);
|
|
41
|
+
target.mobileBanner = new common_1.Thumbnails().load(mobileBanner || []);
|
|
20
42
|
target.shelves = ChannelParser.parseShelves(target, data);
|
|
21
43
|
return target;
|
|
22
44
|
}
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./Base"), exports);
|
|
14
14
|
__exportStar(require("./BaseChannel"), exports);
|
|
15
15
|
__exportStar(require("./BaseVideo"), exports);
|
|
16
|
+
__exportStar(require("./Caption"), exports);
|
|
16
17
|
__exportStar(require("./Channel"), exports);
|
|
17
18
|
__exportStar(require("./Chat"), exports);
|
|
18
19
|
__exportStar(require("./Client"), exports);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Thumbnails } from "../../common";
|
|
2
2
|
var BaseChannelParser = /** @class */ (function () {
|
|
3
3
|
function BaseChannelParser() {
|
|
4
4
|
}
|
|
5
5
|
BaseChannelParser.loadBaseChannel = function (target, data) {
|
|
6
|
-
var
|
|
7
|
-
var channelId = data.channelId, title = data.title, thumbnail = data.thumbnail, videoCountText = data.videoCountText, subscriberCountText = data.subscriberCountText;
|
|
6
|
+
var channelId = data.channelId, title = data.title, thumbnail = data.thumbnail, subscriberCountText = data.subscriberCountText;
|
|
8
7
|
target.id = channelId;
|
|
9
8
|
target.name = title.simpleText;
|
|
10
9
|
target.thumbnails = new Thumbnails().load(thumbnail.thumbnails);
|
|
11
|
-
target.videoCount = stripToInt((_a = videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs) === null || _a === void 0 ? void 0 : _a[0].text) || 0; // TODO this sometimes contains subscriber count for some reason
|
|
12
10
|
target.subscriberCount = subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText;
|
|
13
11
|
return target;
|
|
14
12
|
};
|
|
@@ -55,9 +55,9 @@ import { Caption, CaptionLanguage } from "../Caption";
|
|
|
55
55
|
* @example
|
|
56
56
|
* ```js
|
|
57
57
|
*
|
|
58
|
-
* console.log(
|
|
58
|
+
* console.log(video.captions.languages.map((l) => `${l.code} - ${l.name}`)); // printing out available languages for captions
|
|
59
59
|
*
|
|
60
|
-
* console.log(await
|
|
60
|
+
* console.log(await video.captions.get("en")); // printing out captions of a specific language using language code
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
var VideoCaptions = /** @class */ (function (_super) {
|
|
@@ -17,16 +17,38 @@ var ChannelParser = /** @class */ (function () {
|
|
|
17
17
|
function ChannelParser() {
|
|
18
18
|
}
|
|
19
19
|
ChannelParser.loadChannel = function (target, data) {
|
|
20
|
-
var _a
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
var channelId, title, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
|
|
22
|
+
var _j = data.header, c4TabbedHeaderRenderer = _j.c4TabbedHeaderRenderer, pageHeaderRenderer = _j.pageHeaderRenderer;
|
|
23
|
+
if (c4TabbedHeaderRenderer) {
|
|
24
|
+
channelId = c4TabbedHeaderRenderer.channelId;
|
|
25
|
+
title = c4TabbedHeaderRenderer.title;
|
|
26
|
+
subscriberCountText = (_a = c4TabbedHeaderRenderer.subscriberCountText) === null || _a === void 0 ? void 0 : _a.simpleText;
|
|
27
|
+
videoCountText = (_d = (_c = (_b = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.videosCountText) === null || _b === void 0 ? void 0 : _b.runs) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text;
|
|
28
|
+
avatar = (_e = c4TabbedHeaderRenderer.avatar) === null || _e === void 0 ? void 0 : _e.thumbnails;
|
|
29
|
+
tvBanner = (_f = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.tvBanner) === null || _f === void 0 ? void 0 : _f.thumbnails;
|
|
30
|
+
mobileBanner = (_g = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.mobileBanner) === null || _g === void 0 ? void 0 : _g.thumbnails;
|
|
31
|
+
banner = (_h = c4TabbedHeaderRenderer === null || c4TabbedHeaderRenderer === void 0 ? void 0 : c4TabbedHeaderRenderer.banner) === null || _h === void 0 ? void 0 : _h.thumbnails;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
channelId =
|
|
35
|
+
data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.endpoint
|
|
36
|
+
.browseEndpoint.browseId;
|
|
37
|
+
title = pageHeaderRenderer.pageTitle;
|
|
38
|
+
var _k = pageHeaderRenderer.content.pageHeaderViewModel, metadata = _k.metadata, imageModel = _k.image, bannerModel = _k.banner;
|
|
39
|
+
subscriberCountText =
|
|
40
|
+
metadata.contentMetadataViewModel.metadataRows[1].metadataParts[0].text.content;
|
|
41
|
+
avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
|
|
42
|
+
banner = bannerModel.imageBannerViewModel.image.sources;
|
|
43
|
+
}
|
|
21
44
|
target.id = channelId;
|
|
22
45
|
target.name = title;
|
|
23
|
-
target.thumbnails = new Thumbnails().load(avatar
|
|
24
|
-
target.videoCount =
|
|
25
|
-
target.subscriberCount = subscriberCountText
|
|
26
|
-
|
|
27
|
-
target.
|
|
28
|
-
target.
|
|
29
|
-
target.mobileBanner = new Thumbnails().load((mobileBanner === null || mobileBanner === void 0 ? void 0 : mobileBanner.thumbnails) || []);
|
|
46
|
+
target.thumbnails = new Thumbnails().load(avatar);
|
|
47
|
+
target.videoCount = videoCountText;
|
|
48
|
+
target.subscriberCount = subscriberCountText;
|
|
49
|
+
target.banner = new Thumbnails().load(banner || []);
|
|
50
|
+
target.tvBanner = new Thumbnails().load(tvBanner || []);
|
|
51
|
+
target.mobileBanner = new Thumbnails().load(mobileBanner || []);
|
|
30
52
|
target.shelves = ChannelParser.parseShelves(target, data);
|
|
31
53
|
return target;
|
|
32
54
|
};
|
|
@@ -9,7 +9,6 @@ export interface BaseChannelProperties extends BaseProperties {
|
|
|
9
9
|
id?: string;
|
|
10
10
|
name?: string;
|
|
11
11
|
thumbnails?: Thumbnails;
|
|
12
|
-
videoCount?: number;
|
|
13
12
|
subscriberCount?: string;
|
|
14
13
|
}
|
|
15
14
|
/** Represents a Youtube Channel */
|
|
@@ -19,8 +18,6 @@ export declare class BaseChannel extends Base implements BaseChannelProperties {
|
|
|
19
18
|
name: string;
|
|
20
19
|
/** Thumbnails of this Channel */
|
|
21
20
|
thumbnails?: Thumbnails;
|
|
22
|
-
/** How many video does this channel have */
|
|
23
|
-
videoCount?: number;
|
|
24
21
|
/**
|
|
25
22
|
* How many subscriber does this channel have,
|
|
26
23
|
*
|
|
@@ -14,9 +14,9 @@ interface ConstructorParams {
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```js
|
|
16
16
|
*
|
|
17
|
-
* console.log(
|
|
17
|
+
* console.log(video.captions.languages.map((l) => `${l.code} - ${l.name}`)); // printing out available languages for captions
|
|
18
18
|
*
|
|
19
|
-
* console.log(await
|
|
19
|
+
* console.log(await video.captions.get("en")); // printing out captions of a specific language using language code
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare class VideoCaptions extends Base {
|
|
@@ -7,6 +7,7 @@ export declare type ChannelShelf = Shelf<BaseChannel[] | VideoCompact[] | Playli
|
|
|
7
7
|
};
|
|
8
8
|
/** @hidden */
|
|
9
9
|
interface ChannelProperties extends BaseChannelProperties {
|
|
10
|
+
videoCount?: string;
|
|
10
11
|
banner?: Thumbnails;
|
|
11
12
|
tvBanner?: Thumbnails;
|
|
12
13
|
mobileBanner?: Thumbnails;
|
|
@@ -14,6 +15,8 @@ interface ChannelProperties extends BaseChannelProperties {
|
|
|
14
15
|
}
|
|
15
16
|
/** Represents a Youtube Channel */
|
|
16
17
|
export declare class Channel extends BaseChannel implements ChannelProperties {
|
|
18
|
+
/** How many video does this channel have */
|
|
19
|
+
videoCount?: string;
|
|
17
20
|
banner: Thumbnails;
|
|
18
21
|
mobileBanner: Thumbnails;
|
|
19
22
|
tvBanner: Thumbnails;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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.
|
|
66
|
+
"protobufjs": "7.2.6"
|
|
67
67
|
}
|
|
68
68
|
}
|