youtubei 1.6.1 → 1.6.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.
@@ -34,7 +34,7 @@ class BaseVideoParser {
34
34
  ((_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)) || [];
35
35
  target.description = videoInfo.videoDetails.shortDescription || "";
36
36
  // related videos
37
- const secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results.find((s) => s.itemSectionRenderer).itemSectionRenderer.contents;
37
+ const secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
38
38
  if (secondaryContents) {
39
39
  target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
40
40
  target.related.continuation = common_1.getContinuationFromItems(secondaryContents);
@@ -26,7 +26,7 @@ class ChannelParser {
26
26
  .browseEndpoint.browseId;
27
27
  title = pageHeaderRenderer.pageTitle;
28
28
  const { metadata, image: imageModel, banner: bannerModel, } = pageHeaderRenderer.content.pageHeaderViewModel;
29
- const metadataRow = metadata.contentMetadataViewModel.metadataRows[1];
29
+ const metadataRow = metadata.contentMetadataViewModel.metadataRows.find((m) => m.metadataParts);
30
30
  subscriberCountText = metadataRow.metadataParts.find((m) => !m.text.styeRuns).text.content;
31
31
  videoCountText = (_j = metadataRow.metadataParts.find((m) => m.text.styeRuns)) === null || _j === void 0 ? void 0 : _j.text.content;
32
32
  avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
@@ -67,7 +67,7 @@ class ChannelParser {
67
67
  })
68
68
  .filter((i) => i !== undefined);
69
69
  const shelf = {
70
- title: title.runs[0].text,
70
+ title: title.simpleText || title.runs[0].text,
71
71
  subtitle: subtitle === null || subtitle === void 0 ? void 0 : subtitle.simpleText,
72
72
  items,
73
73
  };
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommentParser = void 0;
4
4
  const common_1 = require("../../common");
5
5
  const BaseChannel_1 = require("../BaseChannel");
6
- const Reply_1 = require("../Reply");
6
+ const Comment_1 = require("./Comment");
7
7
  class CommentParser {
8
8
  static loadComment(target, data) {
9
9
  const { properties, toolbar, author, avatar } = data;
@@ -33,9 +33,10 @@ class CommentParser {
33
33
  return common_1.getContinuationFromItems(continuationItems, ["button", "buttonRenderer", "command"]);
34
34
  }
35
35
  static parseReplies(data, comment) {
36
- const continuationItems = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
37
- const rawReplies = common_1.mapFilter(continuationItems, "commentRenderer");
38
- return rawReplies.map((i) => new Reply_1.Reply({ video: comment.video, comment, client: comment.client }).load(i));
36
+ const replies = data.frameworkUpdates.entityBatchUpdate.mutations
37
+ .filter((e) => e.payload.commentEntityPayload)
38
+ .map((e) => e.payload.commentEntityPayload);
39
+ return replies.map((i) => new Comment_1.Comment({ video: comment.video, client: comment.client }).load(i));
39
40
  }
40
41
  }
41
42
  exports.CommentParser = CommentParser;
@@ -5,19 +5,18 @@ const common_1 = require("../../common");
5
5
  const BaseChannel_1 = require("../BaseChannel");
6
6
  class ReplyParser {
7
7
  static loadReply(target, data) {
8
- const { authorText, authorThumbnail, authorEndpoint, contentText, publishedTimeText, commentId, likeCount, authorIsChannelOwner, } = data;
8
+ const { properties, toolbar, author, avatar } = data;
9
9
  // Basic information
10
- target.id = commentId;
11
- target.content = contentText.runs.map((r) => r.text).join("");
12
- target.publishDate = publishedTimeText.runs.shift().text;
13
- target.likeCount = likeCount;
14
- target.isAuthorChannelOwner = authorIsChannelOwner;
10
+ target.id = properties.commentId;
11
+ target.content = properties.content.content;
12
+ target.publishDate = properties.publishedTime;
13
+ target.likeCount = +toolbar.likeCountLiked; // probably broken
14
+ target.isAuthorChannelOwner = !!author.isCreator;
15
15
  // Author
16
- const { browseId } = authorEndpoint.browseEndpoint;
17
16
  target.author = new BaseChannel_1.BaseChannel({
18
- id: browseId,
19
- name: authorText.simpleText,
20
- thumbnails: new common_1.Thumbnails().load(authorThumbnail.thumbnails),
17
+ id: author.id,
18
+ name: author.displayName,
19
+ thumbnails: new common_1.Thumbnails().load(avatar.image.sources),
21
20
  client: target.client,
22
21
  });
23
22
  return target;
@@ -23,9 +23,19 @@ class VideoParser {
23
23
  return target;
24
24
  }
25
25
  static parseComments(data, video) {
26
+ const endpoints = data.onResponseReceivedEndpoints.find((c) => {
27
+ var _a;
28
+ return (c.appendContinuationItemsAction ||
29
+ ((_a = c.reloadContinuationItemsCommand) === null || _a === void 0 ? void 0 : _a.slot) === "RELOAD_CONTINUATION_SLOT_BODY");
30
+ });
31
+ const repliesContinuationItems = (endpoints.reloadContinuationItemsCommand || endpoints.appendContinuationItemsAction).continuationItems;
26
32
  const comments = data.frameworkUpdates.entityBatchUpdate.mutations
27
33
  .filter((m) => m.payload.commentEntityPayload)
28
- .map((m) => m.payload.commentEntityPayload);
34
+ .map((m) => {
35
+ var _a;
36
+ const repliesItems = (_a = repliesContinuationItems.find((r) => r.commentThreadRenderer.commentViewModel.commentKey === m.key)) === null || _a === void 0 ? void 0 : _a.commentThreadRenderer;
37
+ return Object.assign(Object.assign({}, m.payload.commentEntityPayload), repliesItems);
38
+ });
29
39
  return comments.map((c) => new Comment_1.Comment({ video, client: video.client }).load(c));
30
40
  }
31
41
  static parseCommentContinuation(data) {
@@ -5,7 +5,7 @@ const common_1 = require("../../common");
5
5
  const BaseChannel_1 = require("../BaseChannel");
6
6
  class VideoCompactParser {
7
7
  static loadVideoCompact(target, data) {
8
- var _a, _b, _c, _d, _e;
8
+ var _a, _b, _c, _d, _e, _f, _g, _h;
9
9
  const { videoId, title, headline, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
10
10
  target.id = videoId;
11
11
  target.title = headline
@@ -22,19 +22,16 @@ class VideoCompactParser {
22
22
  !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW") ||
23
23
  ((_e = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _e === void 0 ? void 0 : _e.style) === "LIVE";
24
24
  // Channel
25
- if (ownerText || shortBylineText) {
26
- const browseEndpoint = (ownerText || shortBylineText).runs[0].navigationEndpoint
27
- .browseEndpoint;
28
- if (browseEndpoint) {
29
- const id = browseEndpoint.browseId;
30
- const thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
31
- target.channel = new BaseChannel_1.BaseChannel({
32
- id,
33
- name: (ownerText || shortBylineText).runs[0].text,
34
- thumbnails: thumbnails ? new common_1.Thumbnails().load(thumbnails) : undefined,
35
- client: target.client,
36
- });
37
- }
25
+ const browseEndpoint = (_h = (_g = (_f = (ownerText || shortBylineText)) === null || _f === void 0 ? void 0 : _f.runs[0]) === null || _g === void 0 ? void 0 : _g.navigationEndpoint) === null || _h === void 0 ? void 0 : _h.browseEndpoint;
26
+ if (browseEndpoint) {
27
+ const id = browseEndpoint.browseId;
28
+ const thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
29
+ target.channel = new BaseChannel_1.BaseChannel({
30
+ id,
31
+ name: (ownerText || shortBylineText).runs[0].text,
32
+ thumbnails: thumbnails ? new common_1.Thumbnails().load(thumbnails) : undefined,
33
+ client: target.client,
34
+ });
38
35
  }
39
36
  target.viewCount = common_1.stripToInt((viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) || (viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text));
40
37
  return target;
@@ -44,7 +44,7 @@ var BaseVideoParser = /** @class */ (function () {
44
44
  ((_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; })) || [];
45
45
  target.description = videoInfo.videoDetails.shortDescription || "";
46
46
  // related videos
47
- var secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results.find(function (s) { return s.itemSectionRenderer; }).itemSectionRenderer.contents;
47
+ var secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
48
48
  if (secondaryContents) {
49
49
  target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
50
50
  target.related.continuation = getContinuationFromItems(secondaryContents);
@@ -36,7 +36,7 @@ var ChannelParser = /** @class */ (function () {
36
36
  .browseEndpoint.browseId;
37
37
  title = pageHeaderRenderer.pageTitle;
38
38
  var _l = pageHeaderRenderer.content.pageHeaderViewModel, metadata = _l.metadata, imageModel = _l.image, bannerModel = _l.banner;
39
- var metadataRow = metadata.contentMetadataViewModel.metadataRows[1];
39
+ var metadataRow = metadata.contentMetadataViewModel.metadataRows.find(function (m) { return m.metadataParts; });
40
40
  subscriberCountText = metadataRow.metadataParts.find(function (m) { return !m.text.styeRuns; }).text.content;
41
41
  videoCountText = (_j = metadataRow.metadataParts.find(function (m) { return m.text.styeRuns; })) === null || _j === void 0 ? void 0 : _j.text.content;
42
42
  avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
@@ -80,7 +80,7 @@ var ChannelParser = /** @class */ (function () {
80
80
  })
81
81
  .filter(function (i) { return i !== undefined; });
82
82
  var shelf = {
83
- title: title.runs[0].text,
83
+ title: title.simpleText || title.runs[0].text,
84
84
  subtitle: subtitle === null || subtitle === void 0 ? void 0 : subtitle.simpleText,
85
85
  items: items,
86
86
  };
@@ -1,6 +1,6 @@
1
- import { getContinuationFromItems, mapFilter, Thumbnails } from "../../common";
1
+ import { getContinuationFromItems, Thumbnails } from "../../common";
2
2
  import { BaseChannel } from "../BaseChannel";
3
- import { Reply } from "../Reply";
3
+ import { Comment } from "./Comment";
4
4
  var CommentParser = /** @class */ (function () {
5
5
  function CommentParser() {
6
6
  }
@@ -32,10 +32,11 @@ var CommentParser = /** @class */ (function () {
32
32
  return getContinuationFromItems(continuationItems, ["button", "buttonRenderer", "command"]);
33
33
  };
34
34
  CommentParser.parseReplies = function (data, comment) {
35
- var continuationItems = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
36
- var rawReplies = mapFilter(continuationItems, "commentRenderer");
37
- return rawReplies.map(function (i) {
38
- return new Reply({ video: comment.video, comment: comment, client: comment.client }).load(i);
35
+ var replies = data.frameworkUpdates.entityBatchUpdate.mutations
36
+ .filter(function (e) { return e.payload.commentEntityPayload; })
37
+ .map(function (e) { return e.payload.commentEntityPayload; });
38
+ return replies.map(function (i) {
39
+ return new Comment({ video: comment.video, client: comment.client }).load(i);
39
40
  });
40
41
  };
41
42
  return CommentParser;
@@ -4,19 +4,18 @@ var ReplyParser = /** @class */ (function () {
4
4
  function ReplyParser() {
5
5
  }
6
6
  ReplyParser.loadReply = function (target, data) {
7
- var authorText = data.authorText, authorThumbnail = data.authorThumbnail, authorEndpoint = data.authorEndpoint, contentText = data.contentText, publishedTimeText = data.publishedTimeText, commentId = data.commentId, likeCount = data.likeCount, authorIsChannelOwner = data.authorIsChannelOwner;
7
+ var properties = data.properties, toolbar = data.toolbar, author = data.author, avatar = data.avatar;
8
8
  // Basic information
9
- target.id = commentId;
10
- target.content = contentText.runs.map(function (r) { return r.text; }).join("");
11
- target.publishDate = publishedTimeText.runs.shift().text;
12
- target.likeCount = likeCount;
13
- target.isAuthorChannelOwner = authorIsChannelOwner;
9
+ target.id = properties.commentId;
10
+ target.content = properties.content.content;
11
+ target.publishDate = properties.publishedTime;
12
+ target.likeCount = +toolbar.likeCountLiked; // probably broken
13
+ target.isAuthorChannelOwner = !!author.isCreator;
14
14
  // Author
15
- var browseId = authorEndpoint.browseEndpoint.browseId;
16
15
  target.author = new BaseChannel({
17
- id: browseId,
18
- name: authorText.simpleText,
19
- thumbnails: new Thumbnails().load(authorThumbnail.thumbnails),
16
+ id: author.id,
17
+ name: author.displayName,
18
+ thumbnails: new Thumbnails().load(avatar.image.sources),
20
19
  client: target.client,
21
20
  });
22
21
  return target;
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { getContinuationFromItems, Thumbnails } from "../../common";
2
13
  import { BaseVideoParser } from "../BaseVideo";
3
14
  import { Comment } from "../Comment";
@@ -25,9 +36,21 @@ var VideoParser = /** @class */ (function () {
25
36
  return target;
26
37
  };
27
38
  VideoParser.parseComments = function (data, video) {
39
+ var endpoints = data.onResponseReceivedEndpoints.find(function (c) {
40
+ var _a;
41
+ return (c.appendContinuationItemsAction ||
42
+ ((_a = c.reloadContinuationItemsCommand) === null || _a === void 0 ? void 0 : _a.slot) === "RELOAD_CONTINUATION_SLOT_BODY");
43
+ });
44
+ var repliesContinuationItems = (endpoints.reloadContinuationItemsCommand || endpoints.appendContinuationItemsAction).continuationItems;
28
45
  var comments = data.frameworkUpdates.entityBatchUpdate.mutations
29
46
  .filter(function (m) { return m.payload.commentEntityPayload; })
30
- .map(function (m) { return m.payload.commentEntityPayload; });
47
+ .map(function (m) {
48
+ var _a;
49
+ var repliesItems = (_a = repliesContinuationItems.find(function (r) {
50
+ return r.commentThreadRenderer.commentViewModel.commentKey === m.key;
51
+ })) === null || _a === void 0 ? void 0 : _a.commentThreadRenderer;
52
+ return __assign(__assign({}, m.payload.commentEntityPayload), repliesItems);
53
+ });
31
54
  return comments.map(function (c) {
32
55
  return new Comment({ video: video, client: video.client }).load(c);
33
56
  });
@@ -4,7 +4,7 @@ var VideoCompactParser = /** @class */ (function () {
4
4
  function VideoCompactParser() {
5
5
  }
6
6
  VideoCompactParser.loadVideoCompact = function (target, data) {
7
- var _a, _b, _c, _d, _e;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8
8
  var videoId = data.videoId, title = data.title, headline = data.headline, lengthText = data.lengthText, thumbnail = data.thumbnail, ownerText = data.ownerText, shortBylineText = data.shortBylineText, publishedTimeText = data.publishedTimeText, viewCountText = data.viewCountText, badges = data.badges, thumbnailOverlays = data.thumbnailOverlays, channelThumbnailSupportedRenderers = data.channelThumbnailSupportedRenderers, detailedMetadataSnippets = data.detailedMetadataSnippets;
9
9
  target.id = videoId;
10
10
  target.title = headline
@@ -21,19 +21,16 @@ var VideoCompactParser = /** @class */ (function () {
21
21
  !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW") ||
22
22
  ((_e = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _e === void 0 ? void 0 : _e.style) === "LIVE";
23
23
  // Channel
24
- if (ownerText || shortBylineText) {
25
- var browseEndpoint = (ownerText || shortBylineText).runs[0].navigationEndpoint
26
- .browseEndpoint;
27
- if (browseEndpoint) {
28
- var id = browseEndpoint.browseId;
29
- var thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
30
- target.channel = new BaseChannel({
31
- id: id,
32
- name: (ownerText || shortBylineText).runs[0].text,
33
- thumbnails: thumbnails ? new Thumbnails().load(thumbnails) : undefined,
34
- client: target.client,
35
- });
36
- }
24
+ var browseEndpoint = (_h = (_g = (_f = (ownerText || shortBylineText)) === null || _f === void 0 ? void 0 : _f.runs[0]) === null || _g === void 0 ? void 0 : _g.navigationEndpoint) === null || _h === void 0 ? void 0 : _h.browseEndpoint;
25
+ if (browseEndpoint) {
26
+ var id = browseEndpoint.browseId;
27
+ var thumbnails = channelThumbnailSupportedRenderers === null || channelThumbnailSupportedRenderers === void 0 ? void 0 : channelThumbnailSupportedRenderers.channelThumbnailWithLinkRenderer.thumbnail.thumbnails;
28
+ target.channel = new BaseChannel({
29
+ id: id,
30
+ name: (ownerText || shortBylineText).runs[0].text,
31
+ thumbnails: thumbnails ? new Thumbnails().load(thumbnails) : undefined,
32
+ client: target.client,
33
+ });
37
34
  }
38
35
  target.viewCount = stripToInt((viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) || (viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text));
39
36
  return target;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.6.1",
3
+ "version": "1.6.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",