youtubei 1.0.0-rc.4 → 1.0.0-rc.6
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 +4 -0
- package/dist/cjs/classes/BaseChannel/BaseChannelParser.js +2 -2
- package/dist/cjs/classes/BaseChannel/ChannelVideos.js +1 -1
- package/dist/cjs/classes/SearchResult/SearchResult.js +49 -1
- package/dist/cjs/classes/SearchResult/proto/index.js +16 -5
- package/dist/cjs/classes/Video/VideoParser.js +4 -3
- package/dist/cjs/classes/VideoCompact/VideoCompactParser.js +3 -3
- package/dist/esm/classes/BaseChannel/BaseChannelParser.js +2 -2
- package/dist/esm/classes/BaseChannel/ChannelVideos.js +1 -1
- package/dist/esm/classes/SearchResult/SearchResult.js +48 -0
- package/dist/esm/classes/SearchResult/proto/index.js +19 -6
- package/dist/esm/classes/Video/VideoParser.js +4 -3
- package/dist/esm/classes/VideoCompact/VideoCompactParser.js +3 -3
- package/dist/typings/classes/SearchResult/SearchResult.d.ts +48 -4
- package/dist/typings/classes/SearchResult/proto/SearchProto.d.ts +10 -0
- package/dist/typings/classes/SearchResult/proto/index.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,13 +15,13 @@ 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, _b, _c;
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
19
|
const tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find((t) => {
|
|
20
20
|
var _a;
|
|
21
21
|
return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
|
|
22
22
|
BaseChannelParser.TAB_TYPE_PARAMS[name]);
|
|
23
23
|
});
|
|
24
|
-
return (((_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer) === null ||
|
|
24
|
+
return (((_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents) === null || _b === void 0 ? void 0 : _b[0].itemSectionRenderer.contents[0].gridRenderer) === null || _c === void 0 ? void 0 : _c.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map((c) => { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_d = data.onResponseReceivedActions) === null || _d === void 0 ? void 0 : _d[0].appendContinuationItemsAction.continuationItems.map((c) => { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) ||
|
|
25
25
|
[]);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -46,7 +46,7 @@ class ChannelVideos extends Continuable_1.Continuable {
|
|
|
46
46
|
});
|
|
47
47
|
const items = BaseChannelParser_1.BaseChannelParser.parseTabData("videos", response.data);
|
|
48
48
|
const continuation = common_1.getContinuationFromItems(items);
|
|
49
|
-
const data = common_1.mapFilter(items, "
|
|
49
|
+
const data = common_1.mapFilter(items, "videoRenderer");
|
|
50
50
|
return {
|
|
51
51
|
continuation,
|
|
52
52
|
items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
|
|
@@ -9,11 +9,59 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SearchResult = void 0;
|
|
12
|
+
exports.SearchResult = exports.SearchEnum = void 0;
|
|
13
13
|
const constants_1 = require("../../constants");
|
|
14
14
|
const Continuable_1 = require("../Continuable");
|
|
15
15
|
const SearchResultParser_1 = require("./SearchResultParser");
|
|
16
16
|
const proto_1 = require("./proto");
|
|
17
|
+
var SearchEnum;
|
|
18
|
+
(function (SearchEnum) {
|
|
19
|
+
let UploadDate;
|
|
20
|
+
(function (UploadDate) {
|
|
21
|
+
UploadDate["All"] = "all";
|
|
22
|
+
UploadDate["Hour"] = "hour";
|
|
23
|
+
UploadDate["Today"] = "today";
|
|
24
|
+
UploadDate["Week"] = "week";
|
|
25
|
+
UploadDate["Month"] = "month";
|
|
26
|
+
UploadDate["Year"] = "year";
|
|
27
|
+
})(UploadDate = SearchEnum.UploadDate || (SearchEnum.UploadDate = {}));
|
|
28
|
+
let Type;
|
|
29
|
+
(function (Type) {
|
|
30
|
+
Type["Video"] = "video";
|
|
31
|
+
Type["Playlist"] = "playlist";
|
|
32
|
+
Type["Channel"] = "channel";
|
|
33
|
+
Type["All"] = "all";
|
|
34
|
+
})(Type = SearchEnum.Type || (SearchEnum.Type = {}));
|
|
35
|
+
let Duration;
|
|
36
|
+
(function (Duration) {
|
|
37
|
+
Duration["All"] = "all";
|
|
38
|
+
Duration["Short"] = "short";
|
|
39
|
+
Duration["Medium"] = "medium";
|
|
40
|
+
Duration["Long"] = "long";
|
|
41
|
+
})(Duration = SearchEnum.Duration || (SearchEnum.Duration = {}));
|
|
42
|
+
let Sort;
|
|
43
|
+
(function (Sort) {
|
|
44
|
+
Sort["Relevance"] = "relevance";
|
|
45
|
+
Sort["Rating"] = "rating";
|
|
46
|
+
Sort["Date"] = "date";
|
|
47
|
+
Sort["View"] = "view";
|
|
48
|
+
})(Sort = SearchEnum.Sort || (SearchEnum.Sort = {}));
|
|
49
|
+
let Feature;
|
|
50
|
+
(function (Feature) {
|
|
51
|
+
Feature["Live"] = "live";
|
|
52
|
+
Feature["4K"] = "4k";
|
|
53
|
+
Feature["UHD"] = "4k";
|
|
54
|
+
Feature["HD"] = "hd";
|
|
55
|
+
Feature["Subtitles"] = "subtitles";
|
|
56
|
+
Feature["CreativeCommons"] = "creativeCommons";
|
|
57
|
+
Feature["Spherical"] = "360";
|
|
58
|
+
Feature["VR180"] = "vr180";
|
|
59
|
+
Feature["3D"] = "3d";
|
|
60
|
+
Feature["ThreeDimensions"] = "3d";
|
|
61
|
+
Feature["HDR"] = "hdr";
|
|
62
|
+
Feature["Location"] = "location";
|
|
63
|
+
})(Feature = SearchEnum.Feature || (SearchEnum.Feature = {}));
|
|
64
|
+
})(SearchEnum = exports.SearchEnum || (exports.SearchEnum = {}));
|
|
17
65
|
/**
|
|
18
66
|
* Represents search result, usually returned from `client.search();`.
|
|
19
67
|
*
|
|
@@ -12,6 +12,15 @@ exports.SearchProto = protocol_buffers_1.default(`
|
|
|
12
12
|
optional int32 uploadDate = 1;
|
|
13
13
|
optional int32 type = 2;
|
|
14
14
|
optional int32 duration = 3;
|
|
15
|
+
optional int32 hd = 4;
|
|
16
|
+
optional int32 subtitles = 5;
|
|
17
|
+
optional int32 creativeCommons = 6;
|
|
18
|
+
optional int32 live = 8;
|
|
19
|
+
optional int32 4k = 14;
|
|
20
|
+
optional int32 360 = 15;
|
|
21
|
+
optional int32 location = 23;
|
|
22
|
+
optional int32 hdr = 25;
|
|
23
|
+
optional int32 vr180 = 26;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
optional int32 sortBy = 1;
|
|
@@ -45,13 +54,15 @@ const searchSortProto = {
|
|
|
45
54
|
view: 3,
|
|
46
55
|
};
|
|
47
56
|
const optionsToProto = (options) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const featuresRecord = ((_a = options.features) === null || _a === void 0 ? void 0 : _a.reduce((acc, val) => {
|
|
59
|
+
if (val)
|
|
60
|
+
acc[val] = 1;
|
|
61
|
+
return acc;
|
|
62
|
+
}, {})) || {};
|
|
48
63
|
return {
|
|
49
64
|
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
|
-
},
|
|
65
|
+
options: Object.assign({ duration: options.duration && searchDurationProto[options.duration], type: options.type && searchTypeProto[options.type], uploadDate: options.uploadDate && searchUploadDateProto[options.uploadDate] }, featuresRecord),
|
|
55
66
|
};
|
|
56
67
|
};
|
|
57
68
|
exports.optionsToProto = optionsToProto;
|
|
@@ -6,12 +6,13 @@ const BaseVideo_1 = require("../BaseVideo");
|
|
|
6
6
|
const Comment_1 = require("../Comment");
|
|
7
7
|
class VideoParser {
|
|
8
8
|
static loadVideo(target, data) {
|
|
9
|
+
var _a;
|
|
9
10
|
const videoInfo = BaseVideo_1.BaseVideoParser.parseRawData(data);
|
|
10
11
|
target.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
11
|
-
const itemSectionRenderer = data[3].response.contents.twoColumnWatchNextResults.results.results.contents
|
|
12
|
+
const itemSectionRenderer = (_a = data[3].response.contents.twoColumnWatchNextResults.results.results.contents
|
|
12
13
|
.reverse()
|
|
13
|
-
.find((c) => c.itemSectionRenderer).itemSectionRenderer;
|
|
14
|
-
target.comments.continuation = common_1.getContinuationFromItems(itemSectionRenderer.contents);
|
|
14
|
+
.find((c) => c.itemSectionRenderer)) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer;
|
|
15
|
+
target.comments.continuation = common_1.getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
|
|
15
16
|
return target;
|
|
16
17
|
}
|
|
17
18
|
static parseComments(data, video) {
|
|
@@ -6,16 +6,16 @@ const BaseChannel_1 = require("../BaseChannel");
|
|
|
6
6
|
const Thumbnails_1 = require("../Thumbnails");
|
|
7
7
|
class VideoCompactParser {
|
|
8
8
|
static loadVideoCompact(target, data) {
|
|
9
|
-
var _a, _b;
|
|
9
|
+
var _a, _b, _c;
|
|
10
10
|
const { videoId, title, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, channelThumbnailSupportedRenderers, detailedMetadataSnippets, } = data;
|
|
11
11
|
target.id = videoId;
|
|
12
12
|
target.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
|
|
13
13
|
target.thumbnails = new Thumbnails_1.Thumbnails().load(thumbnail.thumbnails);
|
|
14
14
|
target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
15
15
|
target.description =
|
|
16
|
-
(detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs.map((r) => r.text).join("")) || "";
|
|
16
|
+
((_b = detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs) === null || _b === void 0 ? void 0 : _b.map((r) => r.text).join("")) || "";
|
|
17
17
|
target.duration =
|
|
18
|
-
common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((
|
|
18
|
+
common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_c = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _c === void 0 ? void 0 : _c.text.simpleText) ||
|
|
19
19
|
"") || null;
|
|
20
20
|
target.isLive = !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW");
|
|
21
21
|
// Channel
|
|
@@ -14,13 +14,13 @@ 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, _b, _c;
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
18
|
var tab = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs.find(function (t) {
|
|
19
19
|
var _a;
|
|
20
20
|
return (((_a = t.tabRenderer) === null || _a === void 0 ? void 0 : _a.endpoint.browseEndpoint.params) ===
|
|
21
21
|
BaseChannelParser.TAB_TYPE_PARAMS[name]);
|
|
22
22
|
});
|
|
23
|
-
return (((_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer) === null ||
|
|
23
|
+
return (((_c = (_b = tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.sectionListRenderer.contents) === null || _b === void 0 ? void 0 : _b[0].itemSectionRenderer.contents[0].gridRenderer) === null || _c === void 0 ? void 0 : _c.items) || (tab === null || tab === void 0 ? void 0 : tab.tabRenderer.content.richGridRenderer.contents.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) || ((_d = data.onResponseReceivedActions) === null || _d === void 0 ? void 0 : _d[0].appendContinuationItemsAction.continuationItems.map(function (c) { var _a; return ((_a = c.richItemRenderer) === null || _a === void 0 ? void 0 : _a.content) || c; })) ||
|
|
24
24
|
[]);
|
|
25
25
|
};
|
|
26
26
|
BaseChannelParser.TAB_TYPE_PARAMS = {
|
|
@@ -93,7 +93,7 @@ var ChannelVideos = /** @class */ (function (_super) {
|
|
|
93
93
|
response = _b.sent();
|
|
94
94
|
items = BaseChannelParser.parseTabData("videos", response.data);
|
|
95
95
|
continuation = getContinuationFromItems(items);
|
|
96
|
-
data = mapFilter(items, "
|
|
96
|
+
data = mapFilter(items, "videoRenderer");
|
|
97
97
|
return [2 /*return*/, {
|
|
98
98
|
continuation: continuation,
|
|
99
99
|
items: data.map(function (i) {
|
|
@@ -71,6 +71,54 @@ import { I_END_POINT } from "../../constants";
|
|
|
71
71
|
import { Continuable } from "../Continuable";
|
|
72
72
|
import { SearchResultParser } from "./SearchResultParser";
|
|
73
73
|
import { optionsToProto, SearchProto } from "./proto";
|
|
74
|
+
export var SearchEnum;
|
|
75
|
+
(function (SearchEnum) {
|
|
76
|
+
var UploadDate;
|
|
77
|
+
(function (UploadDate) {
|
|
78
|
+
UploadDate["All"] = "all";
|
|
79
|
+
UploadDate["Hour"] = "hour";
|
|
80
|
+
UploadDate["Today"] = "today";
|
|
81
|
+
UploadDate["Week"] = "week";
|
|
82
|
+
UploadDate["Month"] = "month";
|
|
83
|
+
UploadDate["Year"] = "year";
|
|
84
|
+
})(UploadDate = SearchEnum.UploadDate || (SearchEnum.UploadDate = {}));
|
|
85
|
+
var Type;
|
|
86
|
+
(function (Type) {
|
|
87
|
+
Type["Video"] = "video";
|
|
88
|
+
Type["Playlist"] = "playlist";
|
|
89
|
+
Type["Channel"] = "channel";
|
|
90
|
+
Type["All"] = "all";
|
|
91
|
+
})(Type = SearchEnum.Type || (SearchEnum.Type = {}));
|
|
92
|
+
var Duration;
|
|
93
|
+
(function (Duration) {
|
|
94
|
+
Duration["All"] = "all";
|
|
95
|
+
Duration["Short"] = "short";
|
|
96
|
+
Duration["Medium"] = "medium";
|
|
97
|
+
Duration["Long"] = "long";
|
|
98
|
+
})(Duration = SearchEnum.Duration || (SearchEnum.Duration = {}));
|
|
99
|
+
var Sort;
|
|
100
|
+
(function (Sort) {
|
|
101
|
+
Sort["Relevance"] = "relevance";
|
|
102
|
+
Sort["Rating"] = "rating";
|
|
103
|
+
Sort["Date"] = "date";
|
|
104
|
+
Sort["View"] = "view";
|
|
105
|
+
})(Sort = SearchEnum.Sort || (SearchEnum.Sort = {}));
|
|
106
|
+
var Feature;
|
|
107
|
+
(function (Feature) {
|
|
108
|
+
Feature["Live"] = "live";
|
|
109
|
+
Feature["4K"] = "4k";
|
|
110
|
+
Feature["UHD"] = "4k";
|
|
111
|
+
Feature["HD"] = "hd";
|
|
112
|
+
Feature["Subtitles"] = "subtitles";
|
|
113
|
+
Feature["CreativeCommons"] = "creativeCommons";
|
|
114
|
+
Feature["Spherical"] = "360";
|
|
115
|
+
Feature["VR180"] = "vr180";
|
|
116
|
+
Feature["3D"] = "3d";
|
|
117
|
+
Feature["ThreeDimensions"] = "3d";
|
|
118
|
+
Feature["HDR"] = "hdr";
|
|
119
|
+
Feature["Location"] = "location";
|
|
120
|
+
})(Feature = SearchEnum.Feature || (SearchEnum.Feature = {}));
|
|
121
|
+
})(SearchEnum || (SearchEnum = {}));
|
|
74
122
|
/**
|
|
75
123
|
* Represents search result, usually returned from `client.search();`.
|
|
76
124
|
*
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import proto from "protocol-buffers";
|
|
2
13
|
// TODO move this to .proto file
|
|
3
|
-
export var SearchProto = proto("\n\tmessage SearchOptions {\n\t\tmessage Options {\n\t\t\toptional int32 uploadDate = 1;\n\t\t\toptional int32 type = 2;\n\t\t\toptional int32 duration = 3;\n\t\t}\n\n\t\toptional int32 sortBy = 1;\n\t\toptional Options options = 2;\n\t}\n");
|
|
14
|
+
export var SearchProto = proto("\n\tmessage SearchOptions {\n\t\tmessage Options {\n\t\t\toptional int32 uploadDate = 1;\n\t\t\toptional int32 type = 2;\n\t\t\toptional int32 duration = 3;\n\t\t\toptional int32 hd = 4;\n\t\t\toptional int32 subtitles = 5;\n\t\t\toptional int32 creativeCommons = 6;\n\t\t\toptional int32 live = 8;\n\t\t\toptional int32 4k = 14;\n\t\t\toptional int32 360 = 15;\n\t\t\toptional int32 location = 23;\n\t\t\toptional int32 hdr = 25;\n\t\t\toptional int32 vr180 = 26;\n\t\t}\n\n\t\toptional int32 sortBy = 1;\n\t\toptional Options options = 2;\n\t}\n");
|
|
4
15
|
var searchUploadDateProto = {
|
|
5
16
|
all: 0,
|
|
6
17
|
hour: 1,
|
|
@@ -28,12 +39,14 @@ var searchSortProto = {
|
|
|
28
39
|
view: 3,
|
|
29
40
|
};
|
|
30
41
|
export var optionsToProto = function (options) {
|
|
42
|
+
var _a;
|
|
43
|
+
var featuresRecord = ((_a = options.features) === null || _a === void 0 ? void 0 : _a.reduce(function (acc, val) {
|
|
44
|
+
if (val)
|
|
45
|
+
acc[val] = 1;
|
|
46
|
+
return acc;
|
|
47
|
+
}, {})) || {};
|
|
31
48
|
return {
|
|
32
49
|
sortBy: options.sortBy && searchSortProto[options.sortBy],
|
|
33
|
-
options: {
|
|
34
|
-
duration: options.duration && searchDurationProto[options.duration],
|
|
35
|
-
type: options.type && searchTypeProto[options.type],
|
|
36
|
-
uploadDate: options.uploadDate && searchUploadDateProto[options.uploadDate],
|
|
37
|
-
},
|
|
50
|
+
options: __assign({ duration: options.duration && searchDurationProto[options.duration], type: options.type && searchTypeProto[options.type], uploadDate: options.uploadDate && searchUploadDateProto[options.uploadDate] }, featuresRecord),
|
|
38
51
|
};
|
|
39
52
|
};
|
|
@@ -5,12 +5,13 @@ var VideoParser = /** @class */ (function () {
|
|
|
5
5
|
function VideoParser() {
|
|
6
6
|
}
|
|
7
7
|
VideoParser.loadVideo = function (target, data) {
|
|
8
|
+
var _a;
|
|
8
9
|
var videoInfo = BaseVideoParser.parseRawData(data);
|
|
9
10
|
target.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
10
|
-
var itemSectionRenderer = data[3].response.contents.twoColumnWatchNextResults.results.results.contents
|
|
11
|
+
var itemSectionRenderer = (_a = data[3].response.contents.twoColumnWatchNextResults.results.results.contents
|
|
11
12
|
.reverse()
|
|
12
|
-
.find(function (c) { return c.itemSectionRenderer; }).itemSectionRenderer;
|
|
13
|
-
target.comments.continuation = getContinuationFromItems(itemSectionRenderer.contents);
|
|
13
|
+
.find(function (c) { return c.itemSectionRenderer; })) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer;
|
|
14
|
+
target.comments.continuation = getContinuationFromItems((itemSectionRenderer === null || itemSectionRenderer === void 0 ? void 0 : itemSectionRenderer.contents) || []);
|
|
14
15
|
return target;
|
|
15
16
|
};
|
|
16
17
|
VideoParser.parseComments = function (data, video) {
|
|
@@ -5,16 +5,16 @@ var VideoCompactParser = /** @class */ (function () {
|
|
|
5
5
|
function VideoCompactParser() {
|
|
6
6
|
}
|
|
7
7
|
VideoCompactParser.loadVideoCompact = function (target, data) {
|
|
8
|
-
var _a, _b;
|
|
8
|
+
var _a, _b, _c;
|
|
9
9
|
var videoId = data.videoId, title = data.title, lengthText = data.lengthText, thumbnail = data.thumbnail, ownerText = data.ownerText, shortBylineText = data.shortBylineText, publishedTimeText = data.publishedTimeText, viewCountText = data.viewCountText, badges = data.badges, thumbnailOverlays = data.thumbnailOverlays, channelThumbnailSupportedRenderers = data.channelThumbnailSupportedRenderers, detailedMetadataSnippets = data.detailedMetadataSnippets;
|
|
10
10
|
target.id = videoId;
|
|
11
11
|
target.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
|
|
12
12
|
target.thumbnails = new Thumbnails().load(thumbnail.thumbnails);
|
|
13
13
|
target.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
14
14
|
target.description =
|
|
15
|
-
(detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs.map(function (r) { return r.text; }).join("")) || "";
|
|
15
|
+
((_b = detailedMetadataSnippets === null || detailedMetadataSnippets === void 0 ? void 0 : detailedMetadataSnippets[0].snippetText.runs) === null || _b === void 0 ? void 0 : _b.map(function (r) { return r.text; }).join("")) || "";
|
|
16
16
|
target.duration =
|
|
17
|
-
getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((
|
|
17
|
+
getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_c = thumbnailOverlays === null || thumbnailOverlays === void 0 ? void 0 : thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _c === void 0 ? void 0 : _c.text.simpleText) ||
|
|
18
18
|
"") || null;
|
|
19
19
|
target.isLive = !!((badges === null || badges === void 0 ? void 0 : badges[0].metadataBadgeRenderer.style) === "BADGE_STYLE_TYPE_LIVE_NOW");
|
|
20
20
|
// Channel
|
|
@@ -7,11 +7,55 @@ export declare type SearchOptions = {
|
|
|
7
7
|
duration?: SearchDuration;
|
|
8
8
|
uploadDate?: SearchUploadDate;
|
|
9
9
|
sortBy?: SearchSort;
|
|
10
|
+
features?: SearchFeature[];
|
|
10
11
|
};
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export declare namespace SearchEnum {
|
|
13
|
+
enum UploadDate {
|
|
14
|
+
All = "all",
|
|
15
|
+
Hour = "hour",
|
|
16
|
+
Today = "today",
|
|
17
|
+
Week = "week",
|
|
18
|
+
Month = "month",
|
|
19
|
+
Year = "year"
|
|
20
|
+
}
|
|
21
|
+
enum Type {
|
|
22
|
+
Video = "video",
|
|
23
|
+
Playlist = "playlist",
|
|
24
|
+
Channel = "channel",
|
|
25
|
+
All = "all"
|
|
26
|
+
}
|
|
27
|
+
enum Duration {
|
|
28
|
+
All = "all",
|
|
29
|
+
Short = "short",
|
|
30
|
+
Medium = "medium",
|
|
31
|
+
Long = "long"
|
|
32
|
+
}
|
|
33
|
+
enum Sort {
|
|
34
|
+
Relevance = "relevance",
|
|
35
|
+
Rating = "rating",
|
|
36
|
+
Date = "date",
|
|
37
|
+
View = "view"
|
|
38
|
+
}
|
|
39
|
+
enum Feature {
|
|
40
|
+
Live = "live",
|
|
41
|
+
"4K" = "4k",
|
|
42
|
+
UHD = "4k",
|
|
43
|
+
HD = "hd",
|
|
44
|
+
Subtitles = "subtitles",
|
|
45
|
+
CreativeCommons = "creativeCommons",
|
|
46
|
+
Spherical = "360",
|
|
47
|
+
VR180 = "vr180",
|
|
48
|
+
"3D" = "3d",
|
|
49
|
+
ThreeDimensions = "3d",
|
|
50
|
+
HDR = "hdr",
|
|
51
|
+
Location = "location"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export declare type SearchUploadDate = "all" | "hour" | "today" | "week" | "month" | "year" | SearchEnum.UploadDate;
|
|
55
|
+
export declare type SearchType = "all" | "video" | "channel" | "playlist" | SearchEnum.Type;
|
|
56
|
+
export declare type SearchDuration = "all" | "short" | "medium" | "long" | SearchEnum.Duration;
|
|
57
|
+
export declare type SearchSort = "relevance" | "rating" | "date" | "view" | SearchEnum.Sort;
|
|
58
|
+
export declare type SearchFeature = "live" | "4k" | "hd" | "subtitles" | "creativeCommons" | "360" | "vr180" | "3d" | "hdr" | "location" | SearchEnum.Feature;
|
|
15
59
|
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
60
|
/**
|
|
17
61
|
* Represents search result, usually returned from `client.search();`.
|
|
@@ -2,6 +2,16 @@ declare type Options = {
|
|
|
2
2
|
uploadDate?: number;
|
|
3
3
|
type?: number;
|
|
4
4
|
duration?: number;
|
|
5
|
+
live?: number;
|
|
6
|
+
"4k"?: number;
|
|
7
|
+
hd?: number;
|
|
8
|
+
subtitles?: number;
|
|
9
|
+
creativeCommons?: number;
|
|
10
|
+
"360"?: number;
|
|
11
|
+
vr180?: number;
|
|
12
|
+
"3d"?: number;
|
|
13
|
+
hdr?: number;
|
|
14
|
+
location?: number;
|
|
5
15
|
};
|
|
6
16
|
declare type SearchOptions = {
|
|
7
17
|
sortBy?: number;
|
|
@@ -9,6 +9,16 @@ export declare const SearchProto: {
|
|
|
9
9
|
uploadDate?: number | undefined;
|
|
10
10
|
type?: number | undefined;
|
|
11
11
|
duration?: number | undefined;
|
|
12
|
+
live?: number | undefined;
|
|
13
|
+
"4k"?: number | undefined;
|
|
14
|
+
hd?: number | undefined;
|
|
15
|
+
subtitles?: number | undefined;
|
|
16
|
+
creativeCommons?: number | undefined;
|
|
17
|
+
"360"?: number | undefined;
|
|
18
|
+
vr180?: number | undefined;
|
|
19
|
+
"3d"?: number | undefined;
|
|
20
|
+
hdr?: number | undefined;
|
|
21
|
+
location?: number | undefined;
|
|
12
22
|
} | undefined;
|
|
13
23
|
}) => Buffer;
|
|
14
24
|
decode: (buf: Buffer) => {
|
|
@@ -17,6 +27,16 @@ export declare const SearchProto: {
|
|
|
17
27
|
uploadDate?: number | undefined;
|
|
18
28
|
type?: number | undefined;
|
|
19
29
|
duration?: number | undefined;
|
|
30
|
+
live?: number | undefined;
|
|
31
|
+
"4k"?: number | undefined;
|
|
32
|
+
hd?: number | undefined;
|
|
33
|
+
subtitles?: number | undefined;
|
|
34
|
+
creativeCommons?: number | undefined;
|
|
35
|
+
"360"?: number | undefined;
|
|
36
|
+
vr180?: number | undefined;
|
|
37
|
+
"3d"?: number | undefined;
|
|
38
|
+
hdr?: number | undefined;
|
|
39
|
+
location?: number | undefined;
|
|
20
40
|
} | undefined;
|
|
21
41
|
};
|
|
22
42
|
};
|
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.6",
|
|
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",
|