youtubei 1.0.0-rc.1 → 1.0.0-rc.4
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/README.md +1 -1
- package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +12 -4
- package/dist/cjs/classes/BaseChannel/ChannelPlaylists.js +1 -1
- package/dist/cjs/classes/BaseChannel/ChannelVideos.js +1 -1
- package/dist/cjs/classes/Channel/ChannelParser.js +1 -1
- package/dist/cjs/classes/Channel/index.js +1 -0
- package/dist/cjs/classes/Chat/index.js +1 -0
- package/dist/cjs/classes/Client/Client.js +4 -4
- package/dist/cjs/classes/Comment/index.js +2 -0
- package/dist/cjs/classes/{SearchManager/SearchManager.js → SearchResult/SearchResult.js} +14 -12
- package/dist/cjs/classes/{SearchManager/SearchManagerParser.js → SearchResult/SearchResultParser.js} +0 -0
- package/dist/cjs/classes/{SearchManager → SearchResult}/index.js +2 -2
- package/dist/cjs/classes/{SearchManager → SearchResult}/proto/SearchProto.js +0 -0
- package/dist/cjs/classes/{SearchManager → SearchResult}/proto/index.js +0 -0
- package/dist/cjs/classes/Thumbnails/Thumbnails.js +1 -1
- package/dist/cjs/classes/Video/index.js +1 -0
- package/dist/cjs/classes/index.js +3 -3
- package/dist/esm/classes/BaseChannel/BaseChannelParser.js +12 -4
- package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +1 -1
- package/dist/esm/classes/BaseChannel/ChannelVideos.js +1 -1
- package/dist/esm/classes/Channel/ChannelParser.js +1 -1
- package/dist/esm/classes/Channel/index.js +1 -0
- package/dist/esm/classes/Chat/index.js +1 -0
- package/dist/esm/classes/Client/Client.js +5 -5
- package/dist/esm/classes/Comment/index.js +2 -0
- package/dist/esm/classes/{SearchManager/SearchManager.js → SearchResult/SearchResult.js} +16 -14
- package/dist/esm/classes/{SearchManager/SearchManagerParser.js → SearchResult/SearchResultParser.js} +0 -0
- package/dist/esm/classes/SearchResult/index.js +2 -0
- package/dist/esm/classes/{SearchManager → SearchResult}/proto/SearchProto.js +0 -0
- package/dist/esm/classes/{SearchManager → SearchResult}/proto/index.js +0 -0
- package/dist/esm/classes/Thumbnails/Thumbnails.js +1 -1
- package/dist/esm/classes/Video/index.js +1 -0
- package/dist/esm/classes/index.js +3 -3
- package/dist/typings/classes/BaseChannel/BaseChannelParser.d.ts +4 -0
- package/dist/typings/classes/Channel/index.d.ts +1 -0
- package/dist/typings/classes/Chat/index.d.ts +1 -0
- package/dist/typings/classes/Client/Client.d.ts +3 -3
- package/dist/typings/classes/Comment/index.d.ts +2 -0
- package/dist/typings/classes/{SearchManager/SearchManager.d.ts → SearchResult/SearchResult.d.ts} +12 -10
- package/dist/typings/classes/{SearchManager/SearchManagerParser.d.ts → SearchResult/SearchResultParser.d.ts} +2 -2
- package/dist/typings/classes/SearchResult/index.d.ts +2 -0
- package/dist/typings/classes/{SearchManager → SearchResult}/proto/SearchProto.d.ts +0 -0
- package/dist/typings/classes/{SearchManager → SearchResult}/proto/index.d.ts +1 -1
- package/dist/typings/classes/Thumbnails/Thumbnails.d.ts +1 -1
- package/dist/typings/classes/Video/index.d.ts +1 -0
- package/dist/typings/classes/index.d.ts +3 -3
- package/package.json +1 -1
- package/dist/esm/classes/SearchManager/index.js +0 -2
- package/dist/typings/classes/SearchManager/index.d.ts +0 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`Youtubei` is made to replace my other library [scrape-yt](https://github.com/SuspiciousLookingOwl/scrape-yt/). Instead of scrapping data from Youtube page, `youtubei` fetches data by sending a request directly to `https://www.youtube.com/youtubei/v1`, which should be faster and provide more reliable result.
|
|
4
4
|
|
|
5
|
-
<b>Requires Node >=
|
|
5
|
+
<b>Requires Node >= 16</b>
|
|
6
6
|
|
|
7
7
|
#### [Documentation](https://suspiciouslookingowl.github.io/youtubei)
|
|
8
8
|
|
|
@@ -15,10 +15,18 @@ class BaseChannelParser {
|
|
|
15
15
|
}
|
|
16
16
|
/** Parse tab data from request, tab name is ignored if it's a continuation data */
|
|
17
17
|
static parseTabData(name, data) {
|
|
18
|
-
var _a;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
const tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find((t) => {
|
|
20
|
+
var _a;
|
|
21
|
+
return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
|
|
22
|
+
BaseChannelParser.TAB_TYPE_PARAMS[name]);
|
|
23
|
+
});
|
|
24
|
+
return (((_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer) === null || _b === void 0 ? void 0 : _b.items) || ((_c = data.onResponseReceivedActions) === null || _c === void 0 ? void 0 : _c[0].appendContinuationItemsAction.continuationItems) ||
|
|
25
|
+
[]);
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
exports.BaseChannelParser = BaseChannelParser;
|
|
29
|
+
BaseChannelParser.TAB_TYPE_PARAMS = {
|
|
30
|
+
videos: "EgZ2aWRlb3M%3D",
|
|
31
|
+
playlists: "EglwbGF5bGlzdHM%3D",
|
|
32
|
+
};
|
|
@@ -49,7 +49,7 @@ class ChannelPlaylists extends Continuable_1.Continuable {
|
|
|
49
49
|
const data = common_1.mapFilter(items, "gridPlaylistRenderer");
|
|
50
50
|
return {
|
|
51
51
|
continuation,
|
|
52
|
-
items: data.map((i) => new PlaylistCompact_1.PlaylistCompact({ client: this.client }).load(i)),
|
|
52
|
+
items: data.map((i) => new PlaylistCompact_1.PlaylistCompact({ client: this.client, channel: this.channel }).load(i)),
|
|
53
53
|
};
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -49,7 +49,7 @@ class ChannelVideos extends Continuable_1.Continuable {
|
|
|
49
49
|
const data = common_1.mapFilter(items, "gridVideoRenderer");
|
|
50
50
|
return {
|
|
51
51
|
continuation,
|
|
52
|
-
items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client }).load(i)),
|
|
52
|
+
items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
|
|
53
53
|
};
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -12,7 +12,7 @@ class ChannelParser {
|
|
|
12
12
|
target.name = title;
|
|
13
13
|
target.thumbnails = new Thumbnails_1.Thumbnails().load(avatar.thumbnails);
|
|
14
14
|
target.videoCount = 0; // data not available
|
|
15
|
-
target.subscriberCount = subscriberCountText.simpleText;
|
|
15
|
+
target.subscriberCount = subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText;
|
|
16
16
|
const { tvBanner, mobileBanner, banner } = data.header.c4TabbedHeaderRenderer;
|
|
17
17
|
target.banner = new Thumbnails_1.Thumbnails().load((banner === null || banner === void 0 ? void 0 : banner.thumbnails) || []);
|
|
18
18
|
target.tvBanner = new Thumbnails_1.Thumbnails().load((tvBanner === null || tvBanner === void 0 ? void 0 : tvBanner.thumbnails) || []);
|
|
@@ -15,7 +15,7 @@ const Channel_1 = require("../Channel");
|
|
|
15
15
|
const LiveVideo_1 = require("../LiveVideo");
|
|
16
16
|
const MixPlaylist_1 = require("../MixPlaylist");
|
|
17
17
|
const Playlist_1 = require("../Playlist");
|
|
18
|
-
const
|
|
18
|
+
const SearchResult_1 = require("../SearchResult");
|
|
19
19
|
const Video_1 = require("../Video");
|
|
20
20
|
const HTTP_1 = require("./HTTP");
|
|
21
21
|
/** Youtube Client */
|
|
@@ -33,9 +33,9 @@ class Client {
|
|
|
33
33
|
*/
|
|
34
34
|
search(query, options) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const
|
|
37
|
-
yield
|
|
38
|
-
return
|
|
36
|
+
const result = new SearchResult_1.SearchResult({ client: this });
|
|
37
|
+
yield result.search(query, options || {});
|
|
38
|
+
return result;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
@@ -11,3 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./Comment"), exports);
|
|
14
|
+
__exportStar(require("./CommentReplies"), exports);
|
|
15
|
+
__exportStar(require("./CommentParser"), exports);
|
|
@@ -9,34 +9,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.SearchResult = void 0;
|
|
13
13
|
const constants_1 = require("../../constants");
|
|
14
14
|
const Continuable_1 = require("../Continuable");
|
|
15
|
-
const
|
|
15
|
+
const SearchResultParser_1 = require("./SearchResultParser");
|
|
16
16
|
const proto_1 = require("./proto");
|
|
17
17
|
/**
|
|
18
18
|
* Represents search result, usually returned from `client.search();`.
|
|
19
19
|
*
|
|
20
|
-
* {@link
|
|
20
|
+
* {@link SearchResult} is a helper class to manage search result
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```ts
|
|
24
|
-
* const
|
|
24
|
+
* const result = await youtube.search("Keyword");
|
|
25
25
|
*
|
|
26
|
-
* console.log(
|
|
26
|
+
* console.log(result.items); // search result from first page
|
|
27
27
|
*
|
|
28
|
-
* let nextSearchResult = await
|
|
28
|
+
* let nextSearchResult = await result.next();
|
|
29
29
|
* console.log(nextSearchResult); // search result from second page
|
|
30
30
|
*
|
|
31
|
-
* nextSearchResult = await
|
|
31
|
+
* nextSearchResult = await result.next();
|
|
32
32
|
* console.log(nextSearchResult); // search result from third page
|
|
33
33
|
*
|
|
34
|
-
* console.log(
|
|
34
|
+
* console.log(result.items); // search result from first, second, and third page.
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* @noInheritDoc
|
|
38
38
|
*/
|
|
39
|
-
class
|
|
39
|
+
class SearchResult extends Continuable_1.Continuable {
|
|
40
40
|
/** @hidden */
|
|
41
41
|
constructor({ client }) {
|
|
42
42
|
super({ client });
|
|
@@ -46,6 +46,8 @@ class SearchManager extends Continuable_1.Continuable {
|
|
|
46
46
|
*
|
|
47
47
|
* @param query Search query
|
|
48
48
|
* @param options Search Options
|
|
49
|
+
*
|
|
50
|
+
* @hidden
|
|
49
51
|
*/
|
|
50
52
|
search(query, options) {
|
|
51
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -60,7 +62,7 @@ class SearchManager extends Continuable_1.Continuable {
|
|
|
60
62
|
});
|
|
61
63
|
this.estimatedResults = +response.data.estimatedResults;
|
|
62
64
|
if (this.estimatedResults > 0) {
|
|
63
|
-
const { data, continuation } =
|
|
65
|
+
const { data, continuation } = SearchResultParser_1.SearchResultParser.parseInitialSearchResult(response.data, this.client);
|
|
64
66
|
this.items.push(...data);
|
|
65
67
|
this.continuation = continuation;
|
|
66
68
|
}
|
|
@@ -72,7 +74,7 @@ class SearchManager extends Continuable_1.Continuable {
|
|
|
72
74
|
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
73
75
|
data: { continuation: this.continuation },
|
|
74
76
|
});
|
|
75
|
-
const { data, continuation } =
|
|
77
|
+
const { data, continuation } = SearchResultParser_1.SearchResultParser.parseContinuationSearchResult(response.data, this.client);
|
|
76
78
|
return {
|
|
77
79
|
items: data,
|
|
78
80
|
continuation,
|
|
@@ -80,4 +82,4 @@ class SearchManager extends Continuable_1.Continuable {
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
|
-
exports.
|
|
85
|
+
exports.SearchResult = SearchResult;
|
package/dist/cjs/classes/{SearchManager/SearchManagerParser.js → SearchResult/SearchResultParser.js}
RENAMED
|
File without changes
|
|
@@ -10,5 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
14
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./SearchResult"), exports);
|
|
14
|
+
__exportStar(require("./SearchResultParser"), exports);
|
|
File without changes
|
|
File without changes
|
|
@@ -11,4 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./Video"), exports);
|
|
14
|
+
__exportStar(require("./VideoComments"), exports);
|
|
14
15
|
__exportStar(require("./VideoParser"), exports);
|
|
@@ -11,19 +11,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./Base"), exports);
|
|
14
|
+
__exportStar(require("./BaseChannel"), exports);
|
|
14
15
|
__exportStar(require("./BaseVideo"), exports);
|
|
15
16
|
__exportStar(require("./Channel"), exports);
|
|
16
|
-
__exportStar(require("./BaseChannel"), exports);
|
|
17
17
|
__exportStar(require("./Chat"), exports);
|
|
18
18
|
__exportStar(require("./Client"), exports);
|
|
19
|
-
__exportStar(require("./Continuable"), exports);
|
|
20
19
|
__exportStar(require("./Comment"), exports);
|
|
20
|
+
__exportStar(require("./Continuable"), exports);
|
|
21
21
|
__exportStar(require("./LiveVideo"), exports);
|
|
22
22
|
__exportStar(require("./MixPlaylist"), exports);
|
|
23
23
|
__exportStar(require("./Playlist"), exports);
|
|
24
24
|
__exportStar(require("./PlaylistCompact"), exports);
|
|
25
25
|
__exportStar(require("./Reply"), exports);
|
|
26
|
-
__exportStar(require("./
|
|
26
|
+
__exportStar(require("./SearchResult"), exports);
|
|
27
27
|
__exportStar(require("./Thumbnails"), exports);
|
|
28
28
|
__exportStar(require("./Video"), exports);
|
|
29
29
|
__exportStar(require("./VideoCompact"), exports);
|
|
@@ -14,10 +14,18 @@ var BaseChannelParser = /** @class */ (function () {
|
|
|
14
14
|
};
|
|
15
15
|
/** Parse tab data from request, tab name is ignored if it's a continuation data */
|
|
16
16
|
BaseChannelParser.parseTabData = function (name, data) {
|
|
17
|
-
var _a;
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
var tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find(function (t) {
|
|
19
|
+
var _a;
|
|
20
|
+
return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
|
|
21
|
+
BaseChannelParser.TAB_TYPE_PARAMS[name]);
|
|
22
|
+
});
|
|
23
|
+
return (((_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer) === null || _b === void 0 ? void 0 : _b.items) || ((_c = data.onResponseReceivedActions) === null || _c === void 0 ? void 0 : _c[0].appendContinuationItemsAction.continuationItems) ||
|
|
24
|
+
[]);
|
|
25
|
+
};
|
|
26
|
+
BaseChannelParser.TAB_TYPE_PARAMS = {
|
|
27
|
+
videos: "EgZ2aWRlb3M%3D",
|
|
28
|
+
playlists: "EglwbGF5bGlzdHM%3D",
|
|
21
29
|
};
|
|
22
30
|
return BaseChannelParser;
|
|
23
31
|
}());
|
|
@@ -97,7 +97,7 @@ var ChannelPlaylists = /** @class */ (function (_super) {
|
|
|
97
97
|
return [2 /*return*/, {
|
|
98
98
|
continuation: continuation,
|
|
99
99
|
items: data.map(function (i) {
|
|
100
|
-
return new PlaylistCompact({ client: _this.client }).load(i);
|
|
100
|
+
return new PlaylistCompact({ client: _this.client, channel: _this.channel }).load(i);
|
|
101
101
|
}),
|
|
102
102
|
}];
|
|
103
103
|
}
|
|
@@ -97,7 +97,7 @@ var ChannelVideos = /** @class */ (function (_super) {
|
|
|
97
97
|
return [2 /*return*/, {
|
|
98
98
|
continuation: continuation,
|
|
99
99
|
items: data.map(function (i) {
|
|
100
|
-
return new VideoCompact({ client: _this.client }).load(i);
|
|
100
|
+
return new VideoCompact({ client: _this.client, channel: _this.channel }).load(i);
|
|
101
101
|
}),
|
|
102
102
|
}];
|
|
103
103
|
}
|
|
@@ -22,7 +22,7 @@ var ChannelParser = /** @class */ (function () {
|
|
|
22
22
|
target.name = title;
|
|
23
23
|
target.thumbnails = new Thumbnails().load(avatar.thumbnails);
|
|
24
24
|
target.videoCount = 0; // data not available
|
|
25
|
-
target.subscriberCount = subscriberCountText.simpleText;
|
|
25
|
+
target.subscriberCount = subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText;
|
|
26
26
|
var _b = data.header.c4TabbedHeaderRenderer, tvBanner = _b.tvBanner, mobileBanner = _b.mobileBanner, banner = _b.banner;
|
|
27
27
|
target.banner = new Thumbnails().load((banner === null || banner === void 0 ? void 0 : banner.thumbnails) || []);
|
|
28
28
|
target.tvBanner = new Thumbnails().load((tvBanner === null || tvBanner === void 0 ? void 0 : tvBanner.thumbnails) || []);
|
|
@@ -50,7 +50,7 @@ import { Channel } from "../Channel";
|
|
|
50
50
|
import { LiveVideo } from "../LiveVideo";
|
|
51
51
|
import { MixPlaylist } from "../MixPlaylist";
|
|
52
52
|
import { Playlist } from "../Playlist";
|
|
53
|
-
import {
|
|
53
|
+
import { SearchResult } from "../SearchResult";
|
|
54
54
|
import { Video } from "../Video";
|
|
55
55
|
import { HTTP } from "./HTTP";
|
|
56
56
|
/** Youtube Client */
|
|
@@ -69,15 +69,15 @@ var Client = /** @class */ (function () {
|
|
|
69
69
|
*/
|
|
70
70
|
Client.prototype.search = function (query, options) {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var
|
|
72
|
+
var result;
|
|
73
73
|
return __generator(this, function (_a) {
|
|
74
74
|
switch (_a.label) {
|
|
75
75
|
case 0:
|
|
76
|
-
|
|
77
|
-
return [4 /*yield*/,
|
|
76
|
+
result = new SearchResult({ client: this });
|
|
77
|
+
return [4 /*yield*/, result.search(query, options || {})];
|
|
78
78
|
case 1:
|
|
79
79
|
_a.sent();
|
|
80
|
-
return [2 /*return*/,
|
|
80
|
+
return [2 /*return*/, result];
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
});
|
|
@@ -69,34 +69,34 @@ var __spread = (this && this.__spread) || function () {
|
|
|
69
69
|
};
|
|
70
70
|
import { I_END_POINT } from "../../constants";
|
|
71
71
|
import { Continuable } from "../Continuable";
|
|
72
|
-
import { SearchResultParser } from "./
|
|
72
|
+
import { SearchResultParser } from "./SearchResultParser";
|
|
73
73
|
import { optionsToProto, SearchProto } from "./proto";
|
|
74
74
|
/**
|
|
75
75
|
* Represents search result, usually returned from `client.search();`.
|
|
76
76
|
*
|
|
77
|
-
* {@link
|
|
77
|
+
* {@link SearchResult} is a helper class to manage search result
|
|
78
78
|
*
|
|
79
79
|
* @example
|
|
80
80
|
* ```ts
|
|
81
|
-
* const
|
|
81
|
+
* const result = await youtube.search("Keyword");
|
|
82
82
|
*
|
|
83
|
-
* console.log(
|
|
83
|
+
* console.log(result.items); // search result from first page
|
|
84
84
|
*
|
|
85
|
-
* let nextSearchResult = await
|
|
85
|
+
* let nextSearchResult = await result.next();
|
|
86
86
|
* console.log(nextSearchResult); // search result from second page
|
|
87
87
|
*
|
|
88
|
-
* nextSearchResult = await
|
|
88
|
+
* nextSearchResult = await result.next();
|
|
89
89
|
* console.log(nextSearchResult); // search result from third page
|
|
90
90
|
*
|
|
91
|
-
* console.log(
|
|
91
|
+
* console.log(result.items); // search result from first, second, and third page.
|
|
92
92
|
* ```
|
|
93
93
|
*
|
|
94
94
|
* @noInheritDoc
|
|
95
95
|
*/
|
|
96
|
-
var
|
|
97
|
-
__extends(
|
|
96
|
+
var SearchResult = /** @class */ (function (_super) {
|
|
97
|
+
__extends(SearchResult, _super);
|
|
98
98
|
/** @hidden */
|
|
99
|
-
function
|
|
99
|
+
function SearchResult(_a) {
|
|
100
100
|
var client = _a.client;
|
|
101
101
|
return _super.call(this, { client: client }) || this;
|
|
102
102
|
}
|
|
@@ -105,8 +105,10 @@ var SearchManager = /** @class */ (function (_super) {
|
|
|
105
105
|
*
|
|
106
106
|
* @param query Search query
|
|
107
107
|
* @param options Search Options
|
|
108
|
+
*
|
|
109
|
+
* @hidden
|
|
108
110
|
*/
|
|
109
|
-
|
|
111
|
+
SearchResult.prototype.search = function (query, options) {
|
|
110
112
|
return __awaiter(this, void 0, void 0, function () {
|
|
111
113
|
var bufferParams, response, _a, data, continuation;
|
|
112
114
|
var _b;
|
|
@@ -135,7 +137,7 @@ var SearchManager = /** @class */ (function (_super) {
|
|
|
135
137
|
});
|
|
136
138
|
});
|
|
137
139
|
};
|
|
138
|
-
|
|
140
|
+
SearchResult.prototype.fetch = function () {
|
|
139
141
|
return __awaiter(this, void 0, void 0, function () {
|
|
140
142
|
var response, _a, data, continuation;
|
|
141
143
|
return __generator(this, function (_b) {
|
|
@@ -154,6 +156,6 @@ var SearchManager = /** @class */ (function (_super) {
|
|
|
154
156
|
});
|
|
155
157
|
});
|
|
156
158
|
};
|
|
157
|
-
return
|
|
159
|
+
return SearchResult;
|
|
158
160
|
}(Continuable));
|
|
159
|
-
export {
|
|
161
|
+
export { SearchResult };
|
package/dist/esm/classes/{SearchManager/SearchManagerParser.js → SearchResult/SearchResultParser.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export * from "./Base";
|
|
2
|
+
export * from "./BaseChannel";
|
|
2
3
|
export * from "./BaseVideo";
|
|
3
4
|
export * from "./Channel";
|
|
4
|
-
export * from "./BaseChannel";
|
|
5
5
|
export * from "./Chat";
|
|
6
6
|
export * from "./Client";
|
|
7
|
-
export * from "./Continuable";
|
|
8
7
|
export * from "./Comment";
|
|
8
|
+
export * from "./Continuable";
|
|
9
9
|
export * from "./LiveVideo";
|
|
10
10
|
export * from "./MixPlaylist";
|
|
11
11
|
export * from "./Playlist";
|
|
12
12
|
export * from "./PlaylistCompact";
|
|
13
13
|
export * from "./Reply";
|
|
14
|
-
export * from "./
|
|
14
|
+
export * from "./SearchResult";
|
|
15
15
|
export * from "./Thumbnails";
|
|
16
16
|
export * from "./Video";
|
|
17
17
|
export * from "./VideoCompact";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { YoutubeRawData } from "../../common";
|
|
2
2
|
import { BaseChannel } from "./BaseChannel";
|
|
3
3
|
export declare class BaseChannelParser {
|
|
4
|
+
static TAB_TYPE_PARAMS: {
|
|
5
|
+
readonly videos: "EgZ2aWRlb3M%3D";
|
|
6
|
+
readonly playlists: "EglwbGF5bGlzdHM%3D";
|
|
7
|
+
};
|
|
4
8
|
static loadBaseChannel(target: BaseChannel, data: YoutubeRawData): BaseChannel;
|
|
5
9
|
/** Parse tab data from request, tab name is ignored if it's a continuation data */
|
|
6
10
|
static parseTabData(name: "videos" | "playlists", data: YoutubeRawData): YoutubeRawData;
|
|
@@ -3,7 +3,7 @@ import { Channel } from "../Channel";
|
|
|
3
3
|
import { LiveVideo } from "../LiveVideo";
|
|
4
4
|
import { MixPlaylist } from "../MixPlaylist";
|
|
5
5
|
import { Playlist } from "../Playlist";
|
|
6
|
-
import { SearchOptions,
|
|
6
|
+
import { SearchOptions, SearchResult, SearchResultItem } from "../SearchResult";
|
|
7
7
|
import { Video } from "../Video";
|
|
8
8
|
import { HTTP } from "./HTTP";
|
|
9
9
|
export declare type ClientOptions = {
|
|
@@ -25,13 +25,13 @@ export declare class Client {
|
|
|
25
25
|
* @param options Search options
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
|
-
search<T extends SearchOptions>(query: string, options?: T): Promise<
|
|
28
|
+
search<T extends SearchOptions>(query: string, options?: T): Promise<SearchResult<T["type"]>>;
|
|
29
29
|
/**
|
|
30
30
|
* Search for videos / playlists / channels and returns the first result
|
|
31
31
|
*
|
|
32
32
|
* @return Can be {@link VideoCompact} | {@link PlaylistCompact} | {@link BaseChannel} | `undefined`
|
|
33
33
|
*/
|
|
34
|
-
findOne<T extends SearchOptions>(query: string, options?: T): Promise<
|
|
34
|
+
findOne<T extends SearchOptions>(query: string, options?: T): Promise<SearchResultItem<T["type"]> | undefined>;
|
|
35
35
|
/** Get playlist information and its videos by playlist id or URL */
|
|
36
36
|
getPlaylist<T extends Playlist | MixPlaylist | undefined>(playlistId: string): Promise<T>;
|
|
37
37
|
/** Get video information by video id or URL */
|
package/dist/typings/classes/{SearchManager/SearchManager.d.ts → SearchResult/SearchResult.d.ts}
RENAMED
|
@@ -12,30 +12,30 @@ export declare type SearchUploadDate = "all" | "hour" | "today" | "week" | "mont
|
|
|
12
12
|
export declare type SearchType = "all" | "video" | "channel" | "playlist";
|
|
13
13
|
export declare type SearchDuration = "all" | "short" | "medium" | "long";
|
|
14
14
|
export declare type SearchSort = "relevance" | "rating" | "date" | "view";
|
|
15
|
-
export declare type
|
|
15
|
+
export declare type SearchResultItem<T = "all"> = T extends "video" | VideoCompact ? VideoCompact : T extends "channel" | BaseChannel ? BaseChannel : T extends "playlist" | PlaylistCompact ? PlaylistCompact : VideoCompact | BaseChannel | PlaylistCompact;
|
|
16
16
|
/**
|
|
17
17
|
* Represents search result, usually returned from `client.search();`.
|
|
18
18
|
*
|
|
19
|
-
* {@link
|
|
19
|
+
* {@link SearchResult} is a helper class to manage search result
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
23
|
-
* const
|
|
23
|
+
* const result = await youtube.search("Keyword");
|
|
24
24
|
*
|
|
25
|
-
* console.log(
|
|
25
|
+
* console.log(result.items); // search result from first page
|
|
26
26
|
*
|
|
27
|
-
* let nextSearchResult = await
|
|
27
|
+
* let nextSearchResult = await result.next();
|
|
28
28
|
* console.log(nextSearchResult); // search result from second page
|
|
29
29
|
*
|
|
30
|
-
* nextSearchResult = await
|
|
30
|
+
* nextSearchResult = await result.next();
|
|
31
31
|
* console.log(nextSearchResult); // search result from third page
|
|
32
32
|
*
|
|
33
|
-
* console.log(
|
|
33
|
+
* console.log(result.items); // search result from first, second, and third page.
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
36
|
* @noInheritDoc
|
|
37
37
|
*/
|
|
38
|
-
export declare class
|
|
38
|
+
export declare class SearchResult<T extends SearchType | undefined = "all"> extends Continuable<SearchResultItem<T>> {
|
|
39
39
|
/** The estimated search result count */
|
|
40
40
|
estimatedResults: number;
|
|
41
41
|
/** @hidden */
|
|
@@ -45,7 +45,9 @@ export declare class SearchManager<T extends SearchType | undefined = "all"> ext
|
|
|
45
45
|
*
|
|
46
46
|
* @param query Search query
|
|
47
47
|
* @param options Search Options
|
|
48
|
+
*
|
|
49
|
+
* @hidden
|
|
48
50
|
*/
|
|
49
|
-
search(query: string, options: SearchOptions): Promise<
|
|
50
|
-
protected fetch(): Promise<FetchResult<
|
|
51
|
+
search(query: string, options: SearchOptions): Promise<SearchResult<T>>;
|
|
52
|
+
protected fetch(): Promise<FetchResult<SearchResultItem<T>>>;
|
|
51
53
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { YoutubeRawData } from "../../common";
|
|
2
2
|
import { Client } from "../Client";
|
|
3
|
-
import {
|
|
3
|
+
import { SearchResultItem } from "./SearchResult";
|
|
4
4
|
declare type ParseReturnType = {
|
|
5
|
-
data:
|
|
5
|
+
data: SearchResultItem[];
|
|
6
6
|
continuation: string | undefined;
|
|
7
7
|
};
|
|
8
8
|
export declare class SearchResultParser {
|
|
File without changes
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export * from "./Base";
|
|
2
|
+
export * from "./BaseChannel";
|
|
2
3
|
export * from "./BaseVideo";
|
|
3
4
|
export * from "./Channel";
|
|
4
|
-
export * from "./BaseChannel";
|
|
5
5
|
export * from "./Chat";
|
|
6
6
|
export * from "./Client";
|
|
7
|
-
export * from "./Continuable";
|
|
8
7
|
export * from "./Comment";
|
|
8
|
+
export * from "./Continuable";
|
|
9
9
|
export * from "./LiveVideo";
|
|
10
10
|
export * from "./MixPlaylist";
|
|
11
11
|
export * from "./Playlist";
|
|
12
12
|
export * from "./PlaylistCompact";
|
|
13
13
|
export * from "./Reply";
|
|
14
|
-
export * from "./
|
|
14
|
+
export * from "./SearchResult";
|
|
15
15
|
export * from "./Thumbnails";
|
|
16
16
|
export * from "./Video";
|
|
17
17
|
export * from "./VideoCompact";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
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",
|