youtubei 1.3.0 → 1.3.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/MusicSearchResult.js +4 -1
- package/dist/cjs/music/MusicSearchResult/MusicSearchResultParser.js +9 -1
- package/dist/cjs/music/index.js +1 -0
- package/dist/esm/music/MusicSearchResult/MusicSearchResult.js +6 -2
- package/dist/esm/music/MusicSearchResult/MusicSearchResultParser.js +9 -1
- package/dist/esm/music/index.js +1 -0
- package/dist/typings/music/MusicSearchResult/MusicSearchResult.d.ts +5 -1
- package/dist/typings/music/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -43,8 +43,10 @@ var MusicSearchTypeEnum;
|
|
|
43
43
|
*/
|
|
44
44
|
class MusicSearchResult extends MusicContinuable_1.MusicContinuable {
|
|
45
45
|
/** @hidden */
|
|
46
|
-
constructor({ client }) {
|
|
46
|
+
constructor({ client, type }) {
|
|
47
47
|
super({ client });
|
|
48
|
+
if (type)
|
|
49
|
+
this.type = type;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* Initialize data from search
|
|
@@ -57,6 +59,7 @@ class MusicSearchResult extends MusicContinuable_1.MusicContinuable {
|
|
|
57
59
|
search(query, type) {
|
|
58
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
61
|
this.items = [];
|
|
62
|
+
this.type = type;
|
|
60
63
|
const bufferParams = proto_1.MusicSearchProto.encode(proto_1.optionsToProto(type)).finish();
|
|
61
64
|
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
62
65
|
data: {
|
|
@@ -5,7 +5,15 @@ const MusicAllSearchResultParser_1 = require("./MusicAllSearchResultParser");
|
|
|
5
5
|
class MusicSearchResultParser {
|
|
6
6
|
static parseInitialSearchResult(data, type, client) {
|
|
7
7
|
var _a, _b;
|
|
8
|
-
const
|
|
8
|
+
const contentSection = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.find((c) => "musicShelfRenderer" in c);
|
|
9
|
+
if (!contentSection) {
|
|
10
|
+
// no results
|
|
11
|
+
return {
|
|
12
|
+
data: [],
|
|
13
|
+
continuation: undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const { contents, continuations } = contentSection.musicShelfRenderer;
|
|
9
17
|
return {
|
|
10
18
|
data: MusicSearchResultParser.parseSearchResult(contents, type, client),
|
|
11
19
|
continuation: (_b = (_a = continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
|
package/dist/cjs/music/index.js
CHANGED
|
@@ -19,5 +19,6 @@ __exportStar(require("./MusicBaseChannel"), exports);
|
|
|
19
19
|
__exportStar(require("./MusicClient"), exports);
|
|
20
20
|
__exportStar(require("./MusicLyrics"), exports);
|
|
21
21
|
__exportStar(require("./MusicPlaylistCompact"), exports);
|
|
22
|
+
__exportStar(require("./MusicSearchResult"), exports);
|
|
22
23
|
__exportStar(require("./MusicSongCompact"), exports);
|
|
23
24
|
__exportStar(require("./MusicVideoCompact"), exports);
|
|
@@ -102,8 +102,11 @@ var MusicSearchResult = /** @class */ (function (_super) {
|
|
|
102
102
|
__extends(MusicSearchResult, _super);
|
|
103
103
|
/** @hidden */
|
|
104
104
|
function MusicSearchResult(_a) {
|
|
105
|
-
var client = _a.client;
|
|
106
|
-
|
|
105
|
+
var client = _a.client, type = _a.type;
|
|
106
|
+
var _this = _super.call(this, { client: client }) || this;
|
|
107
|
+
if (type)
|
|
108
|
+
_this.type = type;
|
|
109
|
+
return _this;
|
|
107
110
|
}
|
|
108
111
|
/**
|
|
109
112
|
* Initialize data from search
|
|
@@ -121,6 +124,7 @@ var MusicSearchResult = /** @class */ (function (_super) {
|
|
|
121
124
|
switch (_c.label) {
|
|
122
125
|
case 0:
|
|
123
126
|
this.items = [];
|
|
127
|
+
this.type = type;
|
|
124
128
|
bufferParams = MusicSearchProto.encode(optionsToProto(type)).finish();
|
|
125
129
|
return [4 /*yield*/, this.client.http.post(I_END_POINT + "/search", {
|
|
126
130
|
data: {
|
|
@@ -15,7 +15,15 @@ var MusicSearchResultParser = /** @class */ (function () {
|
|
|
15
15
|
}
|
|
16
16
|
MusicSearchResultParser.parseInitialSearchResult = function (data, type, client) {
|
|
17
17
|
var _a, _b;
|
|
18
|
-
var
|
|
18
|
+
var contentSection = data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.find(function (c) { return "musicShelfRenderer" in c; });
|
|
19
|
+
if (!contentSection) {
|
|
20
|
+
// no results
|
|
21
|
+
return {
|
|
22
|
+
data: [],
|
|
23
|
+
continuation: undefined,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var _c = contentSection.musicShelfRenderer, contents = _c.contents, continuations = _c.continuations;
|
|
19
27
|
return {
|
|
20
28
|
data: MusicSearchResultParser.parseSearchResult(contents, type, client),
|
|
21
29
|
continuation: (_b = (_a = continuations[0]) === null || _a === void 0 ? void 0 : _a.nextContinuationData) === null || _b === void 0 ? void 0 : _b.continuation,
|
package/dist/esm/music/index.js
CHANGED
|
@@ -7,6 +7,9 @@ export declare enum MusicSearchTypeEnum {
|
|
|
7
7
|
}
|
|
8
8
|
export declare type MusicSearchType = "song" | "video" | MusicSearchTypeEnum;
|
|
9
9
|
export declare type MusicSearchResultItem<T = "song"> = T extends "song" ? MusicSongCompact : MusicVideoCompact;
|
|
10
|
+
declare type MusicLyricsProperties = MusicContinuableConstructorParams & {
|
|
11
|
+
type?: MusicSearchType;
|
|
12
|
+
};
|
|
10
13
|
/**
|
|
11
14
|
* Represents search result, usually returned from `client.search();`.
|
|
12
15
|
*
|
|
@@ -32,7 +35,7 @@ export declare type MusicSearchResultItem<T = "song"> = T extends "song" ? Music
|
|
|
32
35
|
export declare class MusicSearchResult<T extends MusicSearchType | undefined = "song"> extends MusicContinuable<MusicSearchResultItem<T>> {
|
|
33
36
|
private type;
|
|
34
37
|
/** @hidden */
|
|
35
|
-
constructor({ client }:
|
|
38
|
+
constructor({ client, type }: MusicLyricsProperties);
|
|
36
39
|
/**
|
|
37
40
|
* Initialize data from search
|
|
38
41
|
*
|
|
@@ -44,3 +47,4 @@ export declare class MusicSearchResult<T extends MusicSearchType | undefined = "
|
|
|
44
47
|
search(query: string, type: MusicSearchType): Promise<MusicSearchResult<T>>;
|
|
45
48
|
protected fetch(): Promise<FetchResult<MusicSearchResultItem<T>>>;
|
|
46
49
|
}
|
|
50
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.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",
|