youtubei 1.3.3 → 1.3.5
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.
|
@@ -7,7 +7,7 @@ const PlaylistCompact_1 = require("../PlaylistCompact");
|
|
|
7
7
|
const VideoCompact_1 = require("../VideoCompact");
|
|
8
8
|
class BaseVideoParser {
|
|
9
9
|
static loadBaseVideo(target, data) {
|
|
10
|
-
var _a, _b;
|
|
10
|
+
var _a, _b, _c;
|
|
11
11
|
const videoInfo = BaseVideoParser.parseRawData(data);
|
|
12
12
|
// Basic information
|
|
13
13
|
target.id = videoInfo.videoDetails.videoId;
|
|
@@ -33,8 +33,7 @@ class BaseVideoParser {
|
|
|
33
33
|
((_b = (_a = videoInfo.superTitleLink) === null || _a === void 0 ? void 0 : _a.runs) === null || _b === void 0 ? void 0 : _b.map((r) => r.text.trim()).filter((t) => t)) || [];
|
|
34
34
|
target.description = videoInfo.videoDetails.shortDescription || "";
|
|
35
35
|
// related videos
|
|
36
|
-
const secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
|
|
37
|
-
.results;
|
|
36
|
+
const secondaryContents = (_c = data[3].response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
|
|
38
37
|
if (secondaryContents) {
|
|
39
38
|
target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
|
|
40
39
|
target.related.continuation = common_1.getContinuationFromItems(secondaryContents);
|
|
@@ -71,17 +70,24 @@ class BaseVideoParser {
|
|
|
71
70
|
.filter((c) => c !== undefined);
|
|
72
71
|
}
|
|
73
72
|
static parseButtonRenderer(data) {
|
|
74
|
-
var _a;
|
|
75
|
-
let
|
|
76
|
-
if (
|
|
77
|
-
buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
|
|
73
|
+
var _a, _b;
|
|
74
|
+
let likeCount;
|
|
75
|
+
if (data.toggleButtonRenderer || data.buttonRenderer) {
|
|
76
|
+
const buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
|
|
77
|
+
likeCount = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
|
|
78
78
|
}
|
|
79
|
-
else {
|
|
79
|
+
else if (data.segmentedLikeDislikeButtonRenderer) {
|
|
80
80
|
const likeButton = data.segmentedLikeDislikeButtonRenderer.likeButton;
|
|
81
|
-
buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
|
|
81
|
+
const buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
|
|
82
|
+
likeCount = (((_b = buttonRenderer.defaultText) === null || _b === void 0 ? void 0 : _b.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
|
|
83
|
+
}
|
|
84
|
+
else if (data.segmentedLikeDislikeButtonViewModel) {
|
|
85
|
+
likeCount =
|
|
86
|
+
data.segmentedLikeDislikeButtonViewModel.likeButtonViewModel.likeButtonViewModel
|
|
87
|
+
.toggleButtonViewModel.toggleButtonViewModel.defaultButtonViewModel
|
|
88
|
+
.buttonViewModel.accessibilityText;
|
|
82
89
|
}
|
|
83
|
-
|
|
84
|
-
return accessibilityData.label;
|
|
90
|
+
return likeCount;
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
exports.BaseVideoParser = BaseVideoParser;
|
|
@@ -78,8 +78,10 @@ class Client {
|
|
|
78
78
|
const response = yield this.http.get(`${constants_1.WATCH_END_POINT}`, {
|
|
79
79
|
params: { v: videoId, pbj: "1" },
|
|
80
80
|
});
|
|
81
|
-
if (!response.data[3].response.contents
|
|
81
|
+
if (!response.data[3].response.contents ||
|
|
82
|
+
response.data[2].playerResponse.playabilityStatus.status === "ERROR") {
|
|
82
83
|
return undefined;
|
|
84
|
+
}
|
|
83
85
|
return (!response.data[2].playerResponse.playabilityStatus.liveStreamability
|
|
84
86
|
? new Video_1.Video({ client: this }).load(response.data)
|
|
85
87
|
: new LiveVideo_1.LiveVideo({ client: this }).load(response.data));
|
|
@@ -17,7 +17,7 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
17
17
|
function BaseVideoParser() {
|
|
18
18
|
}
|
|
19
19
|
BaseVideoParser.loadBaseVideo = function (target, data) {
|
|
20
|
-
var _a, _b;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
22
22
|
// Basic information
|
|
23
23
|
target.id = videoInfo.videoDetails.videoId;
|
|
@@ -27,7 +27,7 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
27
27
|
target.isLiveContent = videoInfo.videoDetails.isLiveContent;
|
|
28
28
|
target.thumbnails = new Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
29
29
|
// Channel
|
|
30
|
-
var
|
|
30
|
+
var _d = videoInfo.owner.videoOwnerRenderer, title = _d.title, thumbnail = _d.thumbnail, subscriberCountText = _d.subscriberCountText;
|
|
31
31
|
target.channel = new BaseChannel({
|
|
32
32
|
client: target.client,
|
|
33
33
|
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
@@ -43,8 +43,7 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
43
43
|
((_b = (_a = videoInfo.superTitleLink) === null || _a === void 0 ? void 0 : _a.runs) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.text.trim(); }).filter(function (t) { return t; })) || [];
|
|
44
44
|
target.description = videoInfo.videoDetails.shortDescription || "";
|
|
45
45
|
// related videos
|
|
46
|
-
var secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
|
|
47
|
-
.results;
|
|
46
|
+
var secondaryContents = (_c = data[3].response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
|
|
48
47
|
if (secondaryContents) {
|
|
49
48
|
target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
|
|
50
49
|
target.related.continuation = getContinuationFromItems(secondaryContents);
|
|
@@ -81,17 +80,24 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
81
80
|
.filter(function (c) { return c !== undefined; });
|
|
82
81
|
};
|
|
83
82
|
BaseVideoParser.parseButtonRenderer = function (data) {
|
|
84
|
-
var _a;
|
|
85
|
-
var
|
|
86
|
-
if (
|
|
87
|
-
buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
|
|
83
|
+
var _a, _b;
|
|
84
|
+
var likeCount;
|
|
85
|
+
if (data.toggleButtonRenderer || data.buttonRenderer) {
|
|
86
|
+
var buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
|
|
87
|
+
likeCount = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
|
|
88
88
|
}
|
|
89
|
-
else {
|
|
89
|
+
else if (data.segmentedLikeDislikeButtonRenderer) {
|
|
90
90
|
var likeButton = data.segmentedLikeDislikeButtonRenderer.likeButton;
|
|
91
|
-
buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
|
|
91
|
+
var buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
|
|
92
|
+
likeCount = (((_b = buttonRenderer.defaultText) === null || _b === void 0 ? void 0 : _b.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
|
|
93
|
+
}
|
|
94
|
+
else if (data.segmentedLikeDislikeButtonViewModel) {
|
|
95
|
+
likeCount =
|
|
96
|
+
data.segmentedLikeDislikeButtonViewModel.likeButtonViewModel.likeButtonViewModel
|
|
97
|
+
.toggleButtonViewModel.toggleButtonViewModel.defaultButtonViewModel
|
|
98
|
+
.buttonViewModel.accessibilityText;
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
return accessibilityData.label;
|
|
100
|
+
return likeCount;
|
|
95
101
|
};
|
|
96
102
|
return BaseVideoParser;
|
|
97
103
|
}());
|
|
@@ -143,8 +143,10 @@ var Client = /** @class */ (function () {
|
|
|
143
143
|
})];
|
|
144
144
|
case 1:
|
|
145
145
|
response = _a.sent();
|
|
146
|
-
if (!response.data[3].response.contents
|
|
146
|
+
if (!response.data[3].response.contents ||
|
|
147
|
+
response.data[2].playerResponse.playabilityStatus.status === "ERROR") {
|
|
147
148
|
return [2 /*return*/, undefined];
|
|
149
|
+
}
|
|
148
150
|
return [2 /*return*/, (!response.data[2].playerResponse.playabilityStatus.liveStreamability
|
|
149
151
|
? new Video({ client: this }).load(response.data)
|
|
150
152
|
: new LiveVideo({ client: this }).load(response.data))];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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",
|