youtubei 1.5.0 → 1.5.2
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.
- package/dist/cjs/music/MusicSearchResult/MusicAllSearchResultParser.js +23 -17
- package/dist/esm/music/MusicSearchResult/MusicAllSearchResultParser.js +23 -19
- package/dist/typings/music/MusicClient/MusicClient.d.ts +1 -1
- package/dist/typings/music/MusicSearchResult/MusicAllSearchResultParser.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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.
|
|
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
|
|
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
|
-
|
|
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;
|
|
@@ -177,13 +186,7 @@ class MusicAllSearchResultParser {
|
|
|
177
186
|
return album;
|
|
178
187
|
}
|
|
179
188
|
static parseArtists(items, client) {
|
|
180
|
-
return items
|
|
181
|
-
.filter((r) => {
|
|
182
|
-
var _a;
|
|
183
|
-
const pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
184
|
-
return pageType === "MUSIC_PAGE_TYPE_ARTIST";
|
|
185
|
-
})
|
|
186
|
-
.map((r) => {
|
|
189
|
+
return this.parseArtistsOrChannel(items).map((r) => {
|
|
187
190
|
var _a;
|
|
188
191
|
return new MusicBaseArtist_1.MusicBaseArtist({
|
|
189
192
|
client,
|
|
@@ -194,11 +197,7 @@ class MusicAllSearchResultParser {
|
|
|
194
197
|
}
|
|
195
198
|
static parseChannel(items, client) {
|
|
196
199
|
var _a;
|
|
197
|
-
const channelRaw =
|
|
198
|
-
var _a;
|
|
199
|
-
const pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
200
|
-
return pageType === "MUSIC_PAGE_TYPE_USER_CHANNEL";
|
|
201
|
-
});
|
|
200
|
+
const [channelRaw] = this.parseArtistsOrChannel(items);
|
|
202
201
|
if (!channelRaw)
|
|
203
202
|
return;
|
|
204
203
|
const channel = new MusicBaseChannel_1.MusicBaseChannel({
|
|
@@ -208,5 +207,12 @@ class MusicAllSearchResultParser {
|
|
|
208
207
|
});
|
|
209
208
|
return channel;
|
|
210
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
|
+
}
|
|
211
217
|
}
|
|
212
218
|
exports.MusicAllSearchResultParser = MusicAllSearchResultParser;
|
|
@@ -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.
|
|
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
|
|
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
|
-
|
|
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;
|
|
@@ -194,13 +201,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
|
|
|
194
201
|
return album;
|
|
195
202
|
};
|
|
196
203
|
MusicAllSearchResultParser.parseArtists = function (items, client) {
|
|
197
|
-
return items
|
|
198
|
-
.filter(function (r) {
|
|
199
|
-
var _a;
|
|
200
|
-
var pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
201
|
-
return pageType === "MUSIC_PAGE_TYPE_ARTIST";
|
|
202
|
-
})
|
|
203
|
-
.map(function (r) {
|
|
204
|
+
return this.parseArtistsOrChannel(items).map(function (r) {
|
|
204
205
|
var _a;
|
|
205
206
|
return new MusicBaseArtist({
|
|
206
207
|
client: client,
|
|
@@ -211,11 +212,7 @@ var MusicAllSearchResultParser = /** @class */ (function () {
|
|
|
211
212
|
};
|
|
212
213
|
MusicAllSearchResultParser.parseChannel = function (items, client) {
|
|
213
214
|
var _a;
|
|
214
|
-
var
|
|
215
|
-
var _a;
|
|
216
|
-
var pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
217
|
-
return pageType === "MUSIC_PAGE_TYPE_USER_CHANNEL";
|
|
218
|
-
});
|
|
215
|
+
var _b = __read(this.parseArtistsOrChannel(items), 1), channelRaw = _b[0];
|
|
219
216
|
if (!channelRaw)
|
|
220
217
|
return;
|
|
221
218
|
var channel = new MusicBaseChannel({
|
|
@@ -225,6 +222,13 @@ var MusicAllSearchResultParser = /** @class */ (function () {
|
|
|
225
222
|
});
|
|
226
223
|
return channel;
|
|
227
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
|
+
};
|
|
228
232
|
return MusicAllSearchResultParser;
|
|
229
233
|
}());
|
|
230
234
|
export { MusicAllSearchResultParser };
|
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "1.5.2",
|
|
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",
|