youtubei 1.5.0 → 1.5.1

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.
@@ -28,6 +28,7 @@ class MusicAllSearchResultParser {
28
28
  client,
29
29
  id,
30
30
  title,
31
+ duration: common_1.getDuration(top.subtitle.runs.at(-1).text),
31
32
  artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
32
33
  album: MusicAllSearchResultParser.parseAlbum(top.subtitle.runs, client),
33
34
  thumbnails: new common_1.Thumbnails().load(thumbnail),
@@ -38,6 +39,7 @@ class MusicAllSearchResultParser {
38
39
  client,
39
40
  id,
40
41
  title,
42
+ duration: common_1.getDuration(top.subtitle.runs.at(-1).text),
41
43
  artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
42
44
  thumbnails: new common_1.Thumbnails().load(thumbnail),
43
45
  });
@@ -64,7 +66,7 @@ class MusicAllSearchResultParser {
64
66
  client,
65
67
  id,
66
68
  title,
67
- channel: MusicAllSearchResultParser.parseChannel(top.subtitle.run, client),
69
+ channel: MusicAllSearchResultParser.parseChannel(top.subtitle.runs, client),
68
70
  thumbnails: new common_1.Thumbnails().load(thumbnail),
69
71
  });
70
72
  }
@@ -87,7 +89,9 @@ class MusicAllSearchResultParser {
87
89
  .map((m) => m.musicShelfRenderer);
88
90
  return shelves.map((m) => ({
89
91
  title: m.title.runs.map((r) => r.text).join(),
90
- items: m.contents.map((c) => MusicAllSearchResultParser.parseSearchItem(c, client)),
92
+ items: m.contents
93
+ .map((c) => MusicAllSearchResultParser.parseSearchItem(c, client))
94
+ .filter((i) => i),
91
95
  }));
92
96
  }
93
97
  static parseSearchItem(content, client) {
@@ -97,21 +101,26 @@ class MusicAllSearchResultParser {
97
101
  if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
98
102
  const pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
99
103
  .watchEndpointMusicConfig.musicVideoType;
100
- if (pageType === "MUSIC_VIDEO_TYPE_PODCAST_EPISODE")
101
- return;
102
104
  return MusicAllSearchResultParser.parseVideoItem(item, pageType, client);
103
105
  }
104
106
  else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
105
107
  return MusicAllSearchResultParser.parsePlaylistItem(item, client);
106
108
  }
107
109
  else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint) {
108
- return MusicAllSearchResultParser.parseAlbumItem(item, client);
110
+ // TODO add podcast support, id starts with PL
111
+ if (playEndpoint.watchPlaylistEndpoint.playlistId.startsWith("OL")) {
112
+ return MusicAllSearchResultParser.parseAlbumItem(item, client);
113
+ }
109
114
  }
110
115
  else {
111
116
  return MusicAllSearchResultParser.parseArtistItem(item, client);
112
117
  }
113
118
  }
114
119
  static parseVideoItem(item, pageType, client) {
120
+ // TODO support other types
121
+ if (!["MUSIC_VIDEO_TYPE_ATV", "MUSIC_VIDEO_TYPE_UGC", "MUSIC_VIDEO_TYPE_OMV"].includes(pageType)) {
122
+ return;
123
+ }
115
124
  const [topColumn, bottomColumn] = item.flexColumns.map((c) => c.musicResponsiveListItemFlexColumnRenderer.text.runs);
116
125
  const id = topColumn[0].navigationEndpoint.watchEndpoint.videoId;
117
126
  const title = topColumn[0].text;
@@ -43,6 +43,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
43
43
  client: client,
44
44
  id: id,
45
45
  title: title,
46
+ duration: getDuration(top.subtitle.runs.at(-1).text),
46
47
  artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
47
48
  album: MusicAllSearchResultParser.parseAlbum(top.subtitle.runs, client),
48
49
  thumbnails: new Thumbnails().load(thumbnail),
@@ -53,6 +54,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
53
54
  client: client,
54
55
  id: id,
55
56
  title: title,
57
+ duration: getDuration(top.subtitle.runs.at(-1).text),
56
58
  artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
57
59
  thumbnails: new Thumbnails().load(thumbnail),
58
60
  });
@@ -79,7 +81,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
79
81
  client: client,
80
82
  id: id,
81
83
  title: title,
82
- channel: MusicAllSearchResultParser.parseChannel(top.subtitle.run, client),
84
+ channel: MusicAllSearchResultParser.parseChannel(top.subtitle.runs, client),
83
85
  thumbnails: new Thumbnails().load(thumbnail),
84
86
  });
85
87
  }
@@ -102,9 +104,9 @@ var MusicAllSearchResultParser = /** @class */ (function () {
102
104
  .map(function (m) { return m.musicShelfRenderer; });
103
105
  return shelves.map(function (m) { return ({
104
106
  title: m.title.runs.map(function (r) { return r.text; }).join(),
105
- items: m.contents.map(function (c) {
106
- return MusicAllSearchResultParser.parseSearchItem(c, client);
107
- }),
107
+ items: m.contents
108
+ .map(function (c) { return MusicAllSearchResultParser.parseSearchItem(c, client); })
109
+ .filter(function (i) { return i; }),
108
110
  }); });
109
111
  };
110
112
  MusicAllSearchResultParser.parseSearchItem = function (content, client) {
@@ -114,21 +116,26 @@ var MusicAllSearchResultParser = /** @class */ (function () {
114
116
  if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
115
117
  var pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
116
118
  .watchEndpointMusicConfig.musicVideoType;
117
- if (pageType === "MUSIC_VIDEO_TYPE_PODCAST_EPISODE")
118
- return;
119
119
  return MusicAllSearchResultParser.parseVideoItem(item, pageType, client);
120
120
  }
121
121
  else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
122
122
  return MusicAllSearchResultParser.parsePlaylistItem(item, client);
123
123
  }
124
124
  else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint) {
125
- return MusicAllSearchResultParser.parseAlbumItem(item, client);
125
+ // TODO add podcast support, id starts with PL
126
+ if (playEndpoint.watchPlaylistEndpoint.playlistId.startsWith("OL")) {
127
+ return MusicAllSearchResultParser.parseAlbumItem(item, client);
128
+ }
126
129
  }
127
130
  else {
128
131
  return MusicAllSearchResultParser.parseArtistItem(item, client);
129
132
  }
130
133
  };
131
134
  MusicAllSearchResultParser.parseVideoItem = function (item, pageType, client) {
135
+ // TODO support other types
136
+ if (!["MUSIC_VIDEO_TYPE_ATV", "MUSIC_VIDEO_TYPE_UGC", "MUSIC_VIDEO_TYPE_OMV"].includes(pageType)) {
137
+ return;
138
+ }
132
139
  var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
133
140
  var id = topColumn[0].navigationEndpoint.watchEndpoint.videoId;
134
141
  var title = topColumn[0].text;
@@ -7,7 +7,7 @@ import { MusicPlaylistCompact } from "../MusicPlaylistCompact";
7
7
  import { MusicSearchResult, MusicSearchType } from "../MusicSearchResult";
8
8
  import { MusicVideoCompact } from "../MusicVideoCompact";
9
9
  export declare type MusicTopShelf = {
10
- item: MusicVideoCompact | MusicAlbumCompact | MusicPlaylistCompact | MusicArtistCompact;
10
+ item?: MusicVideoCompact | MusicAlbumCompact | MusicPlaylistCompact | MusicArtistCompact;
11
11
  more?: (MusicVideoCompact | MusicAlbumCompact | MusicPlaylistCompact | MusicArtistCompact)[];
12
12
  };
13
13
  export declare type MusicClientOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "youtubei",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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",