youtubei 1.8.1 → 1.8.3

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.
@@ -19,13 +19,33 @@ class BaseVideoParser {
19
19
  target.thumbnails = new common_1.Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
20
20
  // Channel
21
21
  const { title, thumbnail, subscriberCountText } = videoInfo.owner.videoOwnerRenderer;
22
- target.channel = new BaseChannel_1.BaseChannel({
23
- client: target.client,
24
- id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
25
- name: title.runs[0].text,
26
- subscriberCount: subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText,
27
- thumbnails: new common_1.Thumbnails().load(thumbnail.thumbnails),
28
- });
22
+ if (title) {
23
+ target.channel = new BaseChannel_1.BaseChannel({
24
+ client: target.client,
25
+ id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
26
+ name: title.runs[0].text,
27
+ subscriberCount: subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText,
28
+ thumbnails: new common_1.Thumbnails().load(thumbnail.thumbnails),
29
+ });
30
+ }
31
+ if (videoInfo.owner.videoOwnerRenderer.attributedTitle) {
32
+ const channelsData = videoInfo.owner.videoOwnerRenderer.attributedTitle.commandRuns[0].onTap
33
+ .innertubeCommand.showDialogCommand.panelLoadingStrategy.inlineContent
34
+ .dialogViewModel.customContent.listViewModel.listItems;
35
+ const avatarsData = videoInfo.owner.videoOwnerRenderer.avatarStack.avatarStackViewModel.avatars;
36
+ target.channels = channelsData.map((c, i) => {
37
+ const viewModel = c.listItemViewModel;
38
+ const thumbnail = avatarsData[i].avatarViewModel.image.sources;
39
+ return new BaseChannel_1.BaseChannel({
40
+ client: target.client,
41
+ id: viewModel.title.commandRuns[0].onTap.innertubeCommand.browseEndpoint
42
+ .browseId,
43
+ name: viewModel.title.content,
44
+ subscriberCount: viewModel.subtitle.content,
45
+ thumbnails: new common_1.Thumbnails().load(thumbnail),
46
+ });
47
+ });
48
+ }
29
49
  // Like Count and Dislike Count
30
50
  const topLevelButtons = videoInfo.videoActions.menuRenderer.topLevelButtons;
31
51
  target.likeCount = topLevelButtons
@@ -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) {
@@ -29,13 +29,33 @@ var BaseVideoParser = /** @class */ (function () {
29
29
  target.thumbnails = new Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
30
30
  // Channel
31
31
  var _e = videoInfo.owner.videoOwnerRenderer, title = _e.title, thumbnail = _e.thumbnail, subscriberCountText = _e.subscriberCountText;
32
- target.channel = new BaseChannel({
33
- client: target.client,
34
- id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
35
- name: title.runs[0].text,
36
- subscriberCount: subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText,
37
- thumbnails: new Thumbnails().load(thumbnail.thumbnails),
38
- });
32
+ if (title) {
33
+ target.channel = new BaseChannel({
34
+ client: target.client,
35
+ id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
36
+ name: title.runs[0].text,
37
+ subscriberCount: subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText,
38
+ thumbnails: new Thumbnails().load(thumbnail.thumbnails),
39
+ });
40
+ }
41
+ if (videoInfo.owner.videoOwnerRenderer.attributedTitle) {
42
+ var channelsData = videoInfo.owner.videoOwnerRenderer.attributedTitle.commandRuns[0].onTap
43
+ .innertubeCommand.showDialogCommand.panelLoadingStrategy.inlineContent
44
+ .dialogViewModel.customContent.listViewModel.listItems;
45
+ var avatarsData_1 = videoInfo.owner.videoOwnerRenderer.avatarStack.avatarStackViewModel.avatars;
46
+ target.channels = channelsData.map(function (c, i) {
47
+ var viewModel = c.listItemViewModel;
48
+ var thumbnail = avatarsData_1[i].avatarViewModel.image.sources;
49
+ return new BaseChannel({
50
+ client: target.client,
51
+ id: viewModel.title.commandRuns[0].onTap.innertubeCommand.browseEndpoint
52
+ .browseId,
53
+ name: viewModel.title.content,
54
+ subscriberCount: viewModel.subtitle.content,
55
+ thumbnails: new Thumbnails().load(thumbnail),
56
+ });
57
+ });
58
+ }
39
59
  // Like Count and Dislike Count
40
60
  var topLevelButtons = videoInfo.videoActions.menuRenderer.topLevelButtons;
41
61
  target.likeCount = topLevelButtons
@@ -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) {
@@ -11,7 +11,7 @@ export interface BaseVideoProperties extends BaseProperties {
11
11
  title?: string;
12
12
  thumbnails?: Thumbnails;
13
13
  description?: string;
14
- channel?: BaseChannel;
14
+ channel?: BaseChannel | null;
15
15
  uploadDate?: string;
16
16
  viewCount?: number | null;
17
17
  likeCount?: number | null;
@@ -28,7 +28,9 @@ export declare class BaseVideo extends Base implements BaseVideoProperties {
28
28
  /** The description of this video */
29
29
  description: string;
30
30
  /** The channel that uploaded this video */
31
- channel: BaseChannel;
31
+ channel: BaseChannel | null;
32
+ /** The collaborators of this video */
33
+ channels: BaseChannel[] | null;
32
34
  /** The date this video is uploaded at */
33
35
  uploadDate: string;
34
36
  /** How many view does this video have, null if the view count is hidden */
@@ -13,6 +13,12 @@ interface VideoProperties extends BaseVideoProperties {
13
13
  comments?: VideoComments;
14
14
  chapters?: Chapter[];
15
15
  }
16
+ export 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.1",
3
+ "version": "1.8.3",
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",