youtubei 1.6.7 → 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/common/shared/HTTP/HTTP.js +1 -3
- package/dist/cjs/common/utils/helper.js +5 -1
- 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 +14 -2
- package/dist/cjs/youtube/Channel/ChannelParser.js +10 -6
- package/dist/cjs/youtube/PlaylistCompact/PlaylistCompact.js +9 -0
- package/dist/cjs/youtube/PlaylistCompact/PlaylistCompactParser.js +23 -0
- 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/cjs/youtube/SearchResult/SearchResultParser.js +10 -0
- package/dist/cjs/youtube/VideoCompact/VideoCompact.js +9 -0
- package/dist/cjs/youtube/VideoCompact/VideoCompactParser.js +27 -0
- package/dist/esm/common/shared/HTTP/HTTP.js +1 -3
- package/dist/esm/common/utils/helper.js +5 -1
- 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 +14 -2
- package/dist/esm/youtube/Channel/ChannelParser.js +12 -8
- package/dist/esm/youtube/PlaylistCompact/PlaylistCompact.js +9 -0
- package/dist/esm/youtube/PlaylistCompact/PlaylistCompactParser.js +23 -0
- 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/esm/youtube/SearchResult/SearchResultParser.js +10 -0
- package/dist/esm/youtube/VideoCompact/VideoCompact.js +9 -0
- package/dist/esm/youtube/VideoCompact/VideoCompactParser.js +27 -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/PlaylistCompact/PlaylistCompact.d.ts +6 -0
- package/dist/typings/youtube/PlaylistCompact/PlaylistCompactParser.d.ts +1 -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/dist/typings/youtube/VideoCompact/VideoCompact.d.ts +6 -0
- package/dist/typings/youtube/VideoCompact/VideoCompactParser.d.ts +1 -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,218 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MusicAllSearchResultParser = void 0;
|
|
4
|
-
const common_1 = require("../../common");
|
|
5
|
-
const MusicAlbumCompact_1 = require("../MusicAlbumCompact");
|
|
6
|
-
const MusicArtistCompact_1 = require("../MusicArtistCompact");
|
|
7
|
-
const MusicBaseArtist_1 = require("../MusicBaseArtist");
|
|
8
|
-
const MusicBaseChannel_1 = require("../MusicBaseChannel");
|
|
9
|
-
const MusicPlaylistCompact_1 = require("../MusicPlaylistCompact");
|
|
10
|
-
const MusicSongCompact_1 = require("../MusicSongCompact");
|
|
11
|
-
const MusicVideoCompact_1 = require("../MusicVideoCompact");
|
|
12
|
-
class MusicAllSearchResultParser {
|
|
13
|
-
static parseTopResult(data, client) {
|
|
14
|
-
var _a;
|
|
15
|
-
const sectionListContents = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content
|
|
16
|
-
.sectionListRenderer.contents;
|
|
17
|
-
const top = (_a = sectionListContents.find((f) => f.musicCardShelfRenderer)) === null || _a === void 0 ? void 0 : _a.musicCardShelfRenderer;
|
|
18
|
-
if (!top)
|
|
19
|
-
return;
|
|
20
|
-
const { browseEndpoint, watchEndpoint } = top.title.runs[0].navigationEndpoint;
|
|
21
|
-
const id = (watchEndpoint === null || watchEndpoint === void 0 ? void 0 : watchEndpoint.videoId) || (browseEndpoint === null || browseEndpoint === void 0 ? void 0 : browseEndpoint.browseId);
|
|
22
|
-
const type = (watchEndpoint === null || watchEndpoint === void 0 ? void 0 : watchEndpoint.watchEndpointMusicSupportedConfigs.watchEndpointMusicConfig.musicVideoType) || (browseEndpoint === null || browseEndpoint === void 0 ? void 0 : browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType);
|
|
23
|
-
const title = top.title.runs[0].text;
|
|
24
|
-
const thumbnail = top.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails;
|
|
25
|
-
let topResult;
|
|
26
|
-
if (type === "MUSIC_VIDEO_TYPE_ATV") {
|
|
27
|
-
topResult = new MusicSongCompact_1.MusicSongCompact({
|
|
28
|
-
client,
|
|
29
|
-
id,
|
|
30
|
-
title,
|
|
31
|
-
duration: common_1.getDuration(top.subtitle.runs.at(-1).text),
|
|
32
|
-
artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
|
|
33
|
-
album: MusicAllSearchResultParser.parseAlbum(top.subtitle.runs, client),
|
|
34
|
-
thumbnails: new common_1.Thumbnails().load(thumbnail),
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else if (type === "MUSIC_VIDEO_TYPE_UGC" || type === "MUSIC_VIDEO_TYPE_OMV") {
|
|
38
|
-
topResult = new MusicVideoCompact_1.MusicVideoCompact({
|
|
39
|
-
client,
|
|
40
|
-
id,
|
|
41
|
-
title,
|
|
42
|
-
duration: common_1.getDuration(top.subtitle.runs.at(-1).text),
|
|
43
|
-
artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
|
|
44
|
-
thumbnails: new common_1.Thumbnails().load(thumbnail),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else if (type === "MUSIC_PAGE_TYPE_ALBUM") {
|
|
48
|
-
topResult = new MusicAlbumCompact_1.MusicAlbumCompact({
|
|
49
|
-
client,
|
|
50
|
-
id,
|
|
51
|
-
title,
|
|
52
|
-
artists: MusicAllSearchResultParser.parseArtists(top.subtitle.runs, client),
|
|
53
|
-
thumbnails: new common_1.Thumbnails().load(thumbnail),
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else if (type === "MUSIC_PAGE_TYPE_ARTIST") {
|
|
57
|
-
topResult = new MusicArtistCompact_1.MusicArtistCompact({
|
|
58
|
-
client,
|
|
59
|
-
id,
|
|
60
|
-
name: title,
|
|
61
|
-
thumbnails: new common_1.Thumbnails().load(thumbnail),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
else if (type === "MUSIC_PAGE_TYPE_PLAYLIST") {
|
|
65
|
-
topResult = new MusicPlaylistCompact_1.MusicPlaylistCompact({
|
|
66
|
-
client,
|
|
67
|
-
id,
|
|
68
|
-
title,
|
|
69
|
-
channel: MusicAllSearchResultParser.parseChannel(top.subtitle.runs, client),
|
|
70
|
-
thumbnails: new common_1.Thumbnails().load(thumbnail),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
let more;
|
|
74
|
-
if (top.contents) {
|
|
75
|
-
more = top.contents
|
|
76
|
-
.filter((c) => c.musicResponsiveListItemRenderer)
|
|
77
|
-
.map((c) => MusicAllSearchResultParser.parseSearchItem(c, client));
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
item: topResult,
|
|
81
|
-
more,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
static parseSearchResult(data, client) {
|
|
85
|
-
const sectionListContents = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content
|
|
86
|
-
.sectionListRenderer.contents;
|
|
87
|
-
const shelves = sectionListContents
|
|
88
|
-
.filter((f) => f.musicShelfRenderer)
|
|
89
|
-
.map((m) => m.musicShelfRenderer);
|
|
90
|
-
return shelves.map((m) => ({
|
|
91
|
-
title: m.title.runs.map((r) => r.text).join(),
|
|
92
|
-
items: m.contents
|
|
93
|
-
.map((c) => MusicAllSearchResultParser.parseSearchItem(c, client))
|
|
94
|
-
.filter((i) => i),
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
static parseSearchItem(content, client) {
|
|
98
|
-
var _a;
|
|
99
|
-
const item = content.musicResponsiveListItemRenderer;
|
|
100
|
-
const playEndpoint = (_a = item.overlay) === null || _a === void 0 ? void 0 : _a.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer.playNavigationEndpoint;
|
|
101
|
-
if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchEndpoint) {
|
|
102
|
-
const pageType = playEndpoint.watchEndpoint.watchEndpointMusicSupportedConfigs
|
|
103
|
-
.watchEndpointMusicConfig.musicVideoType;
|
|
104
|
-
return MusicAllSearchResultParser.parseVideoItem(item, pageType, client);
|
|
105
|
-
}
|
|
106
|
-
else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint.params) {
|
|
107
|
-
return MusicAllSearchResultParser.parsePlaylistItem(item, client);
|
|
108
|
-
}
|
|
109
|
-
else if (playEndpoint === null || playEndpoint === void 0 ? void 0 : playEndpoint.watchPlaylistEndpoint) {
|
|
110
|
-
// TODO add podcast support, id starts with PL
|
|
111
|
-
if (playEndpoint.watchPlaylistEndpoint.playlistId.startsWith("OL")) {
|
|
112
|
-
return MusicAllSearchResultParser.parseAlbumItem(item, client);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
return MusicAllSearchResultParser.parseArtistItem(item, client);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
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
|
-
}
|
|
124
|
-
const [topColumn, bottomColumn] = item.flexColumns.map((c) => c.musicResponsiveListItemFlexColumnRenderer.text.runs);
|
|
125
|
-
const id = topColumn[0].navigationEndpoint.watchEndpoint.videoId;
|
|
126
|
-
const title = topColumn[0].text;
|
|
127
|
-
const duration = common_1.getDuration(bottomColumn.at(-1).text) || undefined;
|
|
128
|
-
const thumbnails = new common_1.Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
129
|
-
const artists = MusicAllSearchResultParser.parseArtists(bottomColumn, client);
|
|
130
|
-
if (pageType === "MUSIC_VIDEO_TYPE_ATV") {
|
|
131
|
-
return new MusicSongCompact_1.MusicSongCompact({
|
|
132
|
-
client,
|
|
133
|
-
id,
|
|
134
|
-
album: MusicAllSearchResultParser.parseAlbum(bottomColumn, client),
|
|
135
|
-
title,
|
|
136
|
-
artists,
|
|
137
|
-
thumbnails,
|
|
138
|
-
duration,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else if (pageType === "MUSIC_VIDEO_TYPE_UGC" || pageType === "MUSIC_VIDEO_TYPE_OMV") {
|
|
142
|
-
return new MusicVideoCompact_1.MusicVideoCompact({ client, id, title, artists, thumbnails, duration });
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
static parsePlaylistItem(item, client) {
|
|
146
|
-
const [topColumn, bottomColumn] = item.flexColumns.map((c) => c.musicResponsiveListItemFlexColumnRenderer.text.runs);
|
|
147
|
-
const id = item.overlay.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer
|
|
148
|
-
.playNavigationEndpoint.watchPlaylistEndpoint.playlistId;
|
|
149
|
-
const title = topColumn[0].text;
|
|
150
|
-
const songCount = common_1.stripToInt(bottomColumn.at(-1).text) || undefined;
|
|
151
|
-
const thumbnails = new common_1.Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
152
|
-
const channel = MusicAllSearchResultParser.parseChannel(bottomColumn, client);
|
|
153
|
-
return new MusicPlaylistCompact_1.MusicPlaylistCompact({ client, id, title, thumbnails, songCount, channel });
|
|
154
|
-
}
|
|
155
|
-
static parseAlbumItem(item, client) {
|
|
156
|
-
const [topColumn, bottomColumn] = item.flexColumns.map((c) => c.musicResponsiveListItemFlexColumnRenderer.text.runs);
|
|
157
|
-
const id = item.overlay.musicItemThumbnailOverlayRenderer.content.musicPlayButtonRenderer
|
|
158
|
-
.playNavigationEndpoint.watchPlaylistEndpoint.playlistId;
|
|
159
|
-
const title = topColumn[0].text;
|
|
160
|
-
const year = common_1.stripToInt(bottomColumn.at(-1).text) || undefined;
|
|
161
|
-
const thumbnails = new common_1.Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
162
|
-
const artists = MusicAllSearchResultParser.parseArtists(bottomColumn, client);
|
|
163
|
-
return new MusicAlbumCompact_1.MusicAlbumCompact({ client, id, title, thumbnails, artists, year });
|
|
164
|
-
}
|
|
165
|
-
static parseArtistItem(item, client) {
|
|
166
|
-
const [topColumn] = item.flexColumns.map((c) => c.musicResponsiveListItemFlexColumnRenderer.text.runs);
|
|
167
|
-
const id = item.navigationEndpoint.browseEndpoint.browseId;
|
|
168
|
-
const name = topColumn[0].text;
|
|
169
|
-
const thumbnails = new common_1.Thumbnails().load(item.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails);
|
|
170
|
-
return new MusicArtistCompact_1.MusicArtistCompact({ client, id, name, thumbnails });
|
|
171
|
-
}
|
|
172
|
-
static parseAlbum(items, client) {
|
|
173
|
-
var _a;
|
|
174
|
-
const albumRaw = items.find((r) => {
|
|
175
|
-
var _a;
|
|
176
|
-
const pageType = (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType;
|
|
177
|
-
return pageType === "MUSIC_PAGE_TYPE_ALBUM";
|
|
178
|
-
});
|
|
179
|
-
if (!albumRaw)
|
|
180
|
-
return;
|
|
181
|
-
const album = new MusicAlbumCompact_1.MusicAlbumCompact({
|
|
182
|
-
client,
|
|
183
|
-
title: albumRaw.text,
|
|
184
|
-
id: (_a = albumRaw.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
185
|
-
});
|
|
186
|
-
return album;
|
|
187
|
-
}
|
|
188
|
-
static parseArtists(items, client) {
|
|
189
|
-
return this.parseArtistsOrChannel(items).map((r) => {
|
|
190
|
-
var _a;
|
|
191
|
-
return new MusicBaseArtist_1.MusicBaseArtist({
|
|
192
|
-
client,
|
|
193
|
-
name: r.text,
|
|
194
|
-
id: (_a = r.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
static parseChannel(items, client) {
|
|
199
|
-
var _a;
|
|
200
|
-
const [channelRaw] = this.parseArtistsOrChannel(items);
|
|
201
|
-
if (!channelRaw)
|
|
202
|
-
return;
|
|
203
|
-
const channel = new MusicBaseChannel_1.MusicBaseChannel({
|
|
204
|
-
client,
|
|
205
|
-
name: channelRaw.text,
|
|
206
|
-
id: (_a = channelRaw.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint.browseId,
|
|
207
|
-
});
|
|
208
|
-
return channel;
|
|
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
|
-
}
|
|
217
|
-
}
|
|
218
|
-
exports.MusicAllSearchResultParser = MusicAllSearchResultParser;
|
|
@@ -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
|
-
}
|