youtubei 1.8.1 → 1.8.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.
|
@@ -6,7 +6,7 @@ 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;
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
10
|
const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
|
|
11
11
|
target.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
12
12
|
const itemSectionRenderer = (_a = data.response.contents.twoColumnWatchNextResults.results.results.contents
|
|
@@ -20,6 +20,22 @@ class VideoParser {
|
|
|
20
20
|
start: c.timeRangeStartMillis,
|
|
21
21
|
thumbnails: new common_1.Thumbnails().load(c.thumbnail.thumbnails),
|
|
22
22
|
}))) || [];
|
|
23
|
+
const musicPanel = (_d = data.response.engagementPanels) === null || _d === void 0 ? void 0 : _d.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
|
+
if (!musicPanel) {
|
|
25
|
+
target.music = null;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const cards = musicPanel.engagementPanelSectionListRenderer.content.structuredDescriptionContentRenderer.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"; }).horizontalCardListRenderer.cards;
|
|
29
|
+
const music = cards.find((i) => i.videoAttributeViewModel)
|
|
30
|
+
.videoAttributeViewModel;
|
|
31
|
+
target.music = {
|
|
32
|
+
imageUrl: music.image.sources[0].url,
|
|
33
|
+
title: music.title,
|
|
34
|
+
artist: music.subtitle,
|
|
35
|
+
album: ((_e = music.secondarySubtitle) === null || _e === void 0 ? void 0 : _e.content) || null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// target.music =
|
|
23
39
|
return target;
|
|
24
40
|
}
|
|
25
41
|
static parseComments(data, video) {
|
|
@@ -16,7 +16,7 @@ var VideoParser = /** @class */ (function () {
|
|
|
16
16
|
function VideoParser() {
|
|
17
17
|
}
|
|
18
18
|
VideoParser.loadVideo = function (target, data) {
|
|
19
|
-
var _a, _b, _c;
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
20
|
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
21
21
|
target.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
22
22
|
var itemSectionRenderer = (_a = data.response.contents.twoColumnWatchNextResults.results.results.contents
|
|
@@ -33,6 +33,22 @@ var VideoParser = /** @class */ (function () {
|
|
|
33
33
|
thumbnails: new Thumbnails().load(c.thumbnail.thumbnails),
|
|
34
34
|
});
|
|
35
35
|
})) || [];
|
|
36
|
+
var musicPanel = (_d = data.response.engagementPanels) === null || _d === void 0 ? void 0 : _d.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
|
+
if (!musicPanel) {
|
|
38
|
+
target.music = null;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
var cards = musicPanel.engagementPanelSectionListRenderer.content.structuredDescriptionContentRenderer.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"; }).horizontalCardListRenderer.cards;
|
|
42
|
+
var music = cards.find(function (i) { return i.videoAttributeViewModel; })
|
|
43
|
+
.videoAttributeViewModel;
|
|
44
|
+
target.music = {
|
|
45
|
+
imageUrl: music.image.sources[0].url,
|
|
46
|
+
title: music.title,
|
|
47
|
+
artist: music.subtitle,
|
|
48
|
+
album: ((_e = music.secondarySubtitle) === null || _e === void 0 ? void 0 : _e.content) || null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// target.music =
|
|
36
52
|
return target;
|
|
37
53
|
};
|
|
38
54
|
VideoParser.parseComments = function (data, video) {
|
|
@@ -13,6 +13,12 @@ interface VideoProperties extends BaseVideoProperties {
|
|
|
13
13
|
comments?: VideoComments;
|
|
14
14
|
chapters?: Chapter[];
|
|
15
15
|
}
|
|
16
|
+
interface MusicMetadata {
|
|
17
|
+
imageUrl: string;
|
|
18
|
+
title: string;
|
|
19
|
+
artist: string;
|
|
20
|
+
album?: string;
|
|
21
|
+
}
|
|
16
22
|
/** Represents a Video, usually returned from `client.getVideo()` */
|
|
17
23
|
export declare class Video extends BaseVideo implements VideoProperties {
|
|
18
24
|
/** The duration of this video in second */
|
|
@@ -21,6 +27,8 @@ export declare class Video extends BaseVideo implements VideoProperties {
|
|
|
21
27
|
chapters: Chapter[];
|
|
22
28
|
/** {@link Continuable} of videos inside a {@link Video} */
|
|
23
29
|
comments: VideoComments;
|
|
30
|
+
/** Music metadata (if exists) */
|
|
31
|
+
music: MusicMetadata | null;
|
|
24
32
|
/** @hidden */
|
|
25
33
|
constructor(attr: VideoProperties);
|
|
26
34
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.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",
|