youtubei 1.8.2 → 1.8.4

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,21 +6,21 @@ 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;
9
+ var _a, _b, _c, _d, _e, _f;
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
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.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
+ const chapters = (_d = (_c = (_b = data.response.playerOverlays.playerOverlayRenderer.decoratedPlayerBarRenderer) === null || _b === void 0 ? void 0 : _b.decoratedPlayerBarRenderer.playerBar) === null || _c === void 0 ? void 0 : _c.multiMarkersPlayerBarRenderer.markersMap) === null || _d === void 0 ? void 0 : _d[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,
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"; }); });
23
+ const musicPanel = (_e = data.response.engagementPanels) === null || _e === void 0 ? void 0 : _e.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
24
  if (!musicPanel) {
25
25
  target.music = null;
26
26
  }
@@ -32,7 +32,7 @@ class VideoParser {
32
32
  imageUrl: music.image.sources[0].url,
33
33
  title: music.title,
34
34
  artist: music.subtitle,
35
- album: ((_e = music.secondarySubtitle) === null || _e === void 0 ? void 0 : _e.content) || null,
35
+ album: ((_f = music.secondarySubtitle) === null || _f === void 0 ? void 0 : _f.content) || null,
36
36
  };
37
37
  }
38
38
  // target.music =
@@ -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,14 +16,14 @@ var VideoParser = /** @class */ (function () {
16
16
  function VideoParser() {
17
17
  }
18
18
  VideoParser.loadVideo = function (target, data) {
19
- var _a, _b, _c, _d, _e;
19
+ var _a, _b, _c, _d, _e, _f;
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
23
23
  .reverse()
24
24
  .find(function (c) { return c.itemSectionRenderer; })) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer;
25
25
  target.comments.continuation = getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
26
- 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;
26
+ var chapters = (_d = (_c = (_b = data.response.playerOverlays.playerOverlayRenderer.decoratedPlayerBarRenderer) === null || _b === void 0 ? void 0 : _b.decoratedPlayerBarRenderer.playerBar) === null || _c === void 0 ? void 0 : _c.multiMarkersPlayerBarRenderer.markersMap) === null || _d === void 0 ? void 0 : _d[0].value.chapters;
27
27
  target.chapters =
28
28
  (chapters === null || chapters === void 0 ? void 0 : chapters.map(function (_a) {
29
29
  var c = _a.chapterRenderer;
@@ -33,7 +33,7 @@ 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"; }); });
36
+ var musicPanel = (_e = data.response.engagementPanels) === null || _e === void 0 ? void 0 : _e.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
37
  if (!musicPanel) {
38
38
  target.music = null;
39
39
  }
@@ -45,7 +45,7 @@ var VideoParser = /** @class */ (function () {
45
45
  imageUrl: music.image.sources[0].url,
46
46
  title: music.title,
47
47
  artist: music.subtitle,
48
- album: ((_e = music.secondarySubtitle) === null || _e === void 0 ? void 0 : _e.content) || null,
48
+ album: ((_f = music.secondarySubtitle) === null || _f === void 0 ? void 0 : _f.content) || null,
49
49
  };
50
50
  }
51
51
  // target.music =
@@ -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,7 +13,7 @@ interface VideoProperties extends BaseVideoProperties {
13
13
  comments?: VideoComments;
14
14
  chapters?: Chapter[];
15
15
  }
16
- interface MusicMetadata {
16
+ export interface MusicMetadata {
17
17
  imageUrl: string;
18
18
  title: string;
19
19
  artist: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
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",