youtubei 1.8.9 → 1.8.10

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.
@@ -46,10 +46,28 @@ class ChannelLive extends Continuable_1.Continuable {
46
46
  });
47
47
  const items = BaseChannelParser_1.BaseChannelParser.parseTabData("live", response.data);
48
48
  const continuation = common_1.getContinuationFromItems(items);
49
- const data = common_1.mapFilter(items, "videoRenderer");
49
+ const videoRenderers = common_1.mapFilter(items, "videoRenderer");
50
+ const lockupViewModels = common_1.mapFilter(items, "lockupViewModel");
51
+ const fromVideoRenderer = videoRenderers.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i));
52
+ const fromLockup = lockupViewModels.map((i) => {
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
54
+ const v = new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel });
55
+ v.id = i.contentId;
56
+ v.title = (_c = (_b = (_a = i.metadata) === null || _a === void 0 ? void 0 : _a.lockupMetadataViewModel) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.content;
57
+ v.thumbnails = new common_1.Thumbnails().load(((_f = (_e = (_d = i.contentImage) === null || _d === void 0 ? void 0 : _d.thumbnailViewModel) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.sources) || []);
58
+ const overlays = ((_j = (_h = (_g = i.contentImage) === null || _g === void 0 ? void 0 : _g.thumbnailViewModel) === null || _h === void 0 ? void 0 : _h.overlays) === null || _j === void 0 ? void 0 : _j[0]) || {};
59
+ const badges = ((_k = overlays.thumbnailBottomOverlayViewModel) === null || _k === void 0 ? void 0 : _k.badges) || [];
60
+ const badgeText = ((_m = (_l = badges[0]) === null || _l === void 0 ? void 0 : _l.thumbnailBadgeViewModel) === null || _m === void 0 ? void 0 : _m.text) || "";
61
+ v.isLive = badgeText === "LIVE";
62
+ v.duration = !v.isLive && badgeText ? common_1.getDuration(badgeText) : null;
63
+ const metaRows = ((_r = (_q = (_p = (_o = i.metadata) === null || _o === void 0 ? void 0 : _o.lockupMetadataViewModel) === null || _p === void 0 ? void 0 : _p.metadata) === null || _q === void 0 ? void 0 : _q.contentMetadataViewModel) === null || _r === void 0 ? void 0 : _r.metadataRows) || [];
64
+ const metaText = ((_v = (_u = (_t = (_s = metaRows[0]) === null || _s === void 0 ? void 0 : _s.metadataParts) === null || _t === void 0 ? void 0 : _t[0]) === null || _u === void 0 ? void 0 : _u.text) === null || _v === void 0 ? void 0 : _v.content) || "";
65
+ v.viewCount = common_1.stripToInt(metaText);
66
+ return v;
67
+ });
50
68
  return {
51
69
  continuation,
52
- items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
70
+ items: [...fromVideoRenderer, ...fromLockup],
53
71
  };
54
72
  });
55
73
  }
@@ -46,10 +46,28 @@ class ChannelVideos extends Continuable_1.Continuable {
46
46
  });
47
47
  const items = BaseChannelParser_1.BaseChannelParser.parseTabData("videos", response.data);
48
48
  const continuation = common_1.getContinuationFromItems(items);
49
- const data = common_1.mapFilter(items, "videoRenderer");
49
+ const videoRenderers = common_1.mapFilter(items, "videoRenderer");
50
+ const lockupViewModels = common_1.mapFilter(items, "lockupViewModel");
51
+ const fromVideoRenderer = videoRenderers.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i));
52
+ const fromLockup = lockupViewModels.map((i) => {
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
54
+ const v = new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel });
55
+ v.id = i.contentId;
56
+ v.title = (_c = (_b = (_a = i.metadata) === null || _a === void 0 ? void 0 : _a.lockupMetadataViewModel) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.content;
57
+ v.thumbnails = new common_1.Thumbnails().load(((_f = (_e = (_d = i.contentImage) === null || _d === void 0 ? void 0 : _d.thumbnailViewModel) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.sources) || []);
58
+ const overlays = ((_j = (_h = (_g = i.contentImage) === null || _g === void 0 ? void 0 : _g.thumbnailViewModel) === null || _h === void 0 ? void 0 : _h.overlays) === null || _j === void 0 ? void 0 : _j[0]) || {};
59
+ const badges = ((_k = overlays.thumbnailBottomOverlayViewModel) === null || _k === void 0 ? void 0 : _k.badges) || [];
60
+ const badgeText = ((_m = (_l = badges[0]) === null || _l === void 0 ? void 0 : _l.thumbnailBadgeViewModel) === null || _m === void 0 ? void 0 : _m.text) || "";
61
+ v.isLive = badgeText === "LIVE";
62
+ v.duration = !v.isLive && badgeText ? common_1.getDuration(badgeText) : null;
63
+ const metaRows = ((_r = (_q = (_p = (_o = i.metadata) === null || _o === void 0 ? void 0 : _o.lockupMetadataViewModel) === null || _p === void 0 ? void 0 : _p.metadata) === null || _q === void 0 ? void 0 : _q.contentMetadataViewModel) === null || _r === void 0 ? void 0 : _r.metadataRows) || [];
64
+ const metaText = ((_v = (_u = (_t = (_s = metaRows[0]) === null || _s === void 0 ? void 0 : _s.metadataParts) === null || _t === void 0 ? void 0 : _t[0]) === null || _u === void 0 ? void 0 : _u.text) === null || _v === void 0 ? void 0 : _v.content) || "";
65
+ v.viewCount = common_1.stripToInt(metaText);
66
+ return v;
67
+ });
50
68
  return {
51
69
  continuation,
52
- items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
70
+ items: [...fromVideoRenderer, ...fromLockup],
53
71
  };
54
72
  });
55
73
  }
@@ -8,7 +8,7 @@ const VideoCompact_1 = require("../VideoCompact");
8
8
  const VideoCaptions_1 = require("./VideoCaptions");
9
9
  class BaseVideoParser {
10
10
  static loadBaseVideo(target, data) {
11
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
12
12
  const videoInfo = BaseVideoParser.parseRawData(data);
13
13
  // Basic information
14
14
  target.id = videoInfo.currentVideoEndpoint.watchEndpoint.videoId;
@@ -59,14 +59,13 @@ class BaseVideoParser {
59
59
  target.tags =
60
60
  ((_f = (_e = videoInfo.superTitleLink) === null || _e === void 0 ? void 0 : _e.runs) === null || _f === void 0 ? void 0 : _f.map((r) => r.text.trim()).filter((t) => t)) || [];
61
61
  target.description =
62
- ((_g = videoInfo.videoDetails) === null || _g === void 0 ? void 0 : _g.shortDescription) ||
63
- videoInfo.attributedDescription.content ||
62
+ ((_g = videoInfo.videoDetails) === null || _g === void 0 ? void 0 : _g.shortDescription) || ((_h = videoInfo.attributedDescription) === null || _h === void 0 ? void 0 : _h.content) ||
64
63
  "";
65
64
  // related videos
66
- let secondaryContents = (_h = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _h === void 0 ? void 0 : _h.secondaryResults.results;
67
- const itemSectionRenderer = (_j = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find((c) => {
65
+ let secondaryContents = (_j = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _j === void 0 ? void 0 : _j.secondaryResults.results;
66
+ const itemSectionRenderer = (_k = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find((c) => {
68
67
  return c.itemSectionRenderer;
69
- })) === null || _j === void 0 ? void 0 : _j.itemSectionRenderer;
68
+ })) === null || _k === void 0 ? void 0 : _k.itemSectionRenderer;
70
69
  if (itemSectionRenderer)
71
70
  secondaryContents = itemSectionRenderer.contents;
72
71
  if (secondaryContents) {
@@ -47,7 +47,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
48
  }
49
49
  };
50
- import { getContinuationFromItems, mapFilter } from "../../common";
50
+ var __read = (this && this.__read) || function (o, n) {
51
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
52
+ if (!m) return o;
53
+ var i = m.call(o), r, ar = [], e;
54
+ try {
55
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
56
+ }
57
+ catch (error) { e = { error: error }; }
58
+ finally {
59
+ try {
60
+ if (r && !r.done && (m = i["return"])) m.call(i);
61
+ }
62
+ finally { if (e) throw e.error; }
63
+ }
64
+ return ar;
65
+ };
66
+ var __spread = (this && this.__spread) || function () {
67
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
68
+ return ar;
69
+ };
70
+ import { Thumbnails, getContinuationFromItems, getDuration, mapFilter, stripToInt } from "../../common";
51
71
  import { Continuable } from "../Continuable";
52
72
  import { VideoCompact } from "../VideoCompact";
53
73
  import { I_END_POINT } from "../constants";
@@ -80,7 +100,7 @@ var ChannelLive = /** @class */ (function (_super) {
80
100
  ChannelLive.prototype.fetch = function () {
81
101
  var _a;
82
102
  return __awaiter(this, void 0, void 0, function () {
83
- var params, response, items, continuation, data;
103
+ var params, response, items, continuation, videoRenderers, lockupViewModels, fromVideoRenderer, fromLockup;
84
104
  var _this = this;
85
105
  return __generator(this, function (_b) {
86
106
  switch (_b.label) {
@@ -93,12 +113,30 @@ var ChannelLive = /** @class */ (function (_super) {
93
113
  response = _b.sent();
94
114
  items = BaseChannelParser.parseTabData("live", response.data);
95
115
  continuation = getContinuationFromItems(items);
96
- data = mapFilter(items, "videoRenderer");
116
+ videoRenderers = mapFilter(items, "videoRenderer");
117
+ lockupViewModels = mapFilter(items, "lockupViewModel");
118
+ fromVideoRenderer = videoRenderers.map(function (i) {
119
+ return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
120
+ });
121
+ fromLockup = lockupViewModels.map(function (i) {
122
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
123
+ var v = new VideoCompact({ client: _this.client, channel: _this.channel });
124
+ v.id = i.contentId;
125
+ v.title = (_c = (_b = (_a = i.metadata) === null || _a === void 0 ? void 0 : _a.lockupMetadataViewModel) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.content;
126
+ v.thumbnails = new Thumbnails().load(((_f = (_e = (_d = i.contentImage) === null || _d === void 0 ? void 0 : _d.thumbnailViewModel) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.sources) || []);
127
+ var overlays = ((_j = (_h = (_g = i.contentImage) === null || _g === void 0 ? void 0 : _g.thumbnailViewModel) === null || _h === void 0 ? void 0 : _h.overlays) === null || _j === void 0 ? void 0 : _j[0]) || {};
128
+ var badges = ((_k = overlays.thumbnailBottomOverlayViewModel) === null || _k === void 0 ? void 0 : _k.badges) || [];
129
+ var badgeText = ((_m = (_l = badges[0]) === null || _l === void 0 ? void 0 : _l.thumbnailBadgeViewModel) === null || _m === void 0 ? void 0 : _m.text) || "";
130
+ v.isLive = badgeText === "LIVE";
131
+ v.duration = !v.isLive && badgeText ? getDuration(badgeText) : null;
132
+ var metaRows = ((_r = (_q = (_p = (_o = i.metadata) === null || _o === void 0 ? void 0 : _o.lockupMetadataViewModel) === null || _p === void 0 ? void 0 : _p.metadata) === null || _q === void 0 ? void 0 : _q.contentMetadataViewModel) === null || _r === void 0 ? void 0 : _r.metadataRows) || [];
133
+ var metaText = ((_v = (_u = (_t = (_s = metaRows[0]) === null || _s === void 0 ? void 0 : _s.metadataParts) === null || _t === void 0 ? void 0 : _t[0]) === null || _u === void 0 ? void 0 : _u.text) === null || _v === void 0 ? void 0 : _v.content) || "";
134
+ v.viewCount = stripToInt(metaText);
135
+ return v;
136
+ });
97
137
  return [2 /*return*/, {
98
138
  continuation: continuation,
99
- items: data.map(function (i) {
100
- return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
101
- }),
139
+ items: __spread(fromVideoRenderer, fromLockup),
102
140
  }];
103
141
  }
104
142
  });
@@ -47,7 +47,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
48
  }
49
49
  };
50
- import { getContinuationFromItems, mapFilter } from "../../common";
50
+ var __read = (this && this.__read) || function (o, n) {
51
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
52
+ if (!m) return o;
53
+ var i = m.call(o), r, ar = [], e;
54
+ try {
55
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
56
+ }
57
+ catch (error) { e = { error: error }; }
58
+ finally {
59
+ try {
60
+ if (r && !r.done && (m = i["return"])) m.call(i);
61
+ }
62
+ finally { if (e) throw e.error; }
63
+ }
64
+ return ar;
65
+ };
66
+ var __spread = (this && this.__spread) || function () {
67
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
68
+ return ar;
69
+ };
70
+ import { getContinuationFromItems, getDuration, mapFilter, stripToInt, Thumbnails } from "../../common";
51
71
  import { Continuable } from "../Continuable";
52
72
  import { VideoCompact } from "../VideoCompact";
53
73
  import { I_END_POINT } from "../constants";
@@ -80,7 +100,7 @@ var ChannelVideos = /** @class */ (function (_super) {
80
100
  ChannelVideos.prototype.fetch = function () {
81
101
  var _a;
82
102
  return __awaiter(this, void 0, void 0, function () {
83
- var params, response, items, continuation, data;
103
+ var params, response, items, continuation, videoRenderers, lockupViewModels, fromVideoRenderer, fromLockup;
84
104
  var _this = this;
85
105
  return __generator(this, function (_b) {
86
106
  switch (_b.label) {
@@ -93,12 +113,30 @@ var ChannelVideos = /** @class */ (function (_super) {
93
113
  response = _b.sent();
94
114
  items = BaseChannelParser.parseTabData("videos", response.data);
95
115
  continuation = getContinuationFromItems(items);
96
- data = mapFilter(items, "videoRenderer");
116
+ videoRenderers = mapFilter(items, "videoRenderer");
117
+ lockupViewModels = mapFilter(items, "lockupViewModel");
118
+ fromVideoRenderer = videoRenderers.map(function (i) {
119
+ return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
120
+ });
121
+ fromLockup = lockupViewModels.map(function (i) {
122
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
123
+ var v = new VideoCompact({ client: _this.client, channel: _this.channel });
124
+ v.id = i.contentId;
125
+ v.title = (_c = (_b = (_a = i.metadata) === null || _a === void 0 ? void 0 : _a.lockupMetadataViewModel) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.content;
126
+ v.thumbnails = new Thumbnails().load(((_f = (_e = (_d = i.contentImage) === null || _d === void 0 ? void 0 : _d.thumbnailViewModel) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.sources) || []);
127
+ var overlays = ((_j = (_h = (_g = i.contentImage) === null || _g === void 0 ? void 0 : _g.thumbnailViewModel) === null || _h === void 0 ? void 0 : _h.overlays) === null || _j === void 0 ? void 0 : _j[0]) || {};
128
+ var badges = ((_k = overlays.thumbnailBottomOverlayViewModel) === null || _k === void 0 ? void 0 : _k.badges) || [];
129
+ var badgeText = ((_m = (_l = badges[0]) === null || _l === void 0 ? void 0 : _l.thumbnailBadgeViewModel) === null || _m === void 0 ? void 0 : _m.text) || "";
130
+ v.isLive = badgeText === "LIVE";
131
+ v.duration = !v.isLive && badgeText ? getDuration(badgeText) : null;
132
+ var metaRows = ((_r = (_q = (_p = (_o = i.metadata) === null || _o === void 0 ? void 0 : _o.lockupMetadataViewModel) === null || _p === void 0 ? void 0 : _p.metadata) === null || _q === void 0 ? void 0 : _q.contentMetadataViewModel) === null || _r === void 0 ? void 0 : _r.metadataRows) || [];
133
+ var metaText = ((_v = (_u = (_t = (_s = metaRows[0]) === null || _s === void 0 ? void 0 : _s.metadataParts) === null || _t === void 0 ? void 0 : _t[0]) === null || _u === void 0 ? void 0 : _u.text) === null || _v === void 0 ? void 0 : _v.content) || "";
134
+ v.viewCount = stripToInt(metaText);
135
+ return v;
136
+ });
97
137
  return [2 /*return*/, {
98
138
  continuation: continuation,
99
- items: data.map(function (i) {
100
- return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
101
- }),
139
+ items: __spread(fromVideoRenderer, fromLockup),
102
140
  }];
103
141
  }
104
142
  });
@@ -18,7 +18,7 @@ var BaseVideoParser = /** @class */ (function () {
18
18
  function BaseVideoParser() {
19
19
  }
20
20
  BaseVideoParser.loadBaseVideo = function (target, data) {
21
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
22
22
  var videoInfo = BaseVideoParser.parseRawData(data);
23
23
  // Basic information
24
24
  target.id = videoInfo.currentVideoEndpoint.watchEndpoint.videoId;
@@ -32,7 +32,7 @@ var BaseVideoParser = /** @class */ (function () {
32
32
  target.adaptiveFormats = ((_c = videoInfo.streamingData) === null || _c === void 0 ? void 0 : _c.adaptiveFormats) || [];
33
33
  target.thumbnails = new Thumbnails().load(((_d = videoInfo.videoDetails) === null || _d === void 0 ? void 0 : _d.thumbnail.thumbnails) || getThumbnailFromId(target.id));
34
34
  // Channel
35
- var _k = videoInfo.owner.videoOwnerRenderer, title = _k.title, thumbnail = _k.thumbnail, subscriberCountText = _k.subscriberCountText;
35
+ var _l = videoInfo.owner.videoOwnerRenderer, title = _l.title, thumbnail = _l.thumbnail, subscriberCountText = _l.subscriberCountText;
36
36
  if (title) {
37
37
  target.channel = new BaseChannel({
38
38
  client: target.client,
@@ -69,14 +69,13 @@ var BaseVideoParser = /** @class */ (function () {
69
69
  target.tags =
70
70
  ((_f = (_e = videoInfo.superTitleLink) === null || _e === void 0 ? void 0 : _e.runs) === null || _f === void 0 ? void 0 : _f.map(function (r) { return r.text.trim(); }).filter(function (t) { return t; })) || [];
71
71
  target.description =
72
- ((_g = videoInfo.videoDetails) === null || _g === void 0 ? void 0 : _g.shortDescription) ||
73
- videoInfo.attributedDescription.content ||
72
+ ((_g = videoInfo.videoDetails) === null || _g === void 0 ? void 0 : _g.shortDescription) || ((_h = videoInfo.attributedDescription) === null || _h === void 0 ? void 0 : _h.content) ||
74
73
  "";
75
74
  // related videos
76
- var secondaryContents = (_h = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _h === void 0 ? void 0 : _h.secondaryResults.results;
77
- var itemSectionRenderer = (_j = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find(function (c) {
75
+ var secondaryContents = (_j = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _j === void 0 ? void 0 : _j.secondaryResults.results;
76
+ var itemSectionRenderer = (_k = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find(function (c) {
78
77
  return c.itemSectionRenderer;
79
- })) === null || _j === void 0 ? void 0 : _j.itemSectionRenderer;
78
+ })) === null || _k === void 0 ? void 0 : _k.itemSectionRenderer;
80
79
  if (itemSectionRenderer)
81
80
  secondaryContents = itemSectionRenderer.contents;
82
81
  if (secondaryContents) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.8.9",
3
+ "version": "1.8.10",
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",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "homepage": "https://suspiciouslookingowl.github.io/youtubei",
64
64
  "dependencies": {
65
- "node-fetch": "2.6.7",
66
- "protobufjs": "7.2.6"
65
+ "node-fetch": "2.7.0",
66
+ "protobufjs": "8.4.0"
67
67
  }
68
68
  }