youtubei 1.0.0-rc.5 → 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/Video/VideoParser.js +4 -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/Video/VideoParser.js +4 -3
- package/dist/typings/classes/SearchResult/SearchResult.d.ts +47 -5
- 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
|
*
|
|
@@ -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) {
|
|
@@ -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
|
*
|
|
@@ -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) {
|
|
@@ -9,11 +9,53 @@ export declare type SearchOptions = {
|
|
|
9
9
|
sortBy?: SearchSort;
|
|
10
10
|
features?: SearchFeature[];
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
17
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;
|
|
18
60
|
/**
|
|
19
61
|
* Represents search result, usually returned from `client.search();`.
|
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",
|