youtubei 1.3.2 → 1.3.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.
@@ -16,7 +16,7 @@ class MusicSearchResultParser {
16
16
  const { contents, continuations } = contentSection.musicShelfRenderer;
17
17
  return {
18
18
  data: MusicSearchResultParser.parseSearchResult(contents, type, client),
19
- continuation: (_b = (_a = continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
19
+ continuation: (_b = (_a = continuations === null || continuations === void 0 ? void 0 : continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
20
20
  };
21
21
  }
22
22
  static parseContinuationSearchResult(data, type, client) {
@@ -7,7 +7,7 @@ const PlaylistCompact_1 = require("../PlaylistCompact");
7
7
  const VideoCompact_1 = require("../VideoCompact");
8
8
  class BaseVideoParser {
9
9
  static loadBaseVideo(target, data) {
10
- var _a, _b;
10
+ var _a, _b, _c;
11
11
  const videoInfo = BaseVideoParser.parseRawData(data);
12
12
  // Basic information
13
13
  target.id = videoInfo.videoDetails.videoId;
@@ -33,8 +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 = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
37
- .results;
36
+ const secondaryContents = (_c = data[3].response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
38
37
  if (secondaryContents) {
39
38
  target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
40
39
  target.related.continuation = common_1.getContinuationFromItems(secondaryContents);
@@ -71,17 +70,24 @@ class BaseVideoParser {
71
70
  .filter((c) => c !== undefined);
72
71
  }
73
72
  static parseButtonRenderer(data) {
74
- var _a;
75
- let buttonRenderer;
76
- if (!data.segmentedLikeDislikeButtonRenderer) {
77
- buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
73
+ var _a, _b;
74
+ let likeCount;
75
+ if (data.toggleButtonRenderer || data.buttonRenderer) {
76
+ const buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
77
+ likeCount = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
78
78
  }
79
- else {
79
+ else if (data.segmentedLikeDislikeButtonRenderer) {
80
80
  const likeButton = data.segmentedLikeDislikeButtonRenderer.likeButton;
81
- buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
81
+ const buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
82
+ likeCount = (((_b = buttonRenderer.defaultText) === null || _b === void 0 ? void 0 : _b.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
83
+ }
84
+ else if (data.segmentedLikeDislikeButtonViewModel) {
85
+ likeCount =
86
+ data.segmentedLikeDislikeButtonViewModel.likeButtonViewModel.likeButtonViewModel
87
+ .toggleButtonViewModel.toggleButtonViewModel.defaultButtonViewModel
88
+ .buttonViewModel.accessibilityText;
82
89
  }
83
- const accessibilityData = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
84
- return accessibilityData.label;
90
+ return likeCount;
85
91
  }
86
92
  }
87
93
  exports.BaseVideoParser = BaseVideoParser;
@@ -26,7 +26,7 @@ var MusicSearchResultParser = /** @class */ (function () {
26
26
  var _c = contentSection.musicShelfRenderer, contents = _c.contents, continuations = _c.continuations;
27
27
  return {
28
28
  data: MusicSearchResultParser.parseSearchResult(contents, type, client),
29
- continuation: (_b = (_a = continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
29
+ continuation: (_b = (_a = continuations === null || continuations === void 0 ? void 0 : continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
30
30
  };
31
31
  };
32
32
  MusicSearchResultParser.parseContinuationSearchResult = function (data, type, client) {
@@ -17,7 +17,7 @@ var BaseVideoParser = /** @class */ (function () {
17
17
  function BaseVideoParser() {
18
18
  }
19
19
  BaseVideoParser.loadBaseVideo = function (target, data) {
20
- var _a, _b;
20
+ var _a, _b, _c;
21
21
  var videoInfo = BaseVideoParser.parseRawData(data);
22
22
  // Basic information
23
23
  target.id = videoInfo.videoDetails.videoId;
@@ -27,7 +27,7 @@ var BaseVideoParser = /** @class */ (function () {
27
27
  target.isLiveContent = videoInfo.videoDetails.isLiveContent;
28
28
  target.thumbnails = new Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
29
29
  // Channel
30
- var _c = videoInfo.owner.videoOwnerRenderer, title = _c.title, thumbnail = _c.thumbnail, subscriberCountText = _c.subscriberCountText;
30
+ var _d = videoInfo.owner.videoOwnerRenderer, title = _d.title, thumbnail = _d.thumbnail, subscriberCountText = _d.subscriberCountText;
31
31
  target.channel = new BaseChannel({
32
32
  client: target.client,
33
33
  id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
@@ -43,8 +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 = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
47
- .results;
46
+ var secondaryContents = (_c = data[3].response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
48
47
  if (secondaryContents) {
49
48
  target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
50
49
  target.related.continuation = getContinuationFromItems(secondaryContents);
@@ -81,17 +80,24 @@ var BaseVideoParser = /** @class */ (function () {
81
80
  .filter(function (c) { return c !== undefined; });
82
81
  };
83
82
  BaseVideoParser.parseButtonRenderer = function (data) {
84
- var _a;
85
- var buttonRenderer;
86
- if (!data.segmentedLikeDislikeButtonRenderer) {
87
- buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
83
+ var _a, _b;
84
+ var likeCount;
85
+ if (data.toggleButtonRenderer || data.buttonRenderer) {
86
+ var buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
87
+ likeCount = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
88
88
  }
89
- else {
89
+ else if (data.segmentedLikeDislikeButtonRenderer) {
90
90
  var likeButton = data.segmentedLikeDislikeButtonRenderer.likeButton;
91
- buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
91
+ var buttonRenderer = likeButton.toggleButtonRenderer || likeButton.buttonRenderer;
92
+ likeCount = (((_b = buttonRenderer.defaultText) === null || _b === void 0 ? void 0 : _b.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
93
+ }
94
+ else if (data.segmentedLikeDislikeButtonViewModel) {
95
+ likeCount =
96
+ data.segmentedLikeDislikeButtonViewModel.likeButtonViewModel.likeButtonViewModel
97
+ .toggleButtonViewModel.toggleButtonViewModel.defaultButtonViewModel
98
+ .buttonViewModel.accessibilityText;
92
99
  }
93
- var accessibilityData = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
94
- return accessibilityData.label;
100
+ return likeCount;
95
101
  };
96
102
  return BaseVideoParser;
97
103
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.3.2",
3
+ "version": "1.3.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",