youtubei 1.8.7 → 1.8.8

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.
@@ -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;
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12
12
  const videoInfo = BaseVideoParser.parseRawData(data);
13
13
  // Basic information
14
14
  target.id = videoInfo.currentVideoEndpoint.watchEndpoint.videoId;
@@ -58,12 +58,15 @@ class BaseVideoParser {
58
58
  // Tags and description
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
- target.description = videoInfo.attributedDescription.content || ""; // TODO
61
+ target.description =
62
+ ((_g = videoInfo.videoDetails) === null || _g === void 0 ? void 0 : _g.shortDescription) ||
63
+ videoInfo.attributedDescription.content ||
64
+ "";
62
65
  // related videos
63
- let secondaryContents = (_g = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _g === void 0 ? void 0 : _g.secondaryResults.results;
64
- const itemSectionRenderer = (_h = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find((c) => {
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
68
  return c.itemSectionRenderer;
66
- })) === null || _h === void 0 ? void 0 : _h.itemSectionRenderer;
69
+ })) === null || _j === void 0 ? void 0 : _j.itemSectionRenderer;
67
70
  if (itemSectionRenderer)
68
71
  secondaryContents = itemSectionRenderer.contents;
69
72
  if (secondaryContents) {
@@ -82,10 +82,15 @@ class Client {
82
82
  getVideo(videoId) {
83
83
  var _a, _b;
84
84
  return __awaiter(this, void 0, void 0, function* () {
85
- const nextPromise = this.http.post(`${constants_1.I_END_POINT}/next`, { data: { videoId } });
86
- const playerPromise = this.http.post(`${constants_1.I_END_POINT}/player`, { data: { videoId } });
87
- const [nextResponse, playerResponse] = yield Promise.all([nextPromise, playerPromise]);
88
- const data = { response: nextResponse.data, playerResponse: playerResponse.data };
85
+ const response = yield this.http.post(`${constants_1.I_END_POINT}/get_watch`, {
86
+ data: { playerRequest: { videoId }, watchNextRequest: { videoId } },
87
+ });
88
+ const data = {
89
+ response: response.data.find((r) => "watchNextResponse" in r)
90
+ .watchNextResponse,
91
+ playerResponse: response.data.find((r) => "playerResponse" in r)
92
+ .playerResponse,
93
+ };
89
94
  if (!((_b = (_a = data.response) === null || _a === void 0 ? void 0 : _a.contents) === null || _b === void 0 ? void 0 : _b.twoColumnWatchNextResults.results.results.contents) ||
90
95
  data.playerResponse.playabilityStatus.status === "ERROR") {
91
96
  return undefined;
@@ -9,7 +9,8 @@ class VideoParser {
9
9
  var _a, _b, _c, _d, _e, _f, _g, _h;
10
10
  const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
11
11
  const mutations = videoInfo.frameworkUpdates.entityBatchUpdate.mutations;
12
- const lastMarkers = (_a = mutations.find((m) => { var _a; return (_a = m.payload) === null || _a === void 0 ? void 0 : _a.macroMarkersListEntity; })) === null || _a === void 0 ? void 0 : _a.payload.macroMarkersListEntity.markersList.markers;
12
+ const lastMarkers = (_a = mutations
13
+ .find((m) => { var _a; return (_a = m.payload) === null || _a === void 0 ? void 0 : _a.macroMarkersListEntity; })) === null || _a === void 0 ? void 0 : _a.payload.macroMarkersListEntity.markersList.markers.at(-1);
13
14
  target.duration =
14
15
  +((_b = videoInfo.videoDetails) === null || _b === void 0 ? void 0 : _b.lengthSeconds) ||
15
16
  (lastMarkers ? (+lastMarkers.startMillis + +lastMarkers.durationMillis) / 1000 : 0);
@@ -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;
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
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 _j = videoInfo.owner.videoOwnerRenderer, title = _j.title, thumbnail = _j.thumbnail, subscriberCountText = _j.subscriberCountText;
35
+ var _k = videoInfo.owner.videoOwnerRenderer, title = _k.title, thumbnail = _k.thumbnail, subscriberCountText = _k.subscriberCountText;
36
36
  if (title) {
37
37
  target.channel = new BaseChannel({
38
38
  client: target.client,
@@ -68,12 +68,15 @@ var BaseVideoParser = /** @class */ (function () {
68
68
  // Tags and description
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
- target.description = videoInfo.attributedDescription.content || ""; // TODO
71
+ target.description =
72
+ ((_g = videoInfo.videoDetails) === null || _g === void 0 ? void 0 : _g.shortDescription) ||
73
+ videoInfo.attributedDescription.content ||
74
+ "";
72
75
  // related videos
73
- var secondaryContents = (_g = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _g === void 0 ? void 0 : _g.secondaryResults.results;
74
- var itemSectionRenderer = (_h = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find(function (c) {
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
78
  return c.itemSectionRenderer;
76
- })) === null || _h === void 0 ? void 0 : _h.itemSectionRenderer;
79
+ })) === null || _j === void 0 ? void 0 : _j.itemSectionRenderer;
77
80
  if (itemSectionRenderer)
78
81
  secondaryContents = itemSectionRenderer.contents;
79
82
  if (secondaryContents) {
@@ -45,22 +45,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- var __read = (this && this.__read) || function (o, n) {
49
- var m = typeof Symbol === "function" && o[Symbol.iterator];
50
- if (!m) return o;
51
- var i = m.call(o), r, ar = [], e;
52
- try {
53
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
54
- }
55
- catch (error) { e = { error: error }; }
56
- finally {
57
- try {
58
- if (r && !r.done && (m = i["return"])) m.call(i);
59
- }
60
- finally { if (e) throw e.error; }
61
- }
62
- return ar;
63
- };
64
48
  import { HTTP } from "../../common";
65
49
  import { Channel } from "../Channel";
66
50
  import { LiveVideo } from "../LiveVideo";
@@ -162,16 +146,20 @@ var Client = /** @class */ (function () {
162
146
  Client.prototype.getVideo = function (videoId) {
163
147
  var _a, _b;
164
148
  return __awaiter(this, void 0, void 0, function () {
165
- var nextPromise, playerPromise, _c, nextResponse, playerResponse, data;
166
- return __generator(this, function (_d) {
167
- switch (_d.label) {
168
- case 0:
169
- nextPromise = this.http.post(I_END_POINT + "/next", { data: { videoId: videoId } });
170
- playerPromise = this.http.post(I_END_POINT + "/player", { data: { videoId: videoId } });
171
- return [4 /*yield*/, Promise.all([nextPromise, playerPromise])];
149
+ var response, data;
150
+ return __generator(this, function (_c) {
151
+ switch (_c.label) {
152
+ case 0: return [4 /*yield*/, this.http.post(I_END_POINT + "/get_watch", {
153
+ data: { playerRequest: { videoId: videoId }, watchNextRequest: { videoId: videoId } },
154
+ })];
172
155
  case 1:
173
- _c = __read.apply(void 0, [_d.sent(), 2]), nextResponse = _c[0], playerResponse = _c[1];
174
- data = { response: nextResponse.data, playerResponse: playerResponse.data };
156
+ response = _c.sent();
157
+ data = {
158
+ response: response.data.find(function (r) { return "watchNextResponse" in r; })
159
+ .watchNextResponse,
160
+ playerResponse: response.data.find(function (r) { return "playerResponse" in r; })
161
+ .playerResponse,
162
+ };
175
163
  if (!((_b = (_a = data.response) === null || _a === void 0 ? void 0 : _a.contents) === null || _b === void 0 ? void 0 : _b.twoColumnWatchNextResults.results.results.contents) ||
176
164
  data.playerResponse.playabilityStatus.status === "ERROR") {
177
165
  return [2 /*return*/, undefined];
@@ -19,7 +19,8 @@ var VideoParser = /** @class */ (function () {
19
19
  var _a, _b, _c, _d, _e, _f, _g, _h;
20
20
  var videoInfo = BaseVideoParser.parseRawData(data);
21
21
  var mutations = videoInfo.frameworkUpdates.entityBatchUpdate.mutations;
22
- var lastMarkers = (_a = mutations.find(function (m) { var _a; return (_a = m.payload) === null || _a === void 0 ? void 0 : _a.macroMarkersListEntity; })) === null || _a === void 0 ? void 0 : _a.payload.macroMarkersListEntity.markersList.markers;
22
+ var lastMarkers = (_a = mutations
23
+ .find(function (m) { var _a; return (_a = m.payload) === null || _a === void 0 ? void 0 : _a.macroMarkersListEntity; })) === null || _a === void 0 ? void 0 : _a.payload.macroMarkersListEntity.markersList.markers.at(-1);
23
24
  target.duration =
24
25
  +((_b = videoInfo.videoDetails) === null || _b === void 0 ? void 0 : _b.lengthSeconds) ||
25
26
  (lastMarkers ? (+lastMarkers.startMillis + +lastMarkers.durationMillis) / 1000 : 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
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",