youtubei 1.8.5 → 1.8.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/common/shared/HTTP/HTTP.js +5 -0
- package/dist/cjs/common/utils/helper.js +21 -1
- package/dist/cjs/youtube/BaseChannel/ChannelShorts.js +12 -2
- package/dist/cjs/youtube/BaseVideo/BaseVideoParser.js +19 -13
- package/dist/cjs/youtube/Video/VideoParser.js +11 -7
- package/dist/esm/common/shared/HTTP/HTTP.js +8 -0
- package/dist/esm/common/utils/helper.js +19 -0
- package/dist/esm/youtube/BaseChannel/ChannelShorts.js +11 -3
- package/dist/esm/youtube/BaseVideo/BaseVideoParser.js +21 -15
- package/dist/esm/youtube/Video/VideoParser.js +11 -7
- package/dist/typings/common/shared/HTTP/HTTP.d.ts +2 -0
- package/dist/typings/common/utils/helper.d.ts +2 -0
- package/dist/typings/youtube/BaseVideo/BaseVideo.d.ts +6 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.HTTP = void 0;
|
|
16
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
16
17
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
17
18
|
const url_1 = require("url");
|
|
18
19
|
const OAuth_1 = require("./OAuth");
|
|
@@ -37,6 +38,7 @@ class HTTP {
|
|
|
37
38
|
this.authorizationPromise = null;
|
|
38
39
|
this.defaultFetchOptions = options.fetchOptions || {};
|
|
39
40
|
this.defaultClientOptions = options.youtubeClientOptions || {};
|
|
41
|
+
this.rawResponseLogPath = options.rawResponseLogPath;
|
|
40
42
|
}
|
|
41
43
|
get(path, options) {
|
|
42
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -79,6 +81,9 @@ class HTTP {
|
|
|
79
81
|
}
|
|
80
82
|
const response = yield node_fetch_1.default(urlString, options);
|
|
81
83
|
const data = yield response.json();
|
|
84
|
+
if (this.rawResponseLogPath) {
|
|
85
|
+
yield promises_1.default.appendFile(this.rawResponseLogPath, JSON.stringify({ url: urlString, response: data }) + "\n");
|
|
86
|
+
}
|
|
82
87
|
this.parseCookie(response);
|
|
83
88
|
return { data };
|
|
84
89
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapFilter = exports.getContinuationFromItems = exports.stripToInt = exports.getDuration = void 0;
|
|
3
|
+
exports.getThumbnailFromId = exports.mapFilter = exports.getContinuationFromItems = exports.stripToInt = exports.getDuration = void 0;
|
|
4
4
|
const getDuration = (s) => {
|
|
5
5
|
s = s.replace(/:/g, ".");
|
|
6
6
|
const spl = s.split(".");
|
|
@@ -47,3 +47,23 @@ const mapFilter = (items, key) => {
|
|
|
47
47
|
.map((item) => item[key]);
|
|
48
48
|
};
|
|
49
49
|
exports.mapFilter = mapFilter;
|
|
50
|
+
const getThumbnailFromId = (id) => {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
url: `https://i.ytimg.com/vi/${id}/default.jpg`,
|
|
54
|
+
width: 120,
|
|
55
|
+
height: 90,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
url: `https://i.ytimg.com/vi/${id}/mqdefault.jpg`,
|
|
59
|
+
width: 320,
|
|
60
|
+
height: 180,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
url: `https://i.ytimg.com/vi/${id}/hqdefault.jpg`,
|
|
64
|
+
width: 480,
|
|
65
|
+
height: 360,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
};
|
|
69
|
+
exports.getThumbnailFromId = getThumbnailFromId;
|
|
@@ -46,10 +46,20 @@ class ChannelShorts extends Continuable_1.Continuable {
|
|
|
46
46
|
});
|
|
47
47
|
const items = BaseChannelParser_1.BaseChannelParser.parseTabData("shorts", response.data);
|
|
48
48
|
const continuation = common_1.getContinuationFromItems(items);
|
|
49
|
-
const data =
|
|
49
|
+
const data = items.filter((i) => "reelItemRenderer" in i || "shortsLockupViewModel" in i);
|
|
50
50
|
return {
|
|
51
51
|
continuation,
|
|
52
|
-
items: data.map((i) =>
|
|
52
|
+
items: data.map((i) => {
|
|
53
|
+
const video = new VideoCompact_1.VideoCompact({
|
|
54
|
+
client: this.client,
|
|
55
|
+
channel: this.channel,
|
|
56
|
+
});
|
|
57
|
+
if (i.reelItemRenderer)
|
|
58
|
+
video.load(i.reelItemRenderer);
|
|
59
|
+
else if (i.shortsLockupViewModel)
|
|
60
|
+
video.loadLockup(i.lockupViewModel);
|
|
61
|
+
return video;
|
|
62
|
+
}),
|
|
53
63
|
};
|
|
54
64
|
});
|
|
55
65
|
}
|
|
@@ -8,15 +8,19 @@ const VideoCompact_1 = require("../VideoCompact");
|
|
|
8
8
|
const VideoCaptions_1 = require("./VideoCaptions");
|
|
9
9
|
class BaseVideoParser {
|
|
10
10
|
static loadBaseVideo(target, data) {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12
12
|
const videoInfo = BaseVideoParser.parseRawData(data);
|
|
13
13
|
// Basic information
|
|
14
|
-
target.id = videoInfo.
|
|
15
|
-
target.title =
|
|
14
|
+
target.id = videoInfo.currentVideoEndpoint.watchEndpoint.videoId;
|
|
15
|
+
target.title =
|
|
16
|
+
videoInfo.playerOverlays.playerOverlayRenderer.videoDetails.playerOverlayVideoDetailsRenderer.title.simpleText;
|
|
17
|
+
target.viewCount =
|
|
18
|
+
common_1.stripToInt(videoInfo.viewCount.videoViewCountRenderer.viewCount.simpleText) || null;
|
|
19
|
+
target.isLiveContent = !!((_a = videoInfo.videoDetails) === null || _a === void 0 ? void 0 : _a.isLiveContent); // TODO remove dependence on player data
|
|
16
20
|
target.uploadDate = videoInfo.dateText.simpleText;
|
|
17
|
-
target.
|
|
18
|
-
target.
|
|
19
|
-
target.thumbnails = new common_1.Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
21
|
+
target.formats = ((_b = videoInfo.streamingData) === null || _b === void 0 ? void 0 : _b.formats) || [];
|
|
22
|
+
target.adaptiveFormats = ((_c = videoInfo.streamingData) === null || _c === void 0 ? void 0 : _c.adaptiveFormats) || [];
|
|
23
|
+
target.thumbnails = new common_1.Thumbnails().load(((_d = videoInfo.videoDetails) === null || _d === void 0 ? void 0 : _d.thumbnail.thumbnails) || common_1.getThumbnailFromId(target.id));
|
|
20
24
|
// Channel
|
|
21
25
|
const { title, thumbnail, subscriberCountText } = videoInfo.owner.videoOwnerRenderer;
|
|
22
26
|
if (title) {
|
|
@@ -53,13 +57,13 @@ class BaseVideoParser {
|
|
|
53
57
|
: null;
|
|
54
58
|
// Tags and description
|
|
55
59
|
target.tags =
|
|
56
|
-
((
|
|
57
|
-
target.description = videoInfo.
|
|
60
|
+
((_f = (_e = videoInfo.superTitleLink) === null || _e === void 0 ? void 0 : _e.runs) === null || _f === void 0 ? void 0 : _f.map((r) => r.text.trim()).filter((t) => t)) || [];
|
|
61
|
+
target.description = videoInfo.attributedDescription.content || ""; // TODO
|
|
58
62
|
// related videos
|
|
59
|
-
let secondaryContents = (
|
|
60
|
-
const itemSectionRenderer = (
|
|
63
|
+
let secondaryContents = (_g = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _g === void 0 ? void 0 : _g.secondaryResults.results;
|
|
64
|
+
const itemSectionRenderer = (_h = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find((c) => {
|
|
61
65
|
return c.itemSectionRenderer;
|
|
62
|
-
})) === null ||
|
|
66
|
+
})) === null || _h === void 0 ? void 0 : _h.itemSectionRenderer;
|
|
63
67
|
if (itemSectionRenderer)
|
|
64
68
|
secondaryContents = itemSectionRenderer.contents;
|
|
65
69
|
if (secondaryContents) {
|
|
@@ -85,8 +89,10 @@ class BaseVideoParser {
|
|
|
85
89
|
const primaryInfo = contents.find((c) => "videoPrimaryInfoRenderer" in c)
|
|
86
90
|
.videoPrimaryInfoRenderer;
|
|
87
91
|
const secondaryInfo = contents.find((c) => "videoSecondaryInfoRenderer" in c).videoSecondaryInfoRenderer;
|
|
88
|
-
const { videoDetails, captions } = data.playerResponse;
|
|
89
|
-
return Object.assign(Object.assign(Object.assign({}, secondaryInfo), primaryInfo), { videoDetails,
|
|
92
|
+
const { videoDetails, captions, streamingData } = data.playerResponse;
|
|
93
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, data.response), secondaryInfo), primaryInfo), { videoDetails,
|
|
94
|
+
captions,
|
|
95
|
+
streamingData });
|
|
90
96
|
}
|
|
91
97
|
static parseCompactRenderer(data, client) {
|
|
92
98
|
if ("compactVideoRenderer" in data) {
|
|
@@ -6,21 +6,25 @@ const BaseVideo_1 = require("../BaseVideo");
|
|
|
6
6
|
const Comment_1 = require("../Comment");
|
|
7
7
|
class VideoParser {
|
|
8
8
|
static loadVideo(target, data) {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10
10
|
const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
const mutations = videoInfo.frameworkUpdates.entityBatchUpdate.mutations;
|
|
12
|
+
const lastMarkers = (_a = mutations.find((m) => { var _a; return (_a = m.payload) === null || _a === void 0 ? void 0 : _a.macroMarkersListEntity; })) === null || _a === void 0 ? void 0 : _a.payload.macroMarkersListEntity.markersList.markers;
|
|
13
|
+
target.duration =
|
|
14
|
+
+((_b = videoInfo.videoDetails) === null || _b === void 0 ? void 0 : _b.lengthSeconds) ||
|
|
15
|
+
(lastMarkers ? (+lastMarkers.startMillis + +lastMarkers.durationMillis) / 1000 : 0);
|
|
16
|
+
const itemSectionRenderer = (_c = data.response.contents.twoColumnWatchNextResults.results.results.contents
|
|
13
17
|
.reverse()
|
|
14
|
-
.find((c) => c.itemSectionRenderer)) === null ||
|
|
18
|
+
.find((c) => c.itemSectionRenderer)) === null || _c === void 0 ? void 0 : _c.itemSectionRenderer;
|
|
15
19
|
target.comments.continuation = common_1.getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
|
|
16
|
-
const chapters = (
|
|
20
|
+
const chapters = (_f = (_e = (_d = data.response.playerOverlays.playerOverlayRenderer.decoratedPlayerBarRenderer) === null || _d === void 0 ? void 0 : _d.decoratedPlayerBarRenderer.playerBar) === null || _e === void 0 ? void 0 : _e.multiMarkersPlayerBarRenderer.markersMap) === null || _f === void 0 ? void 0 : _f[0].value.chapters;
|
|
17
21
|
target.chapters =
|
|
18
22
|
(chapters === null || chapters === void 0 ? void 0 : chapters.map(({ chapterRenderer: c }) => ({
|
|
19
23
|
title: c.title.simpleText,
|
|
20
24
|
start: c.timeRangeStartMillis,
|
|
21
25
|
thumbnails: new common_1.Thumbnails().load(c.thumbnail.thumbnails),
|
|
22
26
|
}))) || [];
|
|
23
|
-
const musicPanel = (
|
|
27
|
+
const musicPanel = (_g = data.response.engagementPanels) === null || _g === void 0 ? void 0 : _g.find((e) => { var _a, _b; return (_b = (_a = e.engagementPanelSectionListRenderer.content) === null || _a === void 0 ? void 0 : _a.structuredDescriptionContentRenderer) === null || _b === void 0 ? void 0 : _b.items.find((i) => { var _a, _b; return ((_b = (_a = i.horizontalCardListRenderer) === null || _a === void 0 ? void 0 : _a.footerButton) === null || _b === void 0 ? void 0 : _b.buttonViewModel.iconName) === "MUSIC"; }); });
|
|
24
28
|
if (!musicPanel) {
|
|
25
29
|
target.music = null;
|
|
26
30
|
}
|
|
@@ -32,7 +36,7 @@ class VideoParser {
|
|
|
32
36
|
imageUrl: music.image.sources[0].url,
|
|
33
37
|
title: music.title,
|
|
34
38
|
artist: music.subtitle,
|
|
35
|
-
album: ((
|
|
39
|
+
album: ((_h = music.secondarySubtitle) === null || _h === void 0 ? void 0 : _h.content) || null,
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
// target.music =
|
|
@@ -72,6 +72,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
72
72
|
}
|
|
73
73
|
return ar;
|
|
74
74
|
};
|
|
75
|
+
import fs from "fs/promises";
|
|
75
76
|
import fetch from "node-fetch";
|
|
76
77
|
import { URLSearchParams } from "url";
|
|
77
78
|
import { OAuth } from "./OAuth";
|
|
@@ -96,6 +97,7 @@ var HTTP = /** @class */ (function () {
|
|
|
96
97
|
this.authorizationPromise = null;
|
|
97
98
|
this.defaultFetchOptions = options.fetchOptions || {};
|
|
98
99
|
this.defaultClientOptions = options.youtubeClientOptions || {};
|
|
100
|
+
this.rawResponseLogPath = options.rawResponseLogPath;
|
|
99
101
|
}
|
|
100
102
|
HTTP.prototype.get = function (path, options) {
|
|
101
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -172,6 +174,12 @@ var HTTP = /** @class */ (function () {
|
|
|
172
174
|
return [4 /*yield*/, response.json()];
|
|
173
175
|
case 6:
|
|
174
176
|
data = _e.sent();
|
|
177
|
+
if (!this.rawResponseLogPath) return [3 /*break*/, 8];
|
|
178
|
+
return [4 /*yield*/, fs.appendFile(this.rawResponseLogPath, JSON.stringify({ url: urlString, response: data }) + "\n")];
|
|
179
|
+
case 7:
|
|
180
|
+
_e.sent();
|
|
181
|
+
_e.label = 8;
|
|
182
|
+
case 8:
|
|
175
183
|
this.parseCookie(response);
|
|
176
184
|
return [2 /*return*/, { data: data }];
|
|
177
185
|
}
|
|
@@ -63,3 +63,22 @@ export var mapFilter = function (items, key) {
|
|
|
63
63
|
.filter(function (item) { return item[key]; })
|
|
64
64
|
.map(function (item) { return item[key]; });
|
|
65
65
|
};
|
|
66
|
+
export var getThumbnailFromId = function (id) {
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
url: "https://i.ytimg.com/vi/" + id + "/default.jpg",
|
|
70
|
+
width: 120,
|
|
71
|
+
height: 90,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
url: "https://i.ytimg.com/vi/" + id + "/mqdefault.jpg",
|
|
75
|
+
width: 320,
|
|
76
|
+
height: 180,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
url: "https://i.ytimg.com/vi/" + id + "/hqdefault.jpg",
|
|
80
|
+
width: 480,
|
|
81
|
+
height: 360,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
};
|
|
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
import { getContinuationFromItems
|
|
50
|
+
import { getContinuationFromItems } from "../../common";
|
|
51
51
|
import { Continuable } from "../Continuable";
|
|
52
52
|
import { VideoCompact } from "../VideoCompact";
|
|
53
53
|
import { I_END_POINT } from "../constants";
|
|
@@ -93,11 +93,19 @@ var ChannelShorts = /** @class */ (function (_super) {
|
|
|
93
93
|
response = _b.sent();
|
|
94
94
|
items = BaseChannelParser.parseTabData("shorts", response.data);
|
|
95
95
|
continuation = getContinuationFromItems(items);
|
|
96
|
-
data =
|
|
96
|
+
data = items.filter(function (i) { return "reelItemRenderer" in i || "shortsLockupViewModel" in i; });
|
|
97
97
|
return [2 /*return*/, {
|
|
98
98
|
continuation: continuation,
|
|
99
99
|
items: data.map(function (i) {
|
|
100
|
-
|
|
100
|
+
var video = new VideoCompact({
|
|
101
|
+
client: _this.client,
|
|
102
|
+
channel: _this.channel,
|
|
103
|
+
});
|
|
104
|
+
if (i.reelItemRenderer)
|
|
105
|
+
video.load(i.reelItemRenderer);
|
|
106
|
+
else if (i.shortsLockupViewModel)
|
|
107
|
+
video.loadLockup(i.lockupViewModel);
|
|
108
|
+
return video;
|
|
101
109
|
}),
|
|
102
110
|
}];
|
|
103
111
|
}
|
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { getContinuationFromItems, stripToInt, Thumbnails } from "../../common";
|
|
12
|
+
import { getContinuationFromItems, getThumbnailFromId, stripToInt, Thumbnails, } from "../../common";
|
|
13
13
|
import { BaseChannel } from "../BaseChannel";
|
|
14
14
|
import { PlaylistCompact } from "../PlaylistCompact";
|
|
15
15
|
import { VideoCompact } from "../VideoCompact";
|
|
@@ -18,17 +18,21 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
18
18
|
function BaseVideoParser() {
|
|
19
19
|
}
|
|
20
20
|
BaseVideoParser.loadBaseVideo = function (target, data) {
|
|
21
|
-
var _a, _b, _c, _d;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
22
22
|
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
23
23
|
// Basic information
|
|
24
|
-
target.id = videoInfo.
|
|
25
|
-
target.title =
|
|
24
|
+
target.id = videoInfo.currentVideoEndpoint.watchEndpoint.videoId;
|
|
25
|
+
target.title =
|
|
26
|
+
videoInfo.playerOverlays.playerOverlayRenderer.videoDetails.playerOverlayVideoDetailsRenderer.title.simpleText;
|
|
27
|
+
target.viewCount =
|
|
28
|
+
stripToInt(videoInfo.viewCount.videoViewCountRenderer.viewCount.simpleText) || null;
|
|
29
|
+
target.isLiveContent = !!((_a = videoInfo.videoDetails) === null || _a === void 0 ? void 0 : _a.isLiveContent); // TODO remove dependence on player data
|
|
26
30
|
target.uploadDate = videoInfo.dateText.simpleText;
|
|
27
|
-
target.
|
|
28
|
-
target.
|
|
29
|
-
target.thumbnails = new Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
31
|
+
target.formats = ((_b = videoInfo.streamingData) === null || _b === void 0 ? void 0 : _b.formats) || [];
|
|
32
|
+
target.adaptiveFormats = ((_c = videoInfo.streamingData) === null || _c === void 0 ? void 0 : _c.adaptiveFormats) || [];
|
|
33
|
+
target.thumbnails = new Thumbnails().load(((_d = videoInfo.videoDetails) === null || _d === void 0 ? void 0 : _d.thumbnail.thumbnails) || getThumbnailFromId(target.id));
|
|
30
34
|
// Channel
|
|
31
|
-
var
|
|
35
|
+
var _j = videoInfo.owner.videoOwnerRenderer, title = _j.title, thumbnail = _j.thumbnail, subscriberCountText = _j.subscriberCountText;
|
|
32
36
|
if (title) {
|
|
33
37
|
target.channel = new BaseChannel({
|
|
34
38
|
client: target.client,
|
|
@@ -63,13 +67,13 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
63
67
|
: null;
|
|
64
68
|
// Tags and description
|
|
65
69
|
target.tags =
|
|
66
|
-
((
|
|
67
|
-
target.description = videoInfo.
|
|
70
|
+
((_f = (_e = videoInfo.superTitleLink) === null || _e === void 0 ? void 0 : _e.runs) === null || _f === void 0 ? void 0 : _f.map(function (r) { return r.text.trim(); }).filter(function (t) { return t; })) || [];
|
|
71
|
+
target.description = videoInfo.attributedDescription.content || ""; // TODO
|
|
68
72
|
// related videos
|
|
69
|
-
var secondaryContents = (
|
|
70
|
-
var itemSectionRenderer = (
|
|
73
|
+
var secondaryContents = (_g = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _g === void 0 ? void 0 : _g.secondaryResults.results;
|
|
74
|
+
var itemSectionRenderer = (_h = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find(function (c) {
|
|
71
75
|
return c.itemSectionRenderer;
|
|
72
|
-
})) === null ||
|
|
76
|
+
})) === null || _h === void 0 ? void 0 : _h.itemSectionRenderer;
|
|
73
77
|
if (itemSectionRenderer)
|
|
74
78
|
secondaryContents = itemSectionRenderer.contents;
|
|
75
79
|
if (secondaryContents) {
|
|
@@ -95,8 +99,10 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
95
99
|
var primaryInfo = contents.find(function (c) { return "videoPrimaryInfoRenderer" in c; })
|
|
96
100
|
.videoPrimaryInfoRenderer;
|
|
97
101
|
var secondaryInfo = contents.find(function (c) { return "videoSecondaryInfoRenderer" in c; }).videoSecondaryInfoRenderer;
|
|
98
|
-
var _a = data.playerResponse, videoDetails = _a.videoDetails, captions = _a.captions;
|
|
99
|
-
return __assign(__assign(__assign({}, secondaryInfo), primaryInfo), { videoDetails: videoDetails,
|
|
102
|
+
var _a = data.playerResponse, videoDetails = _a.videoDetails, captions = _a.captions, streamingData = _a.streamingData;
|
|
103
|
+
return __assign(__assign(__assign(__assign({}, data.response), secondaryInfo), primaryInfo), { videoDetails: videoDetails,
|
|
104
|
+
captions: captions,
|
|
105
|
+
streamingData: streamingData });
|
|
100
106
|
};
|
|
101
107
|
BaseVideoParser.parseCompactRenderer = function (data, client) {
|
|
102
108
|
if ("compactVideoRenderer" in data) {
|
|
@@ -16,14 +16,18 @@ var VideoParser = /** @class */ (function () {
|
|
|
16
16
|
function VideoParser() {
|
|
17
17
|
}
|
|
18
18
|
VideoParser.loadVideo = function (target, data) {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
20
20
|
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
21
|
-
|
|
22
|
-
var
|
|
21
|
+
var mutations = videoInfo.frameworkUpdates.entityBatchUpdate.mutations;
|
|
22
|
+
var lastMarkers = (_a = mutations.find(function (m) { var _a; return (_a = m.payload) === null || _a === void 0 ? void 0 : _a.macroMarkersListEntity; })) === null || _a === void 0 ? void 0 : _a.payload.macroMarkersListEntity.markersList.markers;
|
|
23
|
+
target.duration =
|
|
24
|
+
+((_b = videoInfo.videoDetails) === null || _b === void 0 ? void 0 : _b.lengthSeconds) ||
|
|
25
|
+
(lastMarkers ? (+lastMarkers.startMillis + +lastMarkers.durationMillis) / 1000 : 0);
|
|
26
|
+
var itemSectionRenderer = (_c = data.response.contents.twoColumnWatchNextResults.results.results.contents
|
|
23
27
|
.reverse()
|
|
24
|
-
.find(function (c) { return c.itemSectionRenderer; })) === null ||
|
|
28
|
+
.find(function (c) { return c.itemSectionRenderer; })) === null || _c === void 0 ? void 0 : _c.itemSectionRenderer;
|
|
25
29
|
target.comments.continuation = getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
|
|
26
|
-
var chapters = (
|
|
30
|
+
var chapters = (_f = (_e = (_d = data.response.playerOverlays.playerOverlayRenderer.decoratedPlayerBarRenderer) === null || _d === void 0 ? void 0 : _d.decoratedPlayerBarRenderer.playerBar) === null || _e === void 0 ? void 0 : _e.multiMarkersPlayerBarRenderer.markersMap) === null || _f === void 0 ? void 0 : _f[0].value.chapters;
|
|
27
31
|
target.chapters =
|
|
28
32
|
(chapters === null || chapters === void 0 ? void 0 : chapters.map(function (_a) {
|
|
29
33
|
var c = _a.chapterRenderer;
|
|
@@ -33,7 +37,7 @@ var VideoParser = /** @class */ (function () {
|
|
|
33
37
|
thumbnails: new Thumbnails().load(c.thumbnail.thumbnails),
|
|
34
38
|
});
|
|
35
39
|
})) || [];
|
|
36
|
-
var musicPanel = (
|
|
40
|
+
var musicPanel = (_g = data.response.engagementPanels) === null || _g === void 0 ? void 0 : _g.find(function (e) { var _a, _b; return (_b = (_a = e.engagementPanelSectionListRenderer.content) === null || _a === void 0 ? void 0 : _a.structuredDescriptionContentRenderer) === null || _b === void 0 ? void 0 : _b.items.find(function (i) { var _a, _b; return ((_b = (_a = i.horizontalCardListRenderer) === null || _a === void 0 ? void 0 : _a.footerButton) === null || _b === void 0 ? void 0 : _b.buttonViewModel.iconName) === "MUSIC"; }); });
|
|
37
41
|
if (!musicPanel) {
|
|
38
42
|
target.music = null;
|
|
39
43
|
}
|
|
@@ -45,7 +49,7 @@ var VideoParser = /** @class */ (function () {
|
|
|
45
49
|
imageUrl: music.image.sources[0].url,
|
|
46
50
|
title: music.title,
|
|
47
51
|
artist: music.subtitle,
|
|
48
|
-
album: ((
|
|
52
|
+
album: ((_h = music.secondarySubtitle) === null || _h === void 0 ? void 0 : _h.content) || null,
|
|
49
53
|
};
|
|
50
54
|
}
|
|
51
55
|
// target.music =
|
|
@@ -22,6 +22,7 @@ export declare type HTTPOptions = {
|
|
|
22
22
|
initialCookie?: string;
|
|
23
23
|
oauth?: OAuthOptions;
|
|
24
24
|
pot?: PotOptions;
|
|
25
|
+
rawResponseLogPath?: string;
|
|
25
26
|
};
|
|
26
27
|
declare type Response<T = any> = {
|
|
27
28
|
data: T;
|
|
@@ -45,6 +46,7 @@ export declare class HTTP {
|
|
|
45
46
|
private authorizationPromise;
|
|
46
47
|
private pot?;
|
|
47
48
|
oauth: OAuthOptions & OAuthProps;
|
|
49
|
+
private rawResponseLogPath?;
|
|
48
50
|
constructor(options: HTTPOptions);
|
|
49
51
|
get(path: string, options?: Partial<Options>): Promise<Response>;
|
|
50
52
|
post(path: string, options?: Partial<Options>): Promise<Response>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Thumbnail } from "../shared";
|
|
1
2
|
import { YoutubeRawData } from "./types";
|
|
2
3
|
export declare const getDuration: (s: string) => number;
|
|
3
4
|
export declare const stripToInt: (string: string) => number | null;
|
|
4
5
|
export declare const getContinuationFromItems: (items: YoutubeRawData, accessors?: string[]) => string | undefined;
|
|
5
6
|
export declare const mapFilter: (items: YoutubeRawData, key: string) => YoutubeRawData;
|
|
7
|
+
export declare const getThumbnailFromId: (id: string) => Thumbnail[];
|
|
@@ -17,6 +17,8 @@ export interface BaseVideoProperties extends BaseProperties {
|
|
|
17
17
|
likeCount?: number | null;
|
|
18
18
|
isLiveContent?: boolean;
|
|
19
19
|
tags?: string[];
|
|
20
|
+
formats?: YoutubeRawData[];
|
|
21
|
+
adaptiveFormats?: YoutubeRawData[];
|
|
20
22
|
}
|
|
21
23
|
/** Represents a Video */
|
|
22
24
|
export declare class BaseVideo extends Base implements BaseVideoProperties {
|
|
@@ -40,6 +42,10 @@ export declare class BaseVideo extends Base implements BaseVideoProperties {
|
|
|
40
42
|
/** Whether this video is a live content or not */
|
|
41
43
|
isLiveContent: boolean;
|
|
42
44
|
/** The tags of this video */
|
|
45
|
+
/** The formats of the video */
|
|
46
|
+
formats: YoutubeRawData[];
|
|
47
|
+
/** The adaptive formats of the video */
|
|
48
|
+
adaptiveFormats: YoutubeRawData[];
|
|
43
49
|
tags: string[];
|
|
44
50
|
/** Continuable of videos / playlists related to this video */
|
|
45
51
|
related: VideoRelated;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.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",
|