youtubei 0.0.1-rc.9 → 1.0.0-rc.1
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/LICENSE +21 -21
- package/README.md +50 -53
- package/dist/cjs/classes/Base/Base.js +10 -0
- package/dist/cjs/classes/Base/index.js +13 -0
- package/dist/cjs/classes/BaseChannel/BaseChannel.js +31 -0
- package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +24 -0
- package/dist/cjs/classes/BaseChannel/ChannelPlaylists.js +57 -0
- package/dist/cjs/classes/BaseChannel/ChannelVideos.js +57 -0
- package/dist/cjs/classes/BaseChannel/index.js +16 -0
- package/dist/cjs/classes/BaseVideo/BaseVideo.js +34 -0
- package/dist/cjs/classes/BaseVideo/BaseVideoParser.js +82 -0
- package/dist/cjs/classes/BaseVideo/VideoRelated.js +39 -0
- package/dist/cjs/classes/BaseVideo/index.js +15 -0
- package/dist/cjs/classes/Channel/Channel.js +24 -0
- package/dist/cjs/classes/Channel/ChannelParser.js +55 -0
- package/dist/cjs/classes/Channel/index.js +13 -0
- package/dist/cjs/classes/Chat/Chat.js +23 -0
- package/dist/cjs/classes/Chat/ChatParser.js +21 -0
- package/dist/cjs/classes/Chat/index.js +13 -0
- package/dist/cjs/classes/Client/Client.js +101 -0
- package/dist/cjs/classes/Client/HTTP.js +59 -0
- package/dist/cjs/classes/Client/index.js +13 -0
- package/dist/cjs/classes/Comment/Comment.js +29 -0
- package/dist/cjs/classes/Comment/CommentParser.js +43 -0
- package/dist/cjs/classes/Comment/CommentReplies.js +36 -0
- package/dist/cjs/classes/Comment/index.js +13 -0
- package/dist/cjs/classes/Continuable/Continuable.js +43 -0
- package/dist/cjs/classes/Continuable/index.js +13 -0
- package/dist/{classes → cjs/classes/LiveVideo}/LiveVideo.js +84 -89
- package/dist/cjs/classes/LiveVideo/LiveVideoParser.js +29 -0
- package/dist/cjs/classes/LiveVideo/index.js +14 -0
- package/dist/cjs/classes/MixPlaylist/MixPlaylist.js +25 -0
- package/dist/cjs/classes/MixPlaylist/MixPlaylistParser.js +27 -0
- package/dist/cjs/classes/MixPlaylist/index.js +14 -0
- package/dist/cjs/classes/Playlist/Playlist.js +25 -0
- package/dist/cjs/classes/Playlist/PlaylistParser.js +83 -0
- package/dist/cjs/classes/Playlist/PlaylistVideos.js +50 -0
- package/dist/cjs/classes/Playlist/index.js +15 -0
- package/dist/cjs/classes/PlaylistCompact/PlaylistCompact.js +45 -0
- package/dist/cjs/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
- package/dist/cjs/classes/PlaylistCompact/index.js +14 -0
- package/dist/cjs/classes/Reply/Reply.js +23 -0
- package/dist/cjs/classes/Reply/ReplyParser.js +26 -0
- package/dist/cjs/classes/Reply/index.js +14 -0
- package/dist/cjs/classes/SearchManager/SearchManager.js +83 -0
- package/dist/cjs/classes/SearchManager/SearchManagerParser.js +40 -0
- package/dist/cjs/classes/SearchManager/index.js +14 -0
- package/dist/{classes/Base.js → cjs/classes/SearchManager/proto/SearchProto.js} +2 -5
- package/dist/cjs/classes/SearchManager/proto/index.js +57 -0
- package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -66
- package/dist/cjs/classes/Thumbnails/index.js +13 -0
- package/dist/cjs/classes/Video/Video.js +26 -0
- package/dist/cjs/classes/Video/VideoComments.js +53 -0
- package/dist/cjs/classes/Video/VideoParser.js +29 -0
- package/dist/cjs/classes/Video/index.js +14 -0
- package/dist/cjs/classes/VideoCompact/VideoCompact.js +49 -0
- package/dist/cjs/classes/VideoCompact/VideoCompactParser.js +36 -0
- package/dist/cjs/classes/VideoCompact/index.js +14 -0
- package/dist/cjs/classes/index.js +29 -0
- package/dist/{common → cjs/common}/decorators.js +14 -14
- package/dist/cjs/common/helper.js +45 -0
- package/dist/{common → cjs/common}/index.js +16 -23
- package/dist/{common → cjs/common}/mixins.js +14 -12
- package/dist/{common → cjs/common}/types.js +2 -2
- package/dist/{constants.js → cjs/constants.js} +10 -10
- package/dist/{index.js → cjs/index.js} +13 -13
- package/dist/esm/classes/Base/Base.js +8 -0
- package/dist/esm/classes/Base/index.js +1 -0
- package/dist/esm/classes/BaseChannel/BaseChannel.js +48 -0
- package/dist/esm/classes/BaseChannel/BaseChannelParser.js +24 -0
- package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +109 -0
- package/dist/esm/classes/BaseChannel/ChannelVideos.js +109 -0
- package/dist/esm/classes/BaseChannel/index.js +4 -0
- package/dist/esm/classes/BaseVideo/BaseVideo.js +51 -0
- package/dist/esm/classes/BaseVideo/BaseVideoParser.js +93 -0
- package/dist/esm/classes/BaseVideo/VideoRelated.js +87 -0
- package/dist/esm/classes/BaseVideo/index.js +3 -0
- package/dist/esm/classes/Channel/Channel.js +37 -0
- package/dist/esm/classes/Channel/ChannelParser.js +77 -0
- package/dist/esm/classes/Channel/index.js +1 -0
- package/dist/esm/classes/Chat/Chat.js +36 -0
- package/dist/esm/classes/Chat/ChatParser.js +21 -0
- package/dist/esm/classes/Chat/index.js +1 -0
- package/dist/esm/classes/Client/Client.js +176 -0
- package/dist/esm/classes/Client/HTTP.js +112 -0
- package/dist/esm/classes/Client/index.js +1 -0
- package/dist/esm/classes/Comment/Comment.js +46 -0
- package/dist/esm/classes/Comment/CommentParser.js +45 -0
- package/dist/esm/classes/Comment/CommentReplies.js +84 -0
- package/dist/esm/classes/Comment/index.js +1 -0
- package/dist/esm/classes/Continuable/Continuable.js +125 -0
- package/dist/esm/classes/Continuable/index.js +1 -0
- package/dist/esm/classes/LiveVideo/LiveVideo.js +160 -0
- package/dist/esm/classes/LiveVideo/LiveVideoParser.js +29 -0
- package/dist/esm/classes/LiveVideo/index.js +2 -0
- package/dist/esm/classes/MixPlaylist/MixPlaylist.js +38 -0
- package/dist/esm/classes/MixPlaylist/MixPlaylistParser.js +49 -0
- package/dist/esm/classes/MixPlaylist/index.js +2 -0
- package/dist/esm/classes/Playlist/Playlist.js +38 -0
- package/dist/esm/classes/Playlist/PlaylistParser.js +105 -0
- package/dist/esm/classes/Playlist/PlaylistVideos.js +98 -0
- package/dist/esm/classes/Playlist/index.js +3 -0
- package/dist/esm/classes/PlaylistCompact/PlaylistCompact.js +90 -0
- package/dist/esm/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
- package/dist/esm/classes/PlaylistCompact/index.js +2 -0
- package/dist/esm/classes/Reply/Reply.js +36 -0
- package/dist/esm/classes/Reply/ReplyParser.js +26 -0
- package/dist/esm/classes/Reply/index.js +2 -0
- package/dist/esm/classes/SearchManager/SearchManager.js +159 -0
- package/dist/esm/classes/SearchManager/SearchManagerParser.js +62 -0
- package/dist/esm/classes/SearchManager/index.js +2 -0
- package/dist/esm/classes/SearchManager/proto/SearchProto.js +1 -0
- package/dist/esm/classes/SearchManager/proto/index.js +39 -0
- package/dist/esm/classes/Thumbnails/Thumbnails.js +109 -0
- package/dist/esm/classes/Thumbnails/index.js +1 -0
- package/dist/esm/classes/Video/Video.js +39 -0
- package/dist/esm/classes/Video/VideoComments.js +101 -0
- package/dist/esm/classes/Video/VideoParser.js +31 -0
- package/dist/esm/classes/Video/index.js +2 -0
- package/dist/esm/classes/VideoCompact/VideoCompact.js +98 -0
- package/dist/esm/classes/VideoCompact/VideoCompactParser.js +36 -0
- package/dist/esm/classes/VideoCompact/index.js +2 -0
- package/dist/esm/classes/index.js +17 -0
- package/dist/esm/common/decorators.js +30 -0
- package/dist/esm/common/helper.js +61 -0
- package/dist/esm/common/index.js +4 -0
- package/dist/esm/common/mixins.js +10 -0
- package/dist/esm/common/types.js +1 -0
- package/dist/esm/constants.js +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/typings/classes/Base/Base.d.ts +11 -0
- package/dist/typings/classes/Base/index.d.ts +1 -0
- package/dist/typings/classes/BaseChannel/BaseChannel.d.ts +43 -0
- package/dist/typings/classes/BaseChannel/BaseChannelParser.d.ts +7 -0
- package/dist/typings/classes/BaseChannel/ChannelPlaylists.d.ts +30 -0
- package/dist/typings/classes/BaseChannel/ChannelVideos.d.ts +30 -0
- package/dist/typings/classes/BaseChannel/index.d.ts +4 -0
- package/dist/typings/classes/BaseVideo/BaseVideo.d.ts +59 -0
- package/dist/typings/classes/BaseVideo/BaseVideoParser.d.ts +14 -0
- package/dist/typings/classes/BaseVideo/VideoRelated.d.ts +21 -0
- package/dist/typings/classes/BaseVideo/index.d.ts +3 -0
- package/dist/typings/classes/Channel/Channel.d.ts +33 -0
- package/dist/typings/classes/Channel/ChannelParser.d.ts +6 -0
- package/dist/typings/classes/Channel/index.d.ts +1 -0
- package/dist/typings/classes/Chat/Chat.d.ts +33 -0
- package/dist/typings/classes/Chat/ChatParser.d.ts +5 -0
- package/dist/typings/classes/Chat/index.d.ts +1 -0
- package/dist/typings/classes/Client/Client.d.ts +41 -0
- package/dist/typings/classes/Client/HTTP.d.ts +21 -0
- package/dist/typings/classes/Client/index.d.ts +1 -0
- package/dist/typings/classes/Comment/Comment.d.ts +51 -0
- package/dist/typings/classes/Comment/CommentParser.d.ts +8 -0
- package/dist/typings/classes/Comment/CommentReplies.d.ts +17 -0
- package/dist/typings/classes/Comment/index.d.ts +1 -0
- package/dist/typings/classes/Continuable/Continuable.d.ts +24 -0
- package/dist/typings/classes/Continuable/index.d.ts +1 -0
- package/dist/{classes → typings/classes/LiveVideo}/LiveVideo.d.ts +46 -44
- package/dist/typings/classes/LiveVideo/LiveVideoParser.d.ts +10 -0
- package/dist/typings/classes/LiveVideo/index.d.ts +2 -0
- package/dist/typings/classes/MixPlaylist/MixPlaylist.d.ts +29 -0
- package/dist/typings/classes/MixPlaylist/MixPlaylistParser.d.ts +6 -0
- package/dist/typings/classes/MixPlaylist/index.d.ts +2 -0
- package/dist/typings/classes/Playlist/Playlist.d.ts +39 -0
- package/dist/typings/classes/Playlist/PlaylistParser.d.ts +16 -0
- package/dist/typings/classes/Playlist/PlaylistVideos.d.ts +31 -0
- package/dist/typings/classes/Playlist/index.d.ts +3 -0
- package/dist/typings/classes/PlaylistCompact/PlaylistCompact.d.ts +43 -0
- package/dist/typings/classes/PlaylistCompact/PlaylistCompactParser.d.ts +5 -0
- package/dist/typings/classes/PlaylistCompact/index.d.ts +2 -0
- package/dist/typings/classes/Reply/Reply.d.ts +43 -0
- package/dist/typings/classes/Reply/ReplyParser.d.ts +5 -0
- package/dist/typings/classes/Reply/index.d.ts +2 -0
- package/dist/typings/classes/SearchManager/SearchManager.d.ts +51 -0
- package/dist/typings/classes/SearchManager/SearchManagerParser.d.ts +13 -0
- package/dist/typings/classes/SearchManager/index.d.ts +2 -0
- package/dist/typings/classes/SearchManager/proto/SearchProto.d.ts +13 -0
- package/dist/typings/classes/SearchManager/proto/index.d.ts +24 -0
- package/dist/{classes → typings/classes/Thumbnails}/Thumbnails.d.ts +41 -42
- package/dist/typings/classes/Thumbnails/index.d.ts +1 -0
- package/dist/typings/classes/Video/Video.d.ts +24 -0
- package/dist/typings/classes/Video/VideoComments.d.ts +34 -0
- package/dist/typings/classes/Video/VideoParser.d.ts +8 -0
- package/dist/typings/classes/Video/index.d.ts +2 -0
- package/dist/typings/classes/VideoCompact/VideoCompact.d.ts +57 -0
- package/dist/typings/classes/VideoCompact/VideoCompactParser.d.ts +5 -0
- package/dist/typings/classes/VideoCompact/index.d.ts +2 -0
- package/dist/typings/classes/index.d.ts +17 -0
- package/dist/{common → typings/common}/decorators.d.ts +5 -5
- package/dist/typings/common/helper.d.ts +5 -0
- package/dist/typings/common/index.d.ts +4 -0
- package/dist/typings/common/mixins.d.ts +1 -0
- package/dist/{common → typings/common}/types.d.ts +1 -1
- package/dist/{constants.d.ts → typings/constants.d.ts} +7 -7
- package/dist/{index.d.ts → typings/index.d.ts} +1 -1
- package/package.json +68 -53
- package/CHANGELOG.md +0 -6
- package/dist/classes/Base.d.ts +0 -7
- package/dist/classes/BaseVideo.d.ts +0 -54
- package/dist/classes/BaseVideo.js +0 -82
- package/dist/classes/Channel.d.ts +0 -83
- package/dist/classes/Channel.js +0 -138
- package/dist/classes/Chat.d.ts +0 -29
- package/dist/classes/Chat.js +0 -31
- package/dist/classes/Client.d.ts +0 -30
- package/dist/classes/Client.js +0 -69
- package/dist/classes/Comment.d.ts +0 -43
- package/dist/classes/Comment.js +0 -42
- package/dist/classes/Playlist.d.ts +0 -61
- package/dist/classes/Playlist.js +0 -127
- package/dist/classes/PlaylistCompact.d.ts +0 -30
- package/dist/classes/PlaylistCompact.js +0 -45
- package/dist/classes/SearchResult.d.ts +0 -69
- package/dist/classes/SearchResult.js +0 -139
- package/dist/classes/Video.d.ts +0 -49
- package/dist/classes/Video.js +0 -102
- package/dist/classes/VideoCompact.d.ts +0 -40
- package/dist/classes/VideoCompact.js +0 -50
- package/dist/classes/index.d.ts +0 -13
- package/dist/classes/index.js +0 -32
- package/dist/common/helper.d.ts +0 -2
- package/dist/common/helper.js +0 -37
- package/dist/common/http.d.ts +0 -30
- package/dist/common/http.js +0 -108
- package/dist/common/index.d.ts +0 -5
- package/dist/common/mixins.d.ts +0 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MixPlaylist = void 0;
|
|
4
|
+
const Base_1 = require("../Base");
|
|
5
|
+
const MixPlaylistParser_1 = require("./MixPlaylistParser");
|
|
6
|
+
/** Represents a MixPlaylist, usually returned from `client.getPlaylist()` */
|
|
7
|
+
class MixPlaylist extends Base_1.Base {
|
|
8
|
+
/** @hidden */
|
|
9
|
+
constructor(attr) {
|
|
10
|
+
super(attr.client);
|
|
11
|
+
/** How many viewers does this playlist have */
|
|
12
|
+
this.videos = [];
|
|
13
|
+
Object.assign(this, attr);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load this instance with raw data from Youtube
|
|
17
|
+
*
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
load(data) {
|
|
21
|
+
MixPlaylistParser_1.MixPlaylistParser.loadMixPlaylist(this, data);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.MixPlaylist = MixPlaylist;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MixPlaylistParser = void 0;
|
|
4
|
+
const VideoCompact_1 = require("../VideoCompact");
|
|
5
|
+
class MixPlaylistParser {
|
|
6
|
+
static loadMixPlaylist(target, data) {
|
|
7
|
+
const twoColumnWatchNextResults = data.contents.twoColumnWatchNextResults;
|
|
8
|
+
const playlist = twoColumnWatchNextResults.playlist.playlist;
|
|
9
|
+
target.title = playlist.titleText.simpleText;
|
|
10
|
+
target.id = playlist.playlistId;
|
|
11
|
+
target.videoCount = playlist.contents.length;
|
|
12
|
+
target.videos = MixPlaylistParser.parseVideos(playlist.contents, target.client);
|
|
13
|
+
return target;
|
|
14
|
+
}
|
|
15
|
+
static parseVideos(data, client) {
|
|
16
|
+
const videosRenderer = data.map((c) => c.playlistPanelVideoRenderer);
|
|
17
|
+
const videos = [];
|
|
18
|
+
for (const videoRenderer of videosRenderer) {
|
|
19
|
+
if (!videoRenderer)
|
|
20
|
+
continue;
|
|
21
|
+
const video = new VideoCompact_1.VideoCompact({ client }).load(videoRenderer);
|
|
22
|
+
videos.push(video);
|
|
23
|
+
}
|
|
24
|
+
return videos;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.MixPlaylistParser = MixPlaylistParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./MixPlaylist"), exports);
|
|
14
|
+
__exportStar(require("./MixPlaylistParser"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Playlist = void 0;
|
|
4
|
+
const Base_1 = require("../Base");
|
|
5
|
+
const PlaylistParser_1 = require("./PlaylistParser");
|
|
6
|
+
const PlaylistVideos_1 = require("./PlaylistVideos");
|
|
7
|
+
/** Represents a Playlist, usually returned from `client.getPlaylist()` */
|
|
8
|
+
class Playlist extends Base_1.Base {
|
|
9
|
+
/** @hidden */
|
|
10
|
+
constructor(attr) {
|
|
11
|
+
super(attr.client);
|
|
12
|
+
Object.assign(this, attr);
|
|
13
|
+
this.videos = new PlaylistVideos_1.PlaylistVideos({ client: attr.client, playlist: this });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load this instance with raw data from Youtube
|
|
17
|
+
*
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
load(data) {
|
|
21
|
+
PlaylistParser_1.PlaylistParser.loadPlaylist(this, data);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.Playlist = Playlist;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaylistParser = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
6
|
+
const Thumbnails_1 = require("../Thumbnails");
|
|
7
|
+
const VideoCompact_1 = require("../VideoCompact");
|
|
8
|
+
class PlaylistParser {
|
|
9
|
+
static loadPlaylist(target, data) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const sidebarRenderer = data.sidebar.playlistSidebarRenderer.items;
|
|
12
|
+
const primaryRenderer = sidebarRenderer[0].playlistSidebarPrimaryInfoRenderer;
|
|
13
|
+
const metadata = data.metadata.playlistMetadataRenderer;
|
|
14
|
+
// Basic information
|
|
15
|
+
target.id = (_a = Object.values(metadata)
|
|
16
|
+
.find((v) => v.includes("playlist?list="))) === null || _a === void 0 ? void 0 : _a.split("=")[1];
|
|
17
|
+
target.title = metadata.title;
|
|
18
|
+
const { stats } = primaryRenderer;
|
|
19
|
+
if (primaryRenderer.stats.length === 3) {
|
|
20
|
+
target.videoCount = PlaylistParser.parseSideBarInfo(stats[0], true);
|
|
21
|
+
target.viewCount = PlaylistParser.parseSideBarInfo(stats[1], true);
|
|
22
|
+
target.lastUpdatedAt = PlaylistParser.parseSideBarInfo(stats[2], false);
|
|
23
|
+
}
|
|
24
|
+
else if (stats.length === 2) {
|
|
25
|
+
target.videoCount = PlaylistParser.parseSideBarInfo(stats[0], true);
|
|
26
|
+
target.lastUpdatedAt = PlaylistParser.parseSideBarInfo(stats[1], false);
|
|
27
|
+
}
|
|
28
|
+
const playlistContents = ((_b = data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
|
|
29
|
+
.sectionListRenderer.contents[0].itemSectionRenderer.contents[0]
|
|
30
|
+
.playlistVideoListRenderer) === null || _b === void 0 ? void 0 : _b.contents) || [];
|
|
31
|
+
// Channel
|
|
32
|
+
const videoOwner = (_c = sidebarRenderer[1]) === null || _c === void 0 ? void 0 : _c.playlistSidebarSecondaryInfoRenderer.videoOwner;
|
|
33
|
+
if (videoOwner) {
|
|
34
|
+
const { title, thumbnail } = videoOwner.videoOwnerRenderer;
|
|
35
|
+
target.channel = new BaseChannel_1.BaseChannel({
|
|
36
|
+
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
37
|
+
name: title.runs[0].text,
|
|
38
|
+
thumbnails: new Thumbnails_1.Thumbnails().load(thumbnail.thumbnails),
|
|
39
|
+
client: target.client,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Videos
|
|
43
|
+
target.videos.items = PlaylistParser.parseVideos(playlistContents, target);
|
|
44
|
+
target.videos.continuation = common_1.getContinuationFromItems(playlistContents);
|
|
45
|
+
return target;
|
|
46
|
+
}
|
|
47
|
+
static parseVideoContinuation(data) {
|
|
48
|
+
const playlistContents = data.onResponseReceivedActions[0].appendContinuationItemsAction.continuationItems;
|
|
49
|
+
return common_1.getContinuationFromItems(playlistContents);
|
|
50
|
+
}
|
|
51
|
+
static parseContinuationVideos(data, client) {
|
|
52
|
+
const playlistContents = data.onResponseReceivedActions[0].appendContinuationItemsAction.continuationItems;
|
|
53
|
+
const videos = common_1.mapFilter(playlistContents, "playlistVideoRenderer");
|
|
54
|
+
return videos.map((video) => new VideoCompact_1.VideoCompact({ client }).load(video));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get compact videos
|
|
58
|
+
*
|
|
59
|
+
* @param playlistContents raw object from youtubei
|
|
60
|
+
*/
|
|
61
|
+
static parseVideos(playlistContents, playlist) {
|
|
62
|
+
const videosRenderer = playlistContents.map((c) => c.playlistVideoRenderer);
|
|
63
|
+
const videos = [];
|
|
64
|
+
for (const videoRenderer of videosRenderer) {
|
|
65
|
+
if (!videoRenderer)
|
|
66
|
+
continue;
|
|
67
|
+
const video = new VideoCompact_1.VideoCompact({ client: playlist.client }).load(videoRenderer);
|
|
68
|
+
videos.push(video);
|
|
69
|
+
}
|
|
70
|
+
return videos;
|
|
71
|
+
}
|
|
72
|
+
static parseSideBarInfo(stats, parseInt) {
|
|
73
|
+
let data;
|
|
74
|
+
if ("runs" in stats)
|
|
75
|
+
data = stats.runs.map((r) => r.text).join("");
|
|
76
|
+
else
|
|
77
|
+
data = stats.simpleText.replace(/[^0-9]/g, "");
|
|
78
|
+
if (parseInt)
|
|
79
|
+
data = +data.replace(/[^0-9]/g, "");
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.PlaylistParser = PlaylistParser;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PlaylistVideos = void 0;
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
14
|
+
const Continuable_1 = require("../Continuable");
|
|
15
|
+
const PlaylistParser_1 = require("./PlaylistParser");
|
|
16
|
+
/**
|
|
17
|
+
* {@link Continuable} of videos inside a {@link Playlist}
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* const playlist = await youtube.getPlaylist(PLAYLIST_ID);
|
|
22
|
+
* console.log(playlist.videos) // first 100 videos
|
|
23
|
+
*
|
|
24
|
+
* let newVideos = await playlist.videos.next();
|
|
25
|
+
* console.log(newVideos) // 100 loaded videos
|
|
26
|
+
* console.log(playlist.videos) // first 200 videos
|
|
27
|
+
*
|
|
28
|
+
* await playlist.videos.next(0); // load the rest of the videos in the playlist
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param count How many times to load the next videos. Set 0 to load all videos (might take a while on a large playlist!)
|
|
32
|
+
*/
|
|
33
|
+
class PlaylistVideos extends Continuable_1.Continuable {
|
|
34
|
+
/** @hidden */
|
|
35
|
+
constructor({ client, playlist }) {
|
|
36
|
+
super({ client, strictContinuationCheck: true });
|
|
37
|
+
this.playlist = playlist;
|
|
38
|
+
}
|
|
39
|
+
fetch() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
42
|
+
data: { continuation: this.continuation },
|
|
43
|
+
});
|
|
44
|
+
const items = PlaylistParser_1.PlaylistParser.parseContinuationVideos(response.data, this.client);
|
|
45
|
+
const continuation = PlaylistParser_1.PlaylistParser.parseVideoContinuation(response.data);
|
|
46
|
+
return { continuation, items };
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.PlaylistVideos = PlaylistVideos;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Playlist"), exports);
|
|
14
|
+
__exportStar(require("./PlaylistParser"), exports);
|
|
15
|
+
__exportStar(require("./PlaylistVideos"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PlaylistCompact = void 0;
|
|
13
|
+
const Base_1 = require("../Base");
|
|
14
|
+
const PlaylistCompactParser_1 = require("./PlaylistCompactParser");
|
|
15
|
+
/** Represents a Compact Playlist (e.g. from search result, related of a video) */
|
|
16
|
+
class PlaylistCompact extends Base_1.Base {
|
|
17
|
+
/** @hidden */
|
|
18
|
+
constructor(attr) {
|
|
19
|
+
super(attr.client);
|
|
20
|
+
Object.assign(this, attr);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Load this instance with raw data from Youtube
|
|
24
|
+
*
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
27
|
+
load(data) {
|
|
28
|
+
PlaylistCompactParser_1.PlaylistCompactParser.loadPlaylistCompact(this, data);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get {@link Playlist} object based on current playlist id
|
|
33
|
+
*
|
|
34
|
+
* Equivalent to
|
|
35
|
+
* ```js
|
|
36
|
+
* client.getPlaylist(playlistCompact.id);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
getPlaylist() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return yield this.client.getPlaylist(this.id);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.PlaylistCompact = PlaylistCompact;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaylistCompactParser = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
6
|
+
const Thumbnails_1 = require("../Thumbnails");
|
|
7
|
+
class PlaylistCompactParser {
|
|
8
|
+
static loadPlaylistCompact(target, data) {
|
|
9
|
+
var _a;
|
|
10
|
+
const { playlistId, title, thumbnail, shortBylineText, videoCount, videoCountShortText, } = data;
|
|
11
|
+
target.id = playlistId;
|
|
12
|
+
target.title = title.simpleText || title.runs[0].text;
|
|
13
|
+
target.videoCount = common_1.stripToInt(videoCount || videoCountShortText.simpleText) || 0;
|
|
14
|
+
// Thumbnail
|
|
15
|
+
target.thumbnails = new Thumbnails_1.Thumbnails().load(((_a = data.thumbnails) === null || _a === void 0 ? void 0 : _a[0].thumbnails) || thumbnail.thumbnails);
|
|
16
|
+
// Channel
|
|
17
|
+
if (shortBylineText && shortBylineText.simpleText !== "YouTube") {
|
|
18
|
+
const shortByLine = shortBylineText.runs[0];
|
|
19
|
+
target.channel = new BaseChannel_1.BaseChannel({
|
|
20
|
+
id: shortByLine.navigationEndpoint.browseEndpoint.browseId,
|
|
21
|
+
name: shortByLine.text,
|
|
22
|
+
client: target.client,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.PlaylistCompactParser = PlaylistCompactParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./PlaylistCompact"), exports);
|
|
14
|
+
__exportStar(require("./PlaylistCompactParser"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reply = void 0;
|
|
4
|
+
const Base_1 = require("../Base");
|
|
5
|
+
const ReplyParser_1 = require("./ReplyParser");
|
|
6
|
+
/** Represents a Reply */
|
|
7
|
+
class Reply extends Base_1.Base {
|
|
8
|
+
/** @hidden */
|
|
9
|
+
constructor(attr) {
|
|
10
|
+
super(attr.client);
|
|
11
|
+
Object.assign(this, attr);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Load this instance with raw data from Youtube
|
|
15
|
+
*
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
18
|
+
load(data) {
|
|
19
|
+
ReplyParser_1.ReplyParser.loadReply(this, data);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Reply = Reply;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplyParser = void 0;
|
|
4
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
5
|
+
const Thumbnails_1 = require("../Thumbnails");
|
|
6
|
+
class ReplyParser {
|
|
7
|
+
static loadReply(target, data) {
|
|
8
|
+
const { authorText, authorThumbnail, authorEndpoint, contentText, publishedTimeText, commentId, likeCount, authorIsChannelOwner, } = data;
|
|
9
|
+
// Basic information
|
|
10
|
+
target.id = commentId;
|
|
11
|
+
target.content = contentText.runs.map((r) => r.text).join("");
|
|
12
|
+
target.publishDate = publishedTimeText.runs.shift().text;
|
|
13
|
+
target.likeCount = likeCount;
|
|
14
|
+
target.isAuthorChannelOwner = authorIsChannelOwner;
|
|
15
|
+
// Author
|
|
16
|
+
const { browseId } = authorEndpoint.browseEndpoint;
|
|
17
|
+
target.author = new BaseChannel_1.BaseChannel({
|
|
18
|
+
id: browseId,
|
|
19
|
+
name: authorText.simpleText,
|
|
20
|
+
thumbnails: new Thumbnails_1.Thumbnails().load(authorThumbnail.thumbnails),
|
|
21
|
+
client: target.client,
|
|
22
|
+
});
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ReplyParser = ReplyParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Reply"), exports);
|
|
14
|
+
__exportStar(require("./ReplyParser"), exports);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SearchManager = void 0;
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
14
|
+
const Continuable_1 = require("../Continuable");
|
|
15
|
+
const SearchManagerParser_1 = require("./SearchManagerParser");
|
|
16
|
+
const proto_1 = require("./proto");
|
|
17
|
+
/**
|
|
18
|
+
* Represents search result, usually returned from `client.search();`.
|
|
19
|
+
*
|
|
20
|
+
* {@link SearchManager} is a helper class to manage search result
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const searchManager = await youtube.search("Keyword");
|
|
25
|
+
*
|
|
26
|
+
* console.log(searchManager.items); // search result from first page
|
|
27
|
+
*
|
|
28
|
+
* let nextSearchResult = await SearchManager.next();
|
|
29
|
+
* console.log(nextSearchResult); // search result from second page
|
|
30
|
+
*
|
|
31
|
+
* nextSearchResult = await SearchManager.next();
|
|
32
|
+
* console.log(nextSearchResult); // search result from third page
|
|
33
|
+
*
|
|
34
|
+
* console.log(searchManager.items); // search result from first, second, and third page.
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @noInheritDoc
|
|
38
|
+
*/
|
|
39
|
+
class SearchManager extends Continuable_1.Continuable {
|
|
40
|
+
/** @hidden */
|
|
41
|
+
constructor({ client }) {
|
|
42
|
+
super({ client });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Initialize data from search
|
|
46
|
+
*
|
|
47
|
+
* @param query Search query
|
|
48
|
+
* @param options Search Options
|
|
49
|
+
*/
|
|
50
|
+
search(query, options) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
this.items = [];
|
|
53
|
+
this.estimatedResults = 0;
|
|
54
|
+
const bufferParams = proto_1.SearchProto.SearchOptions.encode(proto_1.optionsToProto(options));
|
|
55
|
+
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
56
|
+
data: {
|
|
57
|
+
query,
|
|
58
|
+
params: Buffer.from(bufferParams).toString("base64"),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
this.estimatedResults = +response.data.estimatedResults;
|
|
62
|
+
if (this.estimatedResults > 0) {
|
|
63
|
+
const { data, continuation } = SearchManagerParser_1.SearchResultParser.parseInitialSearchResult(response.data, this.client);
|
|
64
|
+
this.items.push(...data);
|
|
65
|
+
this.continuation = continuation;
|
|
66
|
+
}
|
|
67
|
+
return this;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
fetch() {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
73
|
+
data: { continuation: this.continuation },
|
|
74
|
+
});
|
|
75
|
+
const { data, continuation } = SearchManagerParser_1.SearchResultParser.parseContinuationSearchResult(response.data, this.client);
|
|
76
|
+
return {
|
|
77
|
+
items: data,
|
|
78
|
+
continuation,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.SearchManager = SearchManager;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchResultParser = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
6
|
+
const PlaylistCompact_1 = require("../PlaylistCompact");
|
|
7
|
+
const VideoCompact_1 = require("../VideoCompact");
|
|
8
|
+
class SearchResultParser {
|
|
9
|
+
static parseInitialSearchResult(data, client) {
|
|
10
|
+
const sectionListContents = data.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer
|
|
11
|
+
.contents;
|
|
12
|
+
return {
|
|
13
|
+
data: SearchResultParser.parseSearchResult(sectionListContents, client),
|
|
14
|
+
continuation: common_1.getContinuationFromItems(sectionListContents),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
static parseContinuationSearchResult(data, client) {
|
|
18
|
+
const sectionListContents = data.onResponseReceivedCommands[0].appendContinuationItemsAction.continuationItems;
|
|
19
|
+
return {
|
|
20
|
+
data: SearchResultParser.parseSearchResult(sectionListContents, client),
|
|
21
|
+
continuation: common_1.getContinuationFromItems(sectionListContents),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static parseSearchResult(sectionListContents, client) {
|
|
25
|
+
const rawContents = sectionListContents
|
|
26
|
+
.filter((c) => "itemSectionRenderer" in c)
|
|
27
|
+
.at(-1).itemSectionRenderer.contents;
|
|
28
|
+
const contents = [];
|
|
29
|
+
for (const c of rawContents) {
|
|
30
|
+
if ("playlistRenderer" in c)
|
|
31
|
+
contents.push(new PlaylistCompact_1.PlaylistCompact({ client }).load(c.playlistRenderer));
|
|
32
|
+
else if ("videoRenderer" in c)
|
|
33
|
+
contents.push(new VideoCompact_1.VideoCompact({ client }).load(c.videoRenderer));
|
|
34
|
+
else if ("channelRenderer" in c)
|
|
35
|
+
contents.push(new BaseChannel_1.BaseChannel({ client }).load(c.channelRenderer));
|
|
36
|
+
}
|
|
37
|
+
return contents;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.SearchResultParser = SearchResultParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./SearchManager"), exports);
|
|
14
|
+
__exportStar(require("./SearchManagerParser"), exports);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.optionsToProto = exports.SearchProto = void 0;
|
|
7
|
+
const protocol_buffers_1 = __importDefault(require("protocol-buffers"));
|
|
8
|
+
// TODO move this to .proto file
|
|
9
|
+
exports.SearchProto = protocol_buffers_1.default(`
|
|
10
|
+
message SearchOptions {
|
|
11
|
+
message Options {
|
|
12
|
+
optional int32 uploadDate = 1;
|
|
13
|
+
optional int32 type = 2;
|
|
14
|
+
optional int32 duration = 3;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
optional int32 sortBy = 1;
|
|
18
|
+
optional Options options = 2;
|
|
19
|
+
}
|
|
20
|
+
`);
|
|
21
|
+
const searchUploadDateProto = {
|
|
22
|
+
all: 0,
|
|
23
|
+
hour: 1,
|
|
24
|
+
today: 2,
|
|
25
|
+
week: 3,
|
|
26
|
+
month: 4,
|
|
27
|
+
year: 5,
|
|
28
|
+
};
|
|
29
|
+
const searchTypeProto = {
|
|
30
|
+
all: 0,
|
|
31
|
+
video: 1,
|
|
32
|
+
channel: 2,
|
|
33
|
+
playlist: 3,
|
|
34
|
+
};
|
|
35
|
+
const searchDurationProto = {
|
|
36
|
+
all: 0,
|
|
37
|
+
short: 1,
|
|
38
|
+
long: 2,
|
|
39
|
+
medium: 3,
|
|
40
|
+
};
|
|
41
|
+
const searchSortProto = {
|
|
42
|
+
relevance: 0,
|
|
43
|
+
rating: 1,
|
|
44
|
+
date: 2,
|
|
45
|
+
view: 3,
|
|
46
|
+
};
|
|
47
|
+
const optionsToProto = (options) => {
|
|
48
|
+
return {
|
|
49
|
+
sortBy: options.sortBy && searchSortProto[options.sortBy],
|
|
50
|
+
options: {
|
|
51
|
+
duration: options.duration && searchDurationProto[options.duration],
|
|
52
|
+
type: options.type && searchTypeProto[options.type],
|
|
53
|
+
uploadDate: options.uploadDate && searchUploadDateProto[options.uploadDate],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.optionsToProto = optionsToProto;
|