youtubei 1.5.1 → 1.5.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.
@@ -186,13 +186,7 @@ class MusicAllSearchResultParser {
186
186
  return album;
187
187
  }
188
188
  static parseArtists(items, client) {
189
- return items
190
- .filter((r) => {
191
- var _a;
192
- const pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
193
- return pageType === "MUSIC_PAGE_TYPE_ARTIST";
194
- })
195
- .map((r) => {
189
+ return this.parseArtistsOrChannel(items).map((r) => {
196
190
  var _a;
197
191
  return new MusicBaseArtist_1.MusicBaseArtist({
198
192
  client,
@@ -203,11 +197,7 @@ class MusicAllSearchResultParser {
203
197
  }
204
198
  static parseChannel(items, client) {
205
199
  var _a;
206
- const channelRaw = items.find((r) => {
207
- var _a;
208
- const pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
209
- return pageType === "MUSIC_PAGE_TYPE_USER_CHANNEL";
210
- });
200
+ const [channelRaw] = this.parseArtistsOrChannel(items);
211
201
  if (!channelRaw)
212
202
  return;
213
203
  const channel = new MusicBaseChannel_1.MusicBaseChannel({
@@ -217,5 +207,12 @@ class MusicAllSearchResultParser {
217
207
  });
218
208
  return channel;
219
209
  }
210
+ static parseArtistsOrChannel(items) {
211
+ return items.filter((i) => {
212
+ var _a;
213
+ const pageType = (_a = i.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
214
+ return (pageType === "MUSIC_PAGE_TYPE_ARTIST" || pageType == "MUSIC_PAGE_TYPE_USER_CHANNEL");
215
+ });
216
+ }
220
217
  }
221
218
  exports.MusicAllSearchResultParser = MusicAllSearchResultParser;
@@ -70,7 +70,8 @@ class VideoCaptions extends Base_1.Base {
70
70
  curr.push(new Caption_1.Caption({
71
71
  duration: e.dDurationMs,
72
72
  start: e.tStartMs,
73
- text: (_a = e.segs) === null || _a === void 0 ? void 0 : _a.map((s) => Object.values(s).join("")).join(" "),
73
+ text: (_a = e.segs) === null || _a === void 0 ? void 0 : _a.map((s) => s.utf8).join(),
74
+ segments: e.segs,
74
75
  }));
75
76
  return curr;
76
77
  }, []);
@@ -201,13 +201,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
201
201
  return album;
202
202
  };
203
203
  MusicAllSearchResultParser.parseArtists = function (items, client) {
204
- return items
205
- .filter(function (r) {
206
- var _a;
207
- var pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
208
- return pageType === "MUSIC_PAGE_TYPE_ARTIST";
209
- })
210
- .map(function (r) {
204
+ return this.parseArtistsOrChannel(items).map(function (r) {
211
205
  var _a;
212
206
  return new MusicBaseArtist({
213
207
  client: client,
@@ -218,11 +212,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
218
212
  };
219
213
  MusicAllSearchResultParser.parseChannel = function (items, client) {
220
214
  var _a;
221
- var channelRaw = items.find(function (r) {
222
- var _a;
223
- var pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
224
- return pageType === "MUSIC_PAGE_TYPE_USER_CHANNEL";
225
- });
215
+ var _b = __read(this.parseArtistsOrChannel(items), 1), channelRaw = _b[0];
226
216
  if (!channelRaw)
227
217
  return;
228
218
  var channel = new MusicBaseChannel({
@@ -232,6 +222,13 @@ var MusicAllSearchResultParser = /** @class */ (function () {
232
222
  });
233
223
  return channel;
234
224
  };
225
+ MusicAllSearchResultParser.parseArtistsOrChannel = function (items) {
226
+ return items.filter(function (i) {
227
+ var _a;
228
+ var pageType = (_a = i.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
229
+ return (pageType === "MUSIC_PAGE_TYPE_ARTIST" || pageType == "MUSIC_PAGE_TYPE_USER_CHANNEL");
230
+ });
231
+ };
235
232
  return MusicAllSearchResultParser;
236
233
  }());
237
234
  export { MusicAllSearchResultParser };
@@ -119,7 +119,8 @@ var VideoCaptions = /** @class */ (function (_super) {
119
119
  curr.push(new Caption({
120
120
  duration: e.dDurationMs,
121
121
  start: e.tStartMs,
122
- text: (_a = e.segs) === null || _a === void 0 ? void 0 : _a.map(function (s) { return Object.values(s).join(""); }).join(" "),
122
+ text: (_a = e.segs) === null || _a === void 0 ? void 0 : _a.map(function (s) { return s.utf8; }).join(),
123
+ segments: e.segs,
123
124
  }));
124
125
  return curr;
125
126
  }, []);
@@ -15,4 +15,5 @@ export declare class MusicAllSearchResultParser {
15
15
  private static parseAlbum;
16
16
  private static parseArtists;
17
17
  private static parseChannel;
18
+ private static parseArtistsOrChannel;
18
19
  }
@@ -3,7 +3,13 @@ interface CaptionProperties {
3
3
  text?: string;
4
4
  start?: number;
5
5
  duration?: number;
6
+ segments?: CaptionSegment[];
6
7
  }
8
+ declare type CaptionSegment = {
9
+ utf8: string;
10
+ tOffsetMs?: number;
11
+ acAsrConf: number;
12
+ };
7
13
  /**
8
14
  * Represent a single video caption entry
9
15
  */
@@ -14,6 +20,8 @@ export declare class Caption implements CaptionProperties {
14
20
  start: number;
15
21
  /** caption duration in milliseconds */
16
22
  duration: number;
23
+ /** caption duration in milliseconds */
24
+ segments: CaptionSegment[];
17
25
  /** @hidden */
18
26
  constructor(attr?: CaptionProperties);
19
27
  /** transcript end time in milliseconds */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.5.1",
3
+ "version": "1.5.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",