youtubei 1.3.6 → 1.3.7
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/BaseVideo/BaseVideoParser.js +3 -3
- package/dist/cjs/youtube/Client/Client.js +7 -5
- package/dist/cjs/youtube/LiveVideo/LiveVideoParser.js +1 -1
- package/dist/cjs/youtube/Video/VideoParser.js +2 -2
- package/dist/cjs/youtube/VideoCompact/VideoCompactParser.js +6 -4
- package/dist/esm/youtube/BaseVideo/BaseVideoParser.js +3 -3
- package/dist/esm/youtube/Client/Client.js +8 -6
- package/dist/esm/youtube/LiveVideo/LiveVideoParser.js +1 -1
- package/dist/esm/youtube/Video/VideoParser.js +2 -2
- package/dist/esm/youtube/VideoCompact/VideoCompactParser.js +6 -4
- package/package.json +1 -1
|
@@ -33,7 +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 = (_c = data
|
|
36
|
+
const secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
|
|
37
37
|
if (secondaryContents) {
|
|
38
38
|
target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
|
|
39
39
|
target.related.continuation = common_1.getContinuationFromItems(secondaryContents);
|
|
@@ -49,11 +49,11 @@ class BaseVideoParser {
|
|
|
49
49
|
return common_1.getContinuationFromItems(secondaryContents);
|
|
50
50
|
}
|
|
51
51
|
static parseRawData(data) {
|
|
52
|
-
const contents = data
|
|
52
|
+
const contents = data.response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
53
53
|
const primaryInfo = contents.find((c) => "videoPrimaryInfoRenderer" in c)
|
|
54
54
|
.videoPrimaryInfoRenderer;
|
|
55
55
|
const secondaryInfo = contents.find((c) => "videoSecondaryInfoRenderer" in c).videoSecondaryInfoRenderer;
|
|
56
|
-
const videoDetails = data
|
|
56
|
+
const videoDetails = data.playerResponse.videoDetails;
|
|
57
57
|
return Object.assign(Object.assign(Object.assign({}, secondaryInfo), primaryInfo), { videoDetails });
|
|
58
58
|
}
|
|
59
59
|
static parseCompactRenderer(data, client) {
|
|
@@ -79,13 +79,15 @@ class Client {
|
|
|
79
79
|
const response = yield this.http.get(`${constants_1.WATCH_END_POINT}`, {
|
|
80
80
|
params: { v: videoId, pbj: "1" },
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
response.data
|
|
82
|
+
const data = Array.isArray(response.data)
|
|
83
|
+
? response.data.reduce((prev, curr) => (Object.assign(Object.assign({}, prev), curr)), {})
|
|
84
|
+
: response.data;
|
|
85
|
+
if (!((_a = data.response) === null || _a === void 0 ? void 0 : _a.contents) || data.playerResponse.playabilityStatus.status === "ERROR") {
|
|
84
86
|
return undefined;
|
|
85
87
|
}
|
|
86
|
-
return (!
|
|
87
|
-
? new Video_1.Video({ client: this }).load(
|
|
88
|
-
: new LiveVideo_1.LiveVideo({ client: this }).load(
|
|
88
|
+
return (!data.playerResponse.playabilityStatus.liveStreamability
|
|
89
|
+
? new Video_1.Video({ client: this }).load(data)
|
|
90
|
+
: new LiveVideo_1.LiveVideo({ client: this }).load(data));
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
93
|
/** Get channel information by channel id+ */
|
|
@@ -10,7 +10,7 @@ class LiveVideoParser {
|
|
|
10
10
|
.map((r) => r.text)
|
|
11
11
|
.join(" ")
|
|
12
12
|
.replace(/[^0-9]/g, "");
|
|
13
|
-
target.chatContinuation = (_a = data
|
|
13
|
+
target.chatContinuation = (_a = data.response.contents.twoColumnWatchNextResults.conversationBar.liveChatRenderer) === null || _a === void 0 ? void 0 : _a.continuations[0].reloadContinuationData.continuation;
|
|
14
14
|
return target;
|
|
15
15
|
}
|
|
16
16
|
static parseChats(data) {
|
|
@@ -9,11 +9,11 @@ class VideoParser {
|
|
|
9
9
|
var _a, _b, _c;
|
|
10
10
|
const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
|
|
11
11
|
target.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
12
|
-
const itemSectionRenderer = (_a = data
|
|
12
|
+
const itemSectionRenderer = (_a = data.response.contents.twoColumnWatchNextResults.results.results.contents
|
|
13
13
|
.reverse()
|
|
14
14
|
.find((c) => c.itemSectionRenderer)) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer;
|
|
15
15
|
target.comments.continuation = common_1.getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
|
|
16
|
-
const chapters = (_c = (_b = data
|
|
16
|
+
const chapters = (_c = (_b = data.response.playerOverlays.playerOverlayRenderer.decoratedPlayerBarRenderer) === null || _b === void 0 ? void 0 : _b.decoratedPlayerBarRenderer.playerBar.multiMarkersPlayerBarRenderer.markersMap) === null || _c === void 0 ? void 0 : _c[0].value.chapters;
|
|
17
17
|
target.chapters =
|
|
18
18
|
(chapters === null || chapters === void 0 ? void 0 : chapters.map(({ chapterRenderer: c }) => ({
|
|
19
19
|
title: c.title.simpleText,
|
|
@@ -5,16 +5,18 @@ const common_1 = require("../../common");
|
|
|
5
5
|
const BaseChannel_1 = require("../BaseChannel");
|
|
6
6
|
class VideoCompactParser {
|
|
7
7
|
static loadVideoCompact(target, data) {
|
|
8
|
-
var _a, _b, _c;
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
9
|
const { videoId, title, headline, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
|
|
10
10
|
target.id = videoId;
|
|
11
|
-
target.title = headline
|
|
11
|
+
target.title = headline
|
|
12
|
+
? headline.simpleText
|
|
13
|
+
: title.simpleText || ((_b = (_a = title.runs) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) || "";
|
|
12
14
|
target.thumbnails = new common_1.Thumbnails().load(thumbnail.thumbnails);
|
|
13
15
|
target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
14
16
|
target.description =
|
|
15
|
-
((
|
|
17
|
+
((_c = detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs) === null || _c === void 0 ? void 0 : _c.map((r) => r.text).join("")) || "";
|
|
16
18
|
target.duration =
|
|
17
|
-
common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((
|
|
19
|
+
common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_d = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _d === void 0 ? void 0 : _d.text.simpleText) ||
|
|
18
20
|
"") || null;
|
|
19
21
|
target.isLive = !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW");
|
|
20
22
|
// Channel
|
|
@@ -43,7 +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 = (_c = data
|
|
46
|
+
var secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
|
|
47
47
|
if (secondaryContents) {
|
|
48
48
|
target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
|
|
49
49
|
target.related.continuation = getContinuationFromItems(secondaryContents);
|
|
@@ -59,11 +59,11 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
59
59
|
return getContinuationFromItems(secondaryContents);
|
|
60
60
|
};
|
|
61
61
|
BaseVideoParser.parseRawData = function (data) {
|
|
62
|
-
var contents = data
|
|
62
|
+
var contents = data.response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
63
63
|
var primaryInfo = contents.find(function (c) { return "videoPrimaryInfoRenderer" in c; })
|
|
64
64
|
.videoPrimaryInfoRenderer;
|
|
65
65
|
var secondaryInfo = contents.find(function (c) { return "videoSecondaryInfoRenderer" in c; }).videoSecondaryInfoRenderer;
|
|
66
|
-
var videoDetails = data
|
|
66
|
+
var videoDetails = data.playerResponse.videoDetails;
|
|
67
67
|
return __assign(__assign(__assign({}, secondaryInfo), primaryInfo), { videoDetails: videoDetails });
|
|
68
68
|
};
|
|
69
69
|
BaseVideoParser.parseCompactRenderer = function (data, client) {
|
|
@@ -136,7 +136,7 @@ var Client = /** @class */ (function () {
|
|
|
136
136
|
Client.prototype.getVideo = function (videoId) {
|
|
137
137
|
var _a;
|
|
138
138
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
var response;
|
|
139
|
+
var response, data;
|
|
140
140
|
return __generator(this, function (_b) {
|
|
141
141
|
switch (_b.label) {
|
|
142
142
|
case 0: return [4 /*yield*/, this.http.get("" + WATCH_END_POINT, {
|
|
@@ -144,13 +144,15 @@ var Client = /** @class */ (function () {
|
|
|
144
144
|
})];
|
|
145
145
|
case 1:
|
|
146
146
|
response = _b.sent();
|
|
147
|
-
|
|
148
|
-
response.data
|
|
147
|
+
data = Array.isArray(response.data)
|
|
148
|
+
? response.data.reduce(function (prev, curr) { return (__assign(__assign({}, prev), curr)); }, {})
|
|
149
|
+
: response.data;
|
|
150
|
+
if (!((_a = data.response) === null || _a === void 0 ? void 0 : _a.contents) || data.playerResponse.playabilityStatus.status === "ERROR") {
|
|
149
151
|
return [2 /*return*/, undefined];
|
|
150
152
|
}
|
|
151
|
-
return [2 /*return*/, (!
|
|
152
|
-
? new Video({ client: this }).load(
|
|
153
|
-
: new LiveVideo({ client: this }).load(
|
|
153
|
+
return [2 /*return*/, (!data.playerResponse.playabilityStatus.liveStreamability
|
|
154
|
+
? new Video({ client: this }).load(data)
|
|
155
|
+
: new LiveVideo({ client: this }).load(data))];
|
|
154
156
|
}
|
|
155
157
|
});
|
|
156
158
|
});
|
|
@@ -9,7 +9,7 @@ var LiveVideoParser = /** @class */ (function () {
|
|
|
9
9
|
.map(function (r) { return r.text; })
|
|
10
10
|
.join(" ")
|
|
11
11
|
.replace(/[^0-9]/g, "");
|
|
12
|
-
target.chatContinuation = (_a = data
|
|
12
|
+
target.chatContinuation = (_a = data.response.contents.twoColumnWatchNextResults.conversationBar.liveChatRenderer) === null || _a === void 0 ? void 0 : _a.continuations[0].reloadContinuationData.continuation;
|
|
13
13
|
return target;
|
|
14
14
|
};
|
|
15
15
|
LiveVideoParser.parseChats = function (data) {
|
|
@@ -8,11 +8,11 @@ var VideoParser = /** @class */ (function () {
|
|
|
8
8
|
var _a, _b, _c;
|
|
9
9
|
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
10
10
|
target.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
11
|
-
var itemSectionRenderer = (_a = data
|
|
11
|
+
var itemSectionRenderer = (_a = data.response.contents.twoColumnWatchNextResults.results.results.contents
|
|
12
12
|
.reverse()
|
|
13
13
|
.find(function (c) { return c.itemSectionRenderer; })) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer;
|
|
14
14
|
target.comments.continuation = getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
|
|
15
|
-
var chapters = (_c = (_b = data
|
|
15
|
+
var chapters = (_c = (_b = data.response.playerOverlays.playerOverlayRenderer.decoratedPlayerBarRenderer) === null || _b === void 0 ? void 0 : _b.decoratedPlayerBarRenderer.playerBar.multiMarkersPlayerBarRenderer.markersMap) === null || _c === void 0 ? void 0 : _c[0].value.chapters;
|
|
16
16
|
target.chapters =
|
|
17
17
|
(chapters === null || chapters === void 0 ? void 0 : chapters.map(function (_a) {
|
|
18
18
|
var c = _a.chapterRenderer;
|
|
@@ -4,16 +4,18 @@ var VideoCompactParser = /** @class */ (function () {
|
|
|
4
4
|
function VideoCompactParser() {
|
|
5
5
|
}
|
|
6
6
|
VideoCompactParser.loadVideoCompact = function (target, data) {
|
|
7
|
-
var _a, _b, _c;
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
8
|
var videoId = data.videoId, title = data.title, headline = data.headline, lengthText = data.lengthText, thumbnail = data.thumbnail, ownerText = data.ownerText, shortBylineText = data.shortBylineText, publishedTimeText = data.publishedTimeText, viewCountText = data.viewCountText, badges = data.badges, thumbnailOverlays = data.thumbnailOverlays, channelThumbnailSupportedRenderers = data.channelThumbnailSupportedRenderers, detailedMetadataSnippets = data.detailedMetadataSnippets;
|
|
9
9
|
target.id = videoId;
|
|
10
|
-
target.title = headline
|
|
10
|
+
target.title = headline
|
|
11
|
+
? headline.simpleText
|
|
12
|
+
: title.simpleText || ((_b = (_a = title.runs) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) || "";
|
|
11
13
|
target.thumbnails = new Thumbnails().load(thumbnail.thumbnails);
|
|
12
14
|
target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
13
15
|
target.description =
|
|
14
|
-
((
|
|
16
|
+
((_c = detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs) === null || _c === void 0 ? void 0 : _c.map(function (r) { return r.text; }).join("")) || "";
|
|
15
17
|
target.duration =
|
|
16
|
-
getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((
|
|
18
|
+
getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_d = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _d === void 0 ? void 0 : _d.text.simpleText) ||
|
|
17
19
|
"") || null;
|
|
18
20
|
target.isLive = !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW");
|
|
19
21
|
// Channel
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
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",
|