youtubei 1.7.0 → 1.8.0
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/MusicClient/MusicClient.js +13 -18
- package/dist/cjs/music/MusicSearchResult/MusicSearchResult.js +6 -4
- package/dist/cjs/music/MusicSearchResult/MusicSearchResultParser.js +205 -14
- package/dist/cjs/music/MusicSearchResult/index.js +0 -1
- package/dist/cjs/youtube/BaseChannel/BaseChannel.js +2 -0
- package/dist/cjs/youtube/BaseChannel/BaseChannelParser.js +3 -2
- package/dist/cjs/youtube/BaseChannel/ChannelPlaylists.js +12 -2
- package/dist/cjs/youtube/BaseChannel/ChannelPosts.js +59 -0
- package/dist/cjs/youtube/BaseVideo/BaseVideoParser.js +1 -1
- package/dist/cjs/youtube/Channel/ChannelParser.js +10 -6
- package/dist/cjs/youtube/PlaylistCompact/PlaylistCompactParser.js +3 -3
- package/dist/cjs/youtube/Post/Post.js +23 -0
- package/dist/cjs/youtube/Post/PostParser.js +23 -0
- package/dist/cjs/youtube/Post/index.js +14 -0
- package/dist/esm/music/MusicClient/MusicClient.js +16 -20
- package/dist/esm/music/MusicSearchResult/MusicSearchResult.js +5 -4
- package/dist/esm/music/MusicSearchResult/MusicSearchResultParser.js +221 -14
- package/dist/esm/music/MusicSearchResult/index.js +0 -1
- package/dist/esm/youtube/BaseChannel/BaseChannel.js +2 -0
- package/dist/esm/youtube/BaseChannel/BaseChannelParser.js +3 -2
- package/dist/esm/youtube/BaseChannel/ChannelPlaylists.js +11 -3
- package/dist/esm/youtube/BaseChannel/ChannelPosts.js +111 -0
- package/dist/esm/youtube/BaseVideo/BaseVideoParser.js +1 -1
- package/dist/esm/youtube/Channel/ChannelParser.js +12 -8
- package/dist/esm/youtube/PlaylistCompact/PlaylistCompactParser.js +3 -3
- package/dist/esm/youtube/Post/Post.js +36 -0
- package/dist/esm/youtube/Post/PostParser.js +23 -0
- package/dist/esm/youtube/Post/index.js +2 -0
- package/dist/typings/music/MusicClient/MusicClient.d.ts +3 -7
- package/dist/typings/music/MusicSearchResult/MusicSearchResult.d.ts +7 -4
- package/dist/typings/music/MusicSearchResult/MusicSearchResultParser.d.ts +15 -3
- package/dist/typings/music/MusicSearchResult/index.d.ts +0 -1
- package/dist/typings/youtube/BaseChannel/BaseChannel.d.ts +4 -1
- package/dist/typings/youtube/BaseChannel/BaseChannelParser.d.ts +1 -0
- package/dist/typings/youtube/BaseChannel/ChannelPosts.d.ts +30 -0
- package/dist/typings/youtube/Post/Post.d.ts +32 -0
- package/dist/typings/youtube/Post/PostParser.d.ts +5 -0
- package/dist/typings/youtube/Post/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cjs/music/MusicSearchResult/MusicAllSearchResultParser.js +0 -218
- package/dist/esm/music/MusicSearchResult/MusicAllSearchResultParser.js +0 -234
- package/dist/typings/music/MusicSearchResult/MusicAllSearchResultParser.d.ts +0 -19
|
@@ -125,16 +125,17 @@ var MusicSearchResult = /** @class */ (function (_super) {
|
|
|
125
125
|
case 0:
|
|
126
126
|
this.items = [];
|
|
127
127
|
this.type = type;
|
|
128
|
-
|
|
128
|
+
if (type)
|
|
129
|
+
bufferParams = MusicSearchProto.encode(optionsToProto(type)).finish();
|
|
129
130
|
return [4 /*yield*/, this.client.http.post(I_END_POINT + "/search", {
|
|
130
131
|
data: {
|
|
131
132
|
query: query,
|
|
132
|
-
params: Buffer.from(bufferParams).toString("base64"),
|
|
133
|
+
params: bufferParams ? Buffer.from(bufferParams).toString("base64") : undefined,
|
|
133
134
|
},
|
|
134
135
|
})];
|
|
135
136
|
case 1:
|
|
136
137
|
response = _c.sent();
|
|
137
|
-
_a = MusicSearchResultParser.parseInitialSearchResult(response.data,
|
|
138
|
+
_a = MusicSearchResultParser.parseInitialSearchResult(response.data, this.client), data = _a.data, continuation = _a.continuation;
|
|
138
139
|
(_b = this.items).push.apply(_b, __spread(data));
|
|
139
140
|
this.continuation = continuation;
|
|
140
141
|
return [2 /*return*/, this];
|
|
@@ -159,7 +160,7 @@ var MusicSearchResult = /** @class */ (function (_super) {
|
|
|
159
160
|
})];
|
|
160
161
|
case 1:
|
|
161
162
|
response = _b.sent();
|
|
162
|
-
_a = MusicSearchResultParser.parseContinuationSearchResult(response.data, this.
|
|
163
|
+
_a = MusicSearchResultParser.parseContinuationSearchResult(response.data, this.client), data = _a.data, continuation = _a.continuation;
|
|
163
164
|
return [2 /*return*/, {
|
|
164
165
|
items: data,
|
|
165
166
|
continuation: continuation,
|
|
@@ -9,43 +9,130 @@ var __values = (this && this.__values) || function(o) {
|
|
|
9
9
|
};
|
|
10
10
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
import { getDuration, stripToInt, Thumbnails } from "../../common";
|
|
29
|
+
import { MusicAlbumCompact } from "../MusicAlbumCompact";
|
|
30
|
+
import { MusicArtistCompact } from "../MusicArtistCompact";
|
|
31
|
+
import { MusicBaseArtist } from "../MusicBaseArtist";
|
|
32
|
+
import { MusicBaseChannel } from "../MusicBaseChannel";
|
|
33
|
+
import { MusicPlaylistCompact } from "../MusicPlaylistCompact";
|
|
34
|
+
import { MusicSongCompact } from "../MusicSongCompact";
|
|
35
|
+
import { MusicVideoCompact } from "../MusicVideoCompact";
|
|
13
36
|
var MusicSearchResultParser = /** @class */ (function () {
|
|
14
37
|
function MusicSearchResultParser() {
|
|
15
38
|
}
|
|
16
|
-
MusicSearchResultParser.parseInitialSearchResult = function (data,
|
|
39
|
+
MusicSearchResultParser.parseInitialSearchResult = function (data, client) {
|
|
17
40
|
var _a, _b;
|
|
18
|
-
var
|
|
19
|
-
|
|
41
|
+
var sectionContents = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content
|
|
42
|
+
.sectionListRenderer.contents;
|
|
43
|
+
var topContent = sectionContents.find(function (c) { return "musicCardShelfRenderer" in c; });
|
|
44
|
+
var resultContents = sectionContents.find(function (c) { return "musicShelfRenderer" in c; });
|
|
45
|
+
var topResult = this.parseTopResult(topContent, client);
|
|
46
|
+
if (!resultContents) {
|
|
20
47
|
// no results
|
|
21
48
|
return {
|
|
22
|
-
data: [],
|
|
49
|
+
data: topResult ? [topResult] : [],
|
|
23
50
|
continuation: undefined,
|
|
24
51
|
};
|
|
25
52
|
}
|
|
26
|
-
var _c =
|
|
53
|
+
var _c = resultContents.musicShelfRenderer, contents = _c.contents, continuations = _c.continuations;
|
|
54
|
+
var result = MusicSearchResultParser.parseSearchResult(contents, client);
|
|
55
|
+
if (topResult)
|
|
56
|
+
result.unshift(topResult);
|
|
27
57
|
return {
|
|
28
|
-
data:
|
|
58
|
+
data: result,
|
|
29
59
|
continuation: (_b = (_a = continuations === null || continuations === void 0 ? void 0 : continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
|
|
30
60
|
};
|
|
31
61
|
};
|
|
32
|
-
MusicSearchResultParser.parseContinuationSearchResult = function (data,
|
|
62
|
+
MusicSearchResultParser.parseContinuationSearchResult = function (data, client) {
|
|
33
63
|
var shelf = data.continuationContents.musicShelfContinuation;
|
|
34
64
|
return {
|
|
35
|
-
data: MusicSearchResultParser.parseSearchResult(shelf.contents,
|
|
65
|
+
data: MusicSearchResultParser.parseSearchResult(shelf.contents, client),
|
|
36
66
|
continuation: shelf.continuations[0].nextContinuationData.continuation,
|
|
37
67
|
};
|
|
38
68
|
};
|
|
39
|
-
MusicSearchResultParser.
|
|
69
|
+
MusicSearchResultParser.parseTopResult = function (data, client) {
|
|
70
|
+
var top = data === null || data === void 0 ? void 0 : data.musicCardShelfRenderer;
|
|
71
|
+
if (!top)
|
|
72
|
+
return;
|
|
73
|
+
var _a = top.title.runs[0].navigationEndpoint, browseEndpoint = _a.browseEndpoint, watchEndpoint = _a.watchEndpoint;
|
|
74
|
+
var id = (watchEndpoint === null || watchEndpoint === void 0 ? void 0 : watchEndpoint.videoId) || (browseEndpoint === null || browseEndpoint === void 0 ? void 0 : browseEndpoint.browseId);
|
|
75
|
+
var type = (watchEndpoint === null || watchEndpoint === void 0 ? void 0 : watchEndpoint.watchEndpointMusicSupportedConfigs.watchEndpointMusicConfig.musicVideoType) || (browseEndpoint === null || browseEndpoint === void 0 ? void 0 : browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType);
|
|
76
|
+
var title = top.title.runs[0].text;
|
|
77
|
+
var thumbnail = top.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails;
|
|
78
|
+
var topResult;
|
|
79
|
+
if (type === "MUSIC_VIDEO_TYPE_ATV") {
|
|
80
|
+
topResult = new MusicSongCompact({
|
|
81
|
+
client: client,
|
|
82
|
+
id: id,
|
|
83
|
+
title: title,
|
|
84
|
+
duration: getDuration(top.subtitle.runs.at(-1).text),
|
|
85
|
+
artists: this.parseArtists(top.subtitle.runs, client),
|
|
86
|
+
album: this.parseAlbum(top.subtitle.runs, client),
|
|
87
|
+
thumbnails: new Thumbnails().load(thumbnail),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else if (type === "MUSIC_VIDEO_TYPE_UGC" || type === "MUSIC_VIDEO_TYPE_OMV") {
|
|
91
|
+
topResult = new MusicVideoCompact({
|
|
92
|
+
client: client,
|
|
93
|
+
id: id,
|
|
94
|
+
title: title,
|
|
95
|
+
duration: getDuration(top.subtitle.runs.at(-1).text),
|
|
96
|
+
artists: this.parseArtists(top.subtitle.runs, client),
|
|
97
|
+
thumbnails: new Thumbnails().load(thumbnail),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else if (type === "MUSIC_PAGE_TYPE_ALBUM") {
|
|
101
|
+
topResult = new MusicAlbumCompact({
|
|
102
|
+
client: client,
|
|
103
|
+
id: id,
|
|
104
|
+
title: title,
|
|
105
|
+
artists: this.parseArtists(top.subtitle.runs, client),
|
|
106
|
+
thumbnails: new Thumbnails().load(thumbnail),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else if (type === "MUSIC_PAGE_TYPE_ARTIST") {
|
|
110
|
+
topResult = new MusicArtistCompact({
|
|
111
|
+
client: client,
|
|
112
|
+
id: id,
|
|
113
|
+
name: title,
|
|
114
|
+
thumbnails: new Thumbnails().load(thumbnail),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else if (type === "MUSIC_PAGE_TYPE_PLAYLIST") {
|
|
118
|
+
topResult = new MusicPlaylistCompact({
|
|
119
|
+
client: client,
|
|
120
|
+
id: id,
|
|
121
|
+
title: title,
|
|
122
|
+
channel: this.parseChannel(top.subtitle.runs, client),
|
|
123
|
+
thumbnails: new Thumbnails().load(thumbnail),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return topResult;
|
|
127
|
+
};
|
|
128
|
+
MusicSearchResultParser.parseSearchResult = function (shelfContents, client) {
|
|
40
129
|
var e_1, _a;
|
|
41
|
-
var rawContents = shelfContents
|
|
42
|
-
.filter(function (c) { return "musicResponsiveListItemRenderer" in c; })
|
|
43
|
-
.map(function (c) { return c.musicResponsiveListItemRenderer; });
|
|
130
|
+
var rawContents = shelfContents.filter(function (c) { return "musicResponsiveListItemRenderer" in c; });
|
|
44
131
|
var contents = [];
|
|
45
132
|
try {
|
|
46
133
|
for (var rawContents_1 = __values(rawContents), rawContents_1_1 = rawContents_1.next(); !rawContents_1_1.done; rawContents_1_1 = rawContents_1.next()) {
|
|
47
134
|
var c = rawContents_1_1.value;
|
|
48
|
-
var parsed =
|
|
135
|
+
var parsed = this.parseSearchItem(c, client);
|
|
49
136
|
if (parsed)
|
|
50
137
|
contents.push(parsed);
|
|
51
138
|
}
|
|
@@ -59,6 +146,126 @@ var MusicSearchResultParser = /** @class */ (function () {
|
|
|
59
146
|
}
|
|
60
147
|
return contents;
|
|
61
148
|
};
|
|
149
|
+
MusicSearchResultParser.parseSearchItem = function (content, client) {
|
|
150
|
+
var _a;
|
|
151
|
+
var item = content.musicResponsiveListItemRenderer;
|
|
152
|
+
var playEndpoint = (_a = item.overlay) === null || _a === void 0 ? void 0 : _a.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer.playNavigationEndpoint;
|
|
153
|
+
if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
|
|
154
|
+
var pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
|
|
155
|
+
.watchEndpointMusicConfig.musicVideoType;
|
|
156
|
+
return this.parseVideoItem(item, pageType, client);
|
|
157
|
+
}
|
|
158
|
+
else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
|
|
159
|
+
return this.parsePlaylistItem(item, client);
|
|
160
|
+
}
|
|
161
|
+
else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint) {
|
|
162
|
+
// TODO add podcast support, id starts with PL
|
|
163
|
+
if (playEndpoint.watchPlaylistEndpoint.playlistId.startsWith("OL")) {
|
|
164
|
+
return this.parseAlbumItem(item, client);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return this.parseArtistItem(item, client);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
MusicSearchResultParser.parseVideoItem = function (item, pageType, client) {
|
|
172
|
+
// TODO support other types
|
|
173
|
+
if (!["MUSIC_VIDEO_TYPE_ATV", "MUSIC_VIDEO_TYPE_UGC", "MUSIC_VIDEO_TYPE_OMV"].includes(pageType)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
|
|
177
|
+
var id = topColumn[0].navigationEndpoint.watchEndpoint.videoId;
|
|
178
|
+
var title = topColumn[0].text;
|
|
179
|
+
var duration = getDuration(bottomColumn.at(-1).text) || undefined;
|
|
180
|
+
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
181
|
+
var artists = this.parseArtists(bottomColumn, client);
|
|
182
|
+
if (pageType === "MUSIC_VIDEO_TYPE_ATV") {
|
|
183
|
+
return new MusicSongCompact({
|
|
184
|
+
client: client,
|
|
185
|
+
id: id,
|
|
186
|
+
album: this.parseAlbum(bottomColumn, client),
|
|
187
|
+
title: title,
|
|
188
|
+
artists: artists,
|
|
189
|
+
thumbnails: thumbnails,
|
|
190
|
+
duration: duration,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else if (pageType === "MUSIC_VIDEO_TYPE_UGC" || pageType === "MUSIC_VIDEO_TYPE_OMV") {
|
|
194
|
+
return new MusicVideoCompact({ client: client, id: id, title: title, artists: artists, thumbnails: thumbnails, duration: duration });
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
MusicSearchResultParser.parsePlaylistItem = function (item, client) {
|
|
198
|
+
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
|
|
199
|
+
var id = item.overlay.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer
|
|
200
|
+
.playNavigationEndpoint.watchPlaylistEndpoint.playlistId;
|
|
201
|
+
var title = topColumn[0].text;
|
|
202
|
+
var songCount = stripToInt(bottomColumn.at(-1).text) || undefined;
|
|
203
|
+
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
204
|
+
var channel = this.parseChannel(bottomColumn, client);
|
|
205
|
+
return new MusicPlaylistCompact({ client: client, id: id, title: title, thumbnails: thumbnails, songCount: songCount, channel: channel });
|
|
206
|
+
};
|
|
207
|
+
MusicSearchResultParser.parseAlbumItem = function (item, client) {
|
|
208
|
+
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
|
|
209
|
+
var id = item.overlay.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer
|
|
210
|
+
.playNavigationEndpoint.watchPlaylistEndpoint.playlistId;
|
|
211
|
+
var title = topColumn[0].text;
|
|
212
|
+
var year = stripToInt(bottomColumn.at(-1).text) || undefined;
|
|
213
|
+
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
214
|
+
var artists = this.parseArtists(bottomColumn, client);
|
|
215
|
+
return new MusicAlbumCompact({ client: client, id: id, title: title, thumbnails: thumbnails, artists: artists, year: year });
|
|
216
|
+
};
|
|
217
|
+
MusicSearchResultParser.parseArtistItem = function (item, client) {
|
|
218
|
+
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 1), topColumn = _a[0];
|
|
219
|
+
var id = item.navigationEndpoint.browseEndpoint.browseId;
|
|
220
|
+
var name = topColumn[0].text;
|
|
221
|
+
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
222
|
+
return new MusicArtistCompact({ client: client, id: id, name: name, thumbnails: thumbnails });
|
|
223
|
+
};
|
|
224
|
+
MusicSearchResultParser.parseAlbum = function (items, client) {
|
|
225
|
+
var _a;
|
|
226
|
+
var albumRaw = items.find(function (r) {
|
|
227
|
+
var _a;
|
|
228
|
+
var pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
229
|
+
return pageType === "MUSIC_PAGE_TYPE_ALBUM";
|
|
230
|
+
});
|
|
231
|
+
if (!albumRaw)
|
|
232
|
+
return;
|
|
233
|
+
var album = new MusicAlbumCompact({
|
|
234
|
+
client: client,
|
|
235
|
+
title: albumRaw.text,
|
|
236
|
+
id: (_a = albumRaw.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
237
|
+
});
|
|
238
|
+
return album;
|
|
239
|
+
};
|
|
240
|
+
MusicSearchResultParser.parseArtists = function (items, client) {
|
|
241
|
+
return this.parseArtistsOrChannel(items).map(function (r) {
|
|
242
|
+
var _a;
|
|
243
|
+
return new MusicBaseArtist({
|
|
244
|
+
client: client,
|
|
245
|
+
name: r.text,
|
|
246
|
+
id: (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
MusicSearchResultParser.parseChannel = function (items, client) {
|
|
251
|
+
var _a;
|
|
252
|
+
var _b = __read(this.parseArtistsOrChannel(items), 1), channelRaw = _b[0];
|
|
253
|
+
if (!channelRaw)
|
|
254
|
+
return;
|
|
255
|
+
var channel = new MusicBaseChannel({
|
|
256
|
+
client: client,
|
|
257
|
+
name: channelRaw.text,
|
|
258
|
+
id: (_a = channelRaw.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
259
|
+
});
|
|
260
|
+
return channel;
|
|
261
|
+
};
|
|
262
|
+
MusicSearchResultParser.parseArtistsOrChannel = function (items) {
|
|
263
|
+
return items.filter(function (i) {
|
|
264
|
+
var _a;
|
|
265
|
+
var pageType = (_a = i.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
266
|
+
return (pageType === "MUSIC_PAGE_TYPE_ARTIST" || pageType == "MUSIC_PAGE_TYPE_USER_CHANNEL");
|
|
267
|
+
});
|
|
268
|
+
};
|
|
62
269
|
return MusicSearchResultParser;
|
|
63
270
|
}());
|
|
64
271
|
export { MusicSearchResultParser };
|
|
@@ -15,6 +15,7 @@ import { Base } from "../Base";
|
|
|
15
15
|
import { BaseChannelParser } from "./BaseChannelParser";
|
|
16
16
|
import { ChannelLive } from "./ChannelLive";
|
|
17
17
|
import { ChannelPlaylists } from "./ChannelPlaylists";
|
|
18
|
+
import { ChannelPosts } from "./ChannelPosts";
|
|
18
19
|
import { ChannelShorts } from "./ChannelShorts";
|
|
19
20
|
import { ChannelVideos } from "./ChannelVideos";
|
|
20
21
|
/** Represents a Youtube Channel */
|
|
@@ -28,6 +29,7 @@ var BaseChannel = /** @class */ (function (_super) {
|
|
|
28
29
|
_this.shorts = new ChannelShorts({ channel: _this, client: _this.client });
|
|
29
30
|
_this.live = new ChannelLive({ channel: _this, client: _this.client });
|
|
30
31
|
_this.playlists = new ChannelPlaylists({ channel: _this, client: _this.client });
|
|
32
|
+
_this.posts = new ChannelPosts({ channel: _this, client: _this.client });
|
|
31
33
|
return _this;
|
|
32
34
|
}
|
|
33
35
|
Object.defineProperty(BaseChannel.prototype, "url", {
|
|
@@ -12,13 +12,13 @@ var BaseChannelParser = /** @class */ (function () {
|
|
|
12
12
|
};
|
|
13
13
|
/** Parse tab data from request, tab name is ignored if it's a continuation data */
|
|
14
14
|
BaseChannelParser.parseTabData = function (name, data) {
|
|
15
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
16
16
|
var tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find(function (t) {
|
|
17
17
|
var _a;
|
|
18
18
|
return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
|
|
19
19
|
BaseChannelParser.TAB_TYPE_PARAMS[name]);
|
|
20
20
|
});
|
|
21
|
-
return (((_d = (_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c[0].itemSectionRenderer.contents[0].gridRenderer) === null || _d === void 0 ? void 0 : _d.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((
|
|
21
|
+
return (((_d = (_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c[0].itemSectionRenderer.contents[0].gridRenderer) === null || _d === void 0 ? void 0 : _d.items) || ((_h = (_g = (_f = (_e = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content) === null || _e === void 0 ? void 0 : _e.sectionListRenderer) === null || _f === void 0 ? void 0 : _f.contents) === null || _g === void 0 ? void 0 : _g[0].itemSectionRenderer) === null || _h === void 0 ? void 0 : _h.contents) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_j = data.onResponseReceivedActions) === null || _j === void 0 ? void 0 : _j[0].appendContinuationItemsAction.continuationItems.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_k = data.onResponseReceivedEndpoints) === null || _k === void 0 ? void 0 : _k[0].appendContinuationItemsAction.continuationItems) ||
|
|
22
22
|
[]);
|
|
23
23
|
};
|
|
24
24
|
BaseChannelParser.TAB_TYPE_PARAMS = {
|
|
@@ -26,6 +26,7 @@ var BaseChannelParser = /** @class */ (function () {
|
|
|
26
26
|
shorts: "EgZzaG9ydHPyBgUKA5oBAA%3D%3D",
|
|
27
27
|
live: "EgdzdHJlYW1z8gYECgJ6AA%3D%3D",
|
|
28
28
|
playlists: "EglwbGF5bGlzdHPyBgQKAkIA",
|
|
29
|
+
posts: "EgVwb3N0c_IGBAoCSgA%3D",
|
|
29
30
|
};
|
|
30
31
|
return BaseChannelParser;
|
|
31
32
|
}());
|
|
@@ -47,7 +47,7 @@ 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
|
|
50
|
+
import { getContinuationFromItems } from "../../common";
|
|
51
51
|
import { Continuable } from "../Continuable";
|
|
52
52
|
import { PlaylistCompact } from "../PlaylistCompact";
|
|
53
53
|
import { I_END_POINT } from "../constants";
|
|
@@ -93,11 +93,19 @@ var ChannelPlaylists = /** @class */ (function (_super) {
|
|
|
93
93
|
response = _b.sent();
|
|
94
94
|
items = BaseChannelParser.parseTabData("playlists", response.data);
|
|
95
95
|
continuation = getContinuationFromItems(items);
|
|
96
|
-
data =
|
|
96
|
+
data = items.filter(function (i) { return "gridPlaylistRenderer" in i || "lockupViewModel" in i; });
|
|
97
97
|
return [2 /*return*/, {
|
|
98
98
|
continuation: continuation,
|
|
99
99
|
items: data.map(function (i) {
|
|
100
|
-
|
|
100
|
+
var playlist = new PlaylistCompact({
|
|
101
|
+
client: _this.client,
|
|
102
|
+
channel: _this.channel,
|
|
103
|
+
});
|
|
104
|
+
if (i.gridPlaylistRenderer)
|
|
105
|
+
playlist.load(i.gridPlaylistRenderer);
|
|
106
|
+
else if (i.lockupViewModel)
|
|
107
|
+
playlist.loadLockup(i.lockupViewModel);
|
|
108
|
+
return playlist;
|
|
101
109
|
}),
|
|
102
110
|
}];
|
|
103
111
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (_) try {
|
|
30
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
import { getContinuationFromItems } from "../../common";
|
|
51
|
+
import { Continuable } from "../Continuable";
|
|
52
|
+
import { Post } from "../Post";
|
|
53
|
+
import { I_END_POINT } from "../constants";
|
|
54
|
+
import { BaseChannelParser } from "./BaseChannelParser";
|
|
55
|
+
/**
|
|
56
|
+
* {@link Continuable} of posts inside a {@link BaseChannel}
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```js
|
|
60
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
61
|
+
* await channel.posts.next();
|
|
62
|
+
* console.log(channel.posts.items) // first 30 posts
|
|
63
|
+
*
|
|
64
|
+
* let newPosts = await channel.posts.next();
|
|
65
|
+
* console.log(newPosts) // 30 loaded posts
|
|
66
|
+
* console.log(channel.posts.items) // first 60 posts
|
|
67
|
+
*
|
|
68
|
+
* await channel.posts.next(0); // load the rest of the posts in the channel
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
var ChannelPosts = /** @class */ (function (_super) {
|
|
72
|
+
__extends(ChannelPosts, _super);
|
|
73
|
+
/** @hidden */
|
|
74
|
+
function ChannelPosts(_a) {
|
|
75
|
+
var client = _a.client, channel = _a.channel;
|
|
76
|
+
var _this = _super.call(this, { client: client, strictContinuationCheck: true }) || this;
|
|
77
|
+
_this.channel = channel;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
ChannelPosts.prototype.fetch = function () {
|
|
81
|
+
var _a;
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var params, response, items, continuation, data;
|
|
84
|
+
var _this = this;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
params = BaseChannelParser.TAB_TYPE_PARAMS.posts;
|
|
89
|
+
return [4 /*yield*/, this.client.http.post(I_END_POINT + "/browse", {
|
|
90
|
+
data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params: params, continuation: this.continuation },
|
|
91
|
+
})];
|
|
92
|
+
case 1:
|
|
93
|
+
response = _b.sent();
|
|
94
|
+
items = BaseChannelParser.parseTabData("posts", response.data);
|
|
95
|
+
continuation = getContinuationFromItems(items);
|
|
96
|
+
data = items
|
|
97
|
+
.map(function (i) { var _a, _b; return (_b = (_a = i.backstagePostThreadRenderer) === null || _a === void 0 ? void 0 : _a.post) === null || _b === void 0 ? void 0 : _b.backstagePostRenderer; })
|
|
98
|
+
.filter(function (i) { return i !== undefined; });
|
|
99
|
+
return [2 /*return*/, {
|
|
100
|
+
continuation: continuation,
|
|
101
|
+
items: data.map(function (i) {
|
|
102
|
+
return new Post({ client: _this.client, channel: _this.channel }).load(i);
|
|
103
|
+
}),
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return ChannelPosts;
|
|
110
|
+
}(Continuable));
|
|
111
|
+
export { ChannelPosts };
|
|
@@ -47,7 +47,7 @@ var BaseVideoParser = /** @class */ (function () {
|
|
|
47
47
|
target.description = videoInfo.videoDetails.shortDescription || "";
|
|
48
48
|
// related videos
|
|
49
49
|
var secondaryContents = (_c = data.response.contents.twoColumnWatchNextResults.secondaryResults) === null || _c === void 0 ? void 0 : _c.secondaryResults.results;
|
|
50
|
-
var itemSectionRenderer = (_d = secondaryContents.find(function (c) {
|
|
50
|
+
var itemSectionRenderer = (_d = secondaryContents === null || secondaryContents === void 0 ? void 0 : secondaryContents.find(function (c) {
|
|
51
51
|
return c.itemSectionRenderer;
|
|
52
52
|
})) === null || _d === void 0 ? void 0 : _d.itemSectionRenderer;
|
|
53
53
|
if (itemSectionRenderer)
|
|
@@ -17,9 +17,9 @@ var ChannelParser = /** @class */ (function () {
|
|
|
17
17
|
function ChannelParser() {
|
|
18
18
|
}
|
|
19
19
|
ChannelParser.loadChannel = function (target, data) {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
21
|
var channelId, title, handle, description, avatar, subscriberCountText, videoCountText, tvBanner, mobileBanner, banner;
|
|
22
|
-
var
|
|
22
|
+
var _k = data.header, c4TabbedHeaderRenderer = _k.c4TabbedHeaderRenderer, pageHeaderRenderer = _k.pageHeaderRenderer;
|
|
23
23
|
if (c4TabbedHeaderRenderer) {
|
|
24
24
|
channelId = c4TabbedHeaderRenderer.channelId;
|
|
25
25
|
title = c4TabbedHeaderRenderer.title;
|
|
@@ -35,12 +35,16 @@ var ChannelParser = /** @class */ (function () {
|
|
|
35
35
|
data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.endpoint
|
|
36
36
|
.browseEndpoint.browseId;
|
|
37
37
|
title = pageHeaderRenderer.pageTitle;
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
var _l = pageHeaderRenderer.content.pageHeaderViewModel, metadata = _l.metadata, imageModel = _l.image, bannerModel = _l.banner, descriptionModel = _l.description;
|
|
39
|
+
var metadataParts = metadata.contentMetadataViewModel.metadataRows
|
|
40
|
+
.map(function (m) { return m.metadataParts; })
|
|
41
|
+
.flat();
|
|
42
|
+
var handlePart = metadataParts.find(function (m) { var _a; return (_a = m.text.styleRuns) === null || _a === void 0 ? void 0 : _a.some(function (s) { return "weightLabel" in s; }); });
|
|
43
|
+
var subscriberCountPart = metadataParts.find(function (m) { return m.accessibilityLabel; });
|
|
44
|
+
var videoCountPart = metadataParts.find(function (m) { var _a; return (_a = m.text.styleRuns) === null || _a === void 0 ? void 0 : _a.some(function (s) { return "startIndex" in s; }); });
|
|
45
|
+
handle = (_j = handlePart === null || handlePart === void 0 ? void 0 : handlePart.text) === null || _j === void 0 ? void 0 : _j.content;
|
|
46
|
+
videoCountText = videoCountPart === null || videoCountPart === void 0 ? void 0 : videoCountPart.text.content;
|
|
47
|
+
subscriberCountText = subscriberCountPart === null || subscriberCountPart === void 0 ? void 0 : subscriberCountPart.text.content;
|
|
44
48
|
avatar = imageModel.decoratedAvatarViewModel.avatar.avatarViewModel.image.sources;
|
|
45
49
|
banner = bannerModel === null || bannerModel === void 0 ? void 0 : bannerModel.imageBannerViewModel.image.sources;
|
|
46
50
|
description = descriptionModel === null || descriptionModel === void 0 ? void 0 : descriptionModel.descriptionPreviewViewModel.description.content;
|
|
@@ -23,11 +23,11 @@ var PlaylistCompactParser = /** @class */ (function () {
|
|
|
23
23
|
return target;
|
|
24
24
|
};
|
|
25
25
|
PlaylistCompactParser.loadLockupPlaylistCompact = function (target, data) {
|
|
26
|
+
var _a;
|
|
26
27
|
var lockupMetadataViewModel = data.metadata.lockupMetadataViewModel;
|
|
27
|
-
var channelMetadata = lockupMetadataViewModel.metadata.contentMetadataViewModel.metadataRows[0]
|
|
28
|
-
.metadataParts[0];
|
|
28
|
+
var channelMetadata = (_a = lockupMetadataViewModel.metadata.contentMetadataViewModel.metadataRows) === null || _a === void 0 ? void 0 : _a[0].metadataParts[0];
|
|
29
29
|
var thumbnailViewModel = data.contentImage.collectionThumbnailViewModel.primaryThumbnail.thumbnailViewModel;
|
|
30
|
-
if (channelMetadata.text.commandRuns) {
|
|
30
|
+
if (channelMetadata === null || channelMetadata === void 0 ? void 0 : channelMetadata.text.commandRuns) {
|
|
31
31
|
// not a mix
|
|
32
32
|
var channel = new BaseChannel({
|
|
33
33
|
client: target.client,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
import { Base } from "../Base";
|
|
15
|
+
import { PostParser } from "./PostParser";
|
|
16
|
+
/** Represents a chat in a live stream */
|
|
17
|
+
var Post = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Post, _super);
|
|
19
|
+
/** @hidden */
|
|
20
|
+
function Post(attr) {
|
|
21
|
+
var _this = _super.call(this, attr.client) || this;
|
|
22
|
+
Object.assign(_this, attr);
|
|
23
|
+
return _this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Load this instance with raw data from Youtube
|
|
27
|
+
*
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
Post.prototype.load = function (data) {
|
|
31
|
+
PostParser.loadPost(this, data);
|
|
32
|
+
return this;
|
|
33
|
+
};
|
|
34
|
+
return Post;
|
|
35
|
+
}(Base));
|
|
36
|
+
export { Post };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseChannel } from "../BaseChannel";
|
|
2
|
+
var PostParser = /** @class */ (function () {
|
|
3
|
+
function PostParser() {
|
|
4
|
+
}
|
|
5
|
+
PostParser.loadPost = function (target, data) {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
var postId = data.postId, authorText = data.authorText, authorThumbnail = data.authorThumbnail, authorEndpoint = data.authorEndpoint, contentText = data.contentText, publishedTimeText = data.publishedTimeText, voteCount = data.voteCount;
|
|
8
|
+
// Basic information
|
|
9
|
+
target.id = postId;
|
|
10
|
+
target.content = (_a = contentText === null || contentText === void 0 ? void 0 : contentText.runs) === null || _a === void 0 ? void 0 : _a.map(function (r) { return r.text; }).join("");
|
|
11
|
+
target.channel = new BaseChannel({
|
|
12
|
+
id: (_b = authorEndpoint === null || authorEndpoint === void 0 ? void 0 : authorEndpoint.browseEndpoint) === null || _b === void 0 ? void 0 : _b.browseId,
|
|
13
|
+
name: (_c = authorText.runs) === null || _c === void 0 ? void 0 : _c[0].text,
|
|
14
|
+
thumbnails: authorThumbnail.thumbnails,
|
|
15
|
+
client: target.client,
|
|
16
|
+
});
|
|
17
|
+
target.timestamp = (_d = publishedTimeText.runs[0]) === null || _d === void 0 ? void 0 : _d.text;
|
|
18
|
+
target.voteCount = voteCount.simpleText;
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
return PostParser;
|
|
22
|
+
}());
|
|
23
|
+
export { PostParser };
|