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
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
import { getDuration, stripToInt, Thumbnails } from "../../common";
|
|
18
|
-
import { MusicAlbumCompact } from "../MusicAlbumCompact";
|
|
19
|
-
import { MusicArtistCompact } from "../MusicArtistCompact";
|
|
20
|
-
import { MusicBaseArtist } from "../MusicBaseArtist";
|
|
21
|
-
import { MusicBaseChannel } from "../MusicBaseChannel";
|
|
22
|
-
import { MusicPlaylistCompact } from "../MusicPlaylistCompact";
|
|
23
|
-
import { MusicSongCompact } from "../MusicSongCompact";
|
|
24
|
-
import { MusicVideoCompact } from "../MusicVideoCompact";
|
|
25
|
-
var MusicAllSearchResultParser = /** @class */ (function () {
|
|
26
|
-
function MusicAllSearchResultParser() {
|
|
27
|
-
}
|
|
28
|
-
MusicAllSearchResultParser.parseTopResult = function (data, client) {
|
|
29
|
-
var _a;
|
|
30
|
-
var sectionListContents = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content
|
|
31
|
-
.sectionListRenderer.contents;
|
|
32
|
-
var top = (_a = sectionListContents.find(function (f) { return f.musicCardShelfRenderer; })) === null || _a === void 0 ? void 0 : _a.musicCardShelfRenderer;
|
|
33
|
-
if (!top)
|
|
34
|
-
return;
|
|
35
|
-
var _b = top.title.runs[0].navigationEndpoint, browseEndpoint = _b.browseEndpoint, watchEndpoint = _b.watchEndpoint;
|
|
36
|
-
var id = (watchEndpoint === null || watchEndpoint === void 0 ? void 0 : watchEndpoint.videoId) || (browseEndpoint === null || browseEndpoint === void 0 ? void 0 : browseEndpoint.browseId);
|
|
37
|
-
var type = (watchEndpoint === null || watchEndpoint === void 0 ? void 0 : watchEndpoint.watchEndpointMusicSupportedConfigs.watchEndpointMusicConfig.musicVideoType) || (browseEndpoint === null || browseEndpoint === void 0 ? void 0 : browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType);
|
|
38
|
-
var title = top.title.runs[0].text;
|
|
39
|
-
var thumbnail = top.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails;
|
|
40
|
-
var topResult;
|
|
41
|
-
if (type === "MUSIC_VIDEO_TYPE_ATV") {
|
|
42
|
-
topResult = new MusicSongCompact({
|
|
43
|
-
client: client,
|
|
44
|
-
id: id,
|
|
45
|
-
title: title,
|
|
46
|
-
duration: getDuration(top.subtitle.runs.at(-1).text),
|
|
47
|
-
artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
|
|
48
|
-
album: MusicAllSearchResultParser.parseAlbum(top.subtitle.runs, client),
|
|
49
|
-
thumbnails: new Thumbnails().load(thumbnail),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
else if (type === "MUSIC_VIDEO_TYPE_UGC" || type === "MUSIC_VIDEO_TYPE_OMV") {
|
|
53
|
-
topResult = new MusicVideoCompact({
|
|
54
|
-
client: client,
|
|
55
|
-
id: id,
|
|
56
|
-
title: title,
|
|
57
|
-
duration: getDuration(top.subtitle.runs.at(-1).text),
|
|
58
|
-
artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
|
|
59
|
-
thumbnails: new Thumbnails().load(thumbnail),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
else if (type === "MUSIC_PAGE_TYPE_ALBUM") {
|
|
63
|
-
topResult = new MusicAlbumCompact({
|
|
64
|
-
client: client,
|
|
65
|
-
id: id,
|
|
66
|
-
title: title,
|
|
67
|
-
artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
|
|
68
|
-
thumbnails: new Thumbnails().load(thumbnail),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else if (type === "MUSIC_PAGE_TYPE_ARTIST") {
|
|
72
|
-
topResult = new MusicArtistCompact({
|
|
73
|
-
client: client,
|
|
74
|
-
id: id,
|
|
75
|
-
name: title,
|
|
76
|
-
thumbnails: new Thumbnails().load(thumbnail),
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else if (type === "MUSIC_PAGE_TYPE_PLAYLIST") {
|
|
80
|
-
topResult = new MusicPlaylistCompact({
|
|
81
|
-
client: client,
|
|
82
|
-
id: id,
|
|
83
|
-
title: title,
|
|
84
|
-
channel: MusicAllSearchResultParser.parseChannel(top.subtitle.runs, client),
|
|
85
|
-
thumbnails: new Thumbnails().load(thumbnail),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
var more;
|
|
89
|
-
if (top.contents) {
|
|
90
|
-
more = top.contents
|
|
91
|
-
.filter(function (c) { return c.musicResponsiveListItemRenderer; })
|
|
92
|
-
.map(function (c) { return MusicAllSearchResultParser.parseSearchItem(c, client); });
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
item: topResult,
|
|
96
|
-
more: more,
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
MusicAllSearchResultParser.parseSearchResult = function (data, client) {
|
|
100
|
-
var sectionListContents = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content
|
|
101
|
-
.sectionListRenderer.contents;
|
|
102
|
-
var shelves = sectionListContents
|
|
103
|
-
.filter(function (f) { return f.musicShelfRenderer; })
|
|
104
|
-
.map(function (m) { return m.musicShelfRenderer; });
|
|
105
|
-
return shelves.map(function (m) { return ({
|
|
106
|
-
title: m.title.runs.map(function (r) { return r.text; }).join(),
|
|
107
|
-
items: m.contents
|
|
108
|
-
.map(function (c) { return MusicAllSearchResultParser.parseSearchItem(c, client); })
|
|
109
|
-
.filter(function (i) { return i; }),
|
|
110
|
-
}); });
|
|
111
|
-
};
|
|
112
|
-
MusicAllSearchResultParser.parseSearchItem = function (content, client) {
|
|
113
|
-
var _a;
|
|
114
|
-
var item = content.musicResponsiveListItemRenderer;
|
|
115
|
-
var playEndpoint = (_a = item.overlay) === null || _a === void 0 ? void 0 : _a.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer.playNavigationEndpoint;
|
|
116
|
-
if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
|
|
117
|
-
var pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
|
|
118
|
-
.watchEndpointMusicConfig.musicVideoType;
|
|
119
|
-
return MusicAllSearchResultParser.parseVideoItem(item, pageType, client);
|
|
120
|
-
}
|
|
121
|
-
else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
|
|
122
|
-
return MusicAllSearchResultParser.parsePlaylistItem(item, client);
|
|
123
|
-
}
|
|
124
|
-
else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint) {
|
|
125
|
-
// TODO add podcast support, id starts with PL
|
|
126
|
-
if (playEndpoint.watchPlaylistEndpoint.playlistId.startsWith("OL")) {
|
|
127
|
-
return MusicAllSearchResultParser.parseAlbumItem(item, client);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
return MusicAllSearchResultParser.parseArtistItem(item, client);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
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
|
-
}
|
|
139
|
-
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
|
|
140
|
-
var id = topColumn[0].navigationEndpoint.watchEndpoint.videoId;
|
|
141
|
-
var title = topColumn[0].text;
|
|
142
|
-
var duration = getDuration(bottomColumn.at(-1).text) || undefined;
|
|
143
|
-
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
144
|
-
var artists = MusicAllSearchResultParser.parseArtists(bottomColumn, client);
|
|
145
|
-
if (pageType === "MUSIC_VIDEO_TYPE_ATV") {
|
|
146
|
-
return new MusicSongCompact({
|
|
147
|
-
client: client,
|
|
148
|
-
id: id,
|
|
149
|
-
album: MusicAllSearchResultParser.parseAlbum(bottomColumn, client),
|
|
150
|
-
title: title,
|
|
151
|
-
artists: artists,
|
|
152
|
-
thumbnails: thumbnails,
|
|
153
|
-
duration: duration,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else if (pageType === "MUSIC_VIDEO_TYPE_UGC" || pageType === "MUSIC_VIDEO_TYPE_OMV") {
|
|
157
|
-
return new MusicVideoCompact({ client: client, id: id, title: title, artists: artists, thumbnails: thumbnails, duration: duration });
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
MusicAllSearchResultParser.parsePlaylistItem = function (item, client) {
|
|
161
|
-
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
|
|
162
|
-
var id = item.overlay.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer
|
|
163
|
-
.playNavigationEndpoint.watchPlaylistEndpoint.playlistId;
|
|
164
|
-
var title = topColumn[0].text;
|
|
165
|
-
var songCount = stripToInt(bottomColumn.at(-1).text) || undefined;
|
|
166
|
-
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
167
|
-
var channel = MusicAllSearchResultParser.parseChannel(bottomColumn, client);
|
|
168
|
-
return new MusicPlaylistCompact({ client: client, id: id, title: title, thumbnails: thumbnails, songCount: songCount, channel: channel });
|
|
169
|
-
};
|
|
170
|
-
MusicAllSearchResultParser.parseAlbumItem = function (item, client) {
|
|
171
|
-
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 2), topColumn = _a[0], bottomColumn = _a[1];
|
|
172
|
-
var id = item.overlay.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer
|
|
173
|
-
.playNavigationEndpoint.watchPlaylistEndpoint.playlistId;
|
|
174
|
-
var title = topColumn[0].text;
|
|
175
|
-
var year = stripToInt(bottomColumn.at(-1).text) || undefined;
|
|
176
|
-
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
177
|
-
var artists = MusicAllSearchResultParser.parseArtists(bottomColumn, client);
|
|
178
|
-
return new MusicAlbumCompact({ client: client, id: id, title: title, thumbnails: thumbnails, artists: artists, year: year });
|
|
179
|
-
};
|
|
180
|
-
MusicAllSearchResultParser.parseArtistItem = function (item, client) {
|
|
181
|
-
var _a = __read(item.flexColumns.map(function (c) { return c.musicResponsiveListItemFlexColumnRenderer.text.runs; }), 1), topColumn = _a[0];
|
|
182
|
-
var id = item.navigationEndpoint.browseEndpoint.browseId;
|
|
183
|
-
var name = topColumn[0].text;
|
|
184
|
-
var thumbnails = new Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
185
|
-
return new MusicArtistCompact({ client: client, id: id, name: name, thumbnails: thumbnails });
|
|
186
|
-
};
|
|
187
|
-
MusicAllSearchResultParser.parseAlbum = function (items, client) {
|
|
188
|
-
var _a;
|
|
189
|
-
var albumRaw = items.find(function (r) {
|
|
190
|
-
var _a;
|
|
191
|
-
var pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
192
|
-
return pageType === "MUSIC_PAGE_TYPE_ALBUM";
|
|
193
|
-
});
|
|
194
|
-
if (!albumRaw)
|
|
195
|
-
return;
|
|
196
|
-
var album = new MusicAlbumCompact({
|
|
197
|
-
client: client,
|
|
198
|
-
title: albumRaw.text,
|
|
199
|
-
id: (_a = albumRaw.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
200
|
-
});
|
|
201
|
-
return album;
|
|
202
|
-
};
|
|
203
|
-
MusicAllSearchResultParser.parseArtists = function (items, client) {
|
|
204
|
-
return this.parseArtistsOrChannel(items).map(function (r) {
|
|
205
|
-
var _a;
|
|
206
|
-
return new MusicBaseArtist({
|
|
207
|
-
client: client,
|
|
208
|
-
name: r.text,
|
|
209
|
-
id: (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
MusicAllSearchResultParser.parseChannel = function (items, client) {
|
|
214
|
-
var _a;
|
|
215
|
-
var _b = __read(this.parseArtistsOrChannel(items), 1), channelRaw = _b[0];
|
|
216
|
-
if (!channelRaw)
|
|
217
|
-
return;
|
|
218
|
-
var channel = new MusicBaseChannel({
|
|
219
|
-
client: client,
|
|
220
|
-
name: channelRaw.text,
|
|
221
|
-
id: (_a = channelRaw.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
222
|
-
});
|
|
223
|
-
return channel;
|
|
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
|
-
};
|
|
232
|
-
return MusicAllSearchResultParser;
|
|
233
|
-
}());
|
|
234
|
-
export { MusicAllSearchResultParser };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Shelf, YoutubeRawData } from "../../common";
|
|
2
|
-
import { MusicAlbumCompact } from "../MusicAlbumCompact";
|
|
3
|
-
import { MusicClient, MusicTopShelf } from "../MusicClient";
|
|
4
|
-
import { MusicPlaylistCompact } from "../MusicPlaylistCompact";
|
|
5
|
-
import { MusicSongCompact } from "../MusicSongCompact";
|
|
6
|
-
import { MusicVideoCompact } from "../MusicVideoCompact";
|
|
7
|
-
export declare class MusicAllSearchResultParser {
|
|
8
|
-
static parseTopResult(data: YoutubeRawData, client: MusicClient): MusicTopShelf | undefined;
|
|
9
|
-
static parseSearchResult(data: YoutubeRawData, client: MusicClient): Shelf<MusicVideoCompact[] | MusicAlbumCompact[] | MusicPlaylistCompact[]>[];
|
|
10
|
-
private static parseSearchItem;
|
|
11
|
-
static parseVideoItem(item: YoutubeRawData, pageType: string, client: MusicClient): MusicSongCompact | MusicVideoCompact | undefined;
|
|
12
|
-
private static parsePlaylistItem;
|
|
13
|
-
private static parseAlbumItem;
|
|
14
|
-
private static parseArtistItem;
|
|
15
|
-
private static parseAlbum;
|
|
16
|
-
private static parseArtists;
|
|
17
|
-
private static parseChannel;
|
|
18
|
-
private static parseArtistsOrChannel;
|
|
19
|
-
}
|