youtubei 0.0.1-rc.8 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +14 -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 +14 -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 +15 -0
- package/dist/cjs/classes/Continuable/Continuable.js +43 -0
- package/dist/cjs/classes/Continuable/index.js +13 -0
- package/dist/cjs/classes/LiveVideo/LiveVideo.js +84 -0
- 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/SearchResult/SearchResult.js +85 -0
- package/dist/cjs/classes/SearchResult/SearchResultParser.js +40 -0
- package/dist/cjs/classes/SearchResult/index.js +14 -0
- package/dist/cjs/classes/SearchResult/proto/SearchProto.js +2 -0
- package/dist/cjs/classes/SearchResult/proto/index.js +57 -0
- package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -50
- 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 +15 -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 -15
- 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 +2 -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 +2 -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 +3 -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/SearchResult/SearchResult.js +161 -0
- package/dist/esm/classes/SearchResult/SearchResultParser.js +62 -0
- package/dist/esm/classes/SearchResult/index.js +2 -0
- package/dist/esm/classes/SearchResult/proto/SearchProto.js +1 -0
- package/dist/esm/classes/SearchResult/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 +3 -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 +2 -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 +2 -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 +3 -0
- package/dist/typings/classes/Continuable/Continuable.d.ts +24 -0
- package/dist/typings/classes/Continuable/index.d.ts +1 -0
- package/dist/typings/classes/LiveVideo/LiveVideo.d.ts +46 -0
- 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/SearchResult/SearchResult.d.ts +53 -0
- package/dist/typings/classes/SearchResult/SearchResultParser.d.ts +13 -0
- package/dist/typings/classes/SearchResult/index.d.ts +2 -0
- package/dist/typings/classes/SearchResult/proto/SearchProto.d.ts +13 -0
- package/dist/typings/classes/SearchResult/proto/index.d.ts +24 -0
- package/dist/typings/classes/Thumbnails/Thumbnails.d.ts +41 -0
- 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 +3 -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 -7
- 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 -2
- 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 -8
- package/dist/classes/Base.js +0 -10
- package/dist/classes/Channel.d.ts +0 -63
- package/dist/classes/Channel.js +0 -115
- package/dist/classes/Chat.d.ts +0 -35
- package/dist/classes/Chat.js +0 -34
- package/dist/classes/Client.d.ts +0 -17
- package/dist/classes/Client.js +0 -59
- package/dist/classes/Comment.d.ts +0 -51
- package/dist/classes/Comment.js +0 -47
- package/dist/classes/LiveVideo.d.ts +0 -20
- package/dist/classes/LiveVideo.js +0 -59
- package/dist/classes/Playlist.d.ts +0 -66
- package/dist/classes/Playlist.js +0 -133
- package/dist/classes/PlaylistCompact.d.ts +0 -35
- package/dist/classes/PlaylistCompact.js +0 -47
- package/dist/classes/SearchResult.d.ts +0 -51
- package/dist/classes/SearchResult.js +0 -121
- package/dist/classes/Thumbnails.d.ts +0 -26
- package/dist/classes/Video.d.ts +0 -90
- package/dist/classes/Video.js +0 -153
- package/dist/classes/VideoCompact.d.ts +0 -46
- package/dist/classes/VideoCompact.js +0 -53
- package/dist/classes/index.d.ts +0 -12
- package/dist/classes/index.js +0 -30
- package/dist/common/helper.d.ts +0 -4
- package/dist/common/helper.js +0 -39
- package/dist/common/http.d.ts +0 -33
- package/dist/common/http.js +0 -105
- package/dist/common/index.d.ts +0 -5
- package/dist/common/mixins.d.ts +0 -2
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var SearchResult_1;
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
const constants_1 = require("../constants");
|
|
20
|
-
const common_1 = require("../common");
|
|
21
|
-
const _1 = require(".");
|
|
22
|
-
/**
|
|
23
|
-
* Represents search result, usually returned from `client.search();`
|
|
24
|
-
*
|
|
25
|
-
* @noInheritDoc
|
|
26
|
-
*/
|
|
27
|
-
let SearchResult = SearchResult_1 = class SearchResult extends Array {
|
|
28
|
-
/** @hidden */
|
|
29
|
-
constructor() {
|
|
30
|
-
super();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Initialize data from search
|
|
34
|
-
*
|
|
35
|
-
* @param query Search query
|
|
36
|
-
* @param options Search Options
|
|
37
|
-
* @hidden
|
|
38
|
-
*/
|
|
39
|
-
init(query, options) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
42
|
-
data: { query, params: SearchResult_1.getSearchTypeParam(options.type) },
|
|
43
|
-
});
|
|
44
|
-
this.loadSearchResult(response.data.contents.twoColumnSearchResultsRenderer.primaryContents
|
|
45
|
-
.sectionListRenderer.contents);
|
|
46
|
-
return this;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Load next search data. Youtube returns inconsistent amount of search result, it usually varies from 18 to 20
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```js
|
|
54
|
-
* const videos = await youtube.search("keyword", { type: "video" });
|
|
55
|
-
* console.log(videos) // first 18-20 videos from the search result
|
|
56
|
-
*
|
|
57
|
-
* let newVideos = await videos.next();
|
|
58
|
-
* console.log(newVideos) // 18-20 loaded videos
|
|
59
|
-
* console.log(videos) // 36-40 first videos from the search result
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @param count How many times to load the next data
|
|
63
|
-
*/
|
|
64
|
-
next(count = 1) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const newSearchResults = [];
|
|
67
|
-
for (let i = 0; i < count; i++) {
|
|
68
|
-
if (!this._continuation)
|
|
69
|
-
break;
|
|
70
|
-
const response = yield common_1.http.post(`${constants_1.I_END_POINT}/search`, {
|
|
71
|
-
data: { continuation: this._continuation },
|
|
72
|
-
});
|
|
73
|
-
newSearchResults.push(...this.loadSearchResult(response.data.onResponseReceivedCommands[0].appendContinuationItemsAction
|
|
74
|
-
.continuationItems));
|
|
75
|
-
}
|
|
76
|
-
this.push(...newSearchResults);
|
|
77
|
-
return newSearchResults;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/** Load videos data from youtube */
|
|
81
|
-
loadSearchResult(sectionListContents) {
|
|
82
|
-
var _a, _b;
|
|
83
|
-
const contents = sectionListContents
|
|
84
|
-
.filter((c) => "itemSectionRenderer" in c)
|
|
85
|
-
.pop().itemSectionRenderer.contents;
|
|
86
|
-
const continuationToken = (_b = (_a = sectionListContents
|
|
87
|
-
.filter((c) => "continuationItemRenderer" in c)
|
|
88
|
-
.pop().continuationItemRenderer) === null || _a === void 0 ? void 0 : _a.continuationEndpoint) === null || _b === void 0 ? void 0 : _b.continuationCommand.token;
|
|
89
|
-
this._continuation = continuationToken;
|
|
90
|
-
const newContent = [];
|
|
91
|
-
for (const content of contents) {
|
|
92
|
-
if ("playlistRenderer" in content)
|
|
93
|
-
newContent.push(new _1.PlaylistCompact().load(content.playlistRenderer));
|
|
94
|
-
else if ("videoRenderer" in content)
|
|
95
|
-
newContent.push(new _1.VideoCompact().load(content.videoRenderer));
|
|
96
|
-
else if ("channelRenderer" in content)
|
|
97
|
-
newContent.push(new _1.Channel().load(content.channelRenderer));
|
|
98
|
-
}
|
|
99
|
-
this.push(...newContent);
|
|
100
|
-
return newContent;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get type query value
|
|
104
|
-
*
|
|
105
|
-
* @param type Search type
|
|
106
|
-
* @hidden
|
|
107
|
-
*/
|
|
108
|
-
static getSearchTypeParam(type) {
|
|
109
|
-
const searchType = {
|
|
110
|
-
video: "EgIQAQ%3D%3D",
|
|
111
|
-
playlist: "EgIQAw%3D%3D",
|
|
112
|
-
channel: "EgIQAg%3D%3D",
|
|
113
|
-
all: "",
|
|
114
|
-
};
|
|
115
|
-
return type in searchType ? searchType[type] : "";
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
SearchResult = SearchResult_1 = __decorate([
|
|
119
|
-
common_1.extendsBuiltIn()
|
|
120
|
-
], SearchResult);
|
|
121
|
-
exports.default = SearchResult;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
interface Thumbnail {
|
|
2
|
-
url: string;
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Represents Thumbnails, usually found inside Playlist / Channel / Video, etc.
|
|
8
|
-
*
|
|
9
|
-
* @noInheritDoc
|
|
10
|
-
*/
|
|
11
|
-
export default class Thumbnails extends Array<Thumbnail> {
|
|
12
|
-
/** @hidden */
|
|
13
|
-
constructor();
|
|
14
|
-
/**
|
|
15
|
-
* Load instance attributes from youtube raw data
|
|
16
|
-
*
|
|
17
|
-
* @hidden
|
|
18
|
-
*/
|
|
19
|
-
load(thumbnails: Thumbnail[]): Thumbnails;
|
|
20
|
-
/** Returns thumbnail with the lowest resolution, usually the first element of the Thumbnails array */
|
|
21
|
-
get min(): string | undefined;
|
|
22
|
-
/** Returns thumbnail with the highest resolution, usually the last element of the Thumbnails array */
|
|
23
|
-
get best(): string | undefined;
|
|
24
|
-
private static parseThumbnailUrl;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
package/dist/classes/Video.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { PlaylistCompact, VideoCompact, Channel, Base, Comment, Thumbnails } from ".";
|
|
2
|
-
import { YoutubeRawData } from "../common";
|
|
3
|
-
/**
|
|
4
|
-
* @hidden
|
|
5
|
-
* @ignore
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
interface VideoAttributes {
|
|
9
|
-
id: string;
|
|
10
|
-
title: string;
|
|
11
|
-
duration: number | null;
|
|
12
|
-
thumbnails: Thumbnails;
|
|
13
|
-
description: string;
|
|
14
|
-
channel: Channel;
|
|
15
|
-
uploadDate: string;
|
|
16
|
-
viewCount: number | null;
|
|
17
|
-
likeCount: number | null;
|
|
18
|
-
dislikeCount: number | null;
|
|
19
|
-
isLiveContent: boolean;
|
|
20
|
-
tags: string[];
|
|
21
|
-
upNext: VideoCompact | PlaylistCompact;
|
|
22
|
-
related: (VideoCompact | PlaylistCompact)[];
|
|
23
|
-
comments: Comment[];
|
|
24
|
-
}
|
|
25
|
-
/** Represents a Video, usually returned from `client.getVideo()` */
|
|
26
|
-
export default class Video extends Base implements VideoAttributes {
|
|
27
|
-
/** The video's ID */
|
|
28
|
-
id: string;
|
|
29
|
-
/** The title of this video */
|
|
30
|
-
title: string;
|
|
31
|
-
/** The duration of this video in second, null if the video is live */
|
|
32
|
-
duration: number | null;
|
|
33
|
-
/** Thumbnails of the video with different sizes */
|
|
34
|
-
thumbnails: Thumbnails;
|
|
35
|
-
/** The description of this video */
|
|
36
|
-
description: string;
|
|
37
|
-
/** The channel who uploads this video */
|
|
38
|
-
channel: Channel;
|
|
39
|
-
/** The date this video is uploaded at */
|
|
40
|
-
uploadDate: string;
|
|
41
|
-
/** How many view does this video have, null if the view count is hidden */
|
|
42
|
-
viewCount: number | null;
|
|
43
|
-
/** How many like does this video have, null if the like count hidden */
|
|
44
|
-
likeCount: number | null;
|
|
45
|
-
/** How many dislike does this video have, null if the dislike count is hidden */
|
|
46
|
-
dislikeCount: number | null;
|
|
47
|
-
/** Whether this video is a live content or not */
|
|
48
|
-
isLiveContent: boolean;
|
|
49
|
-
/** The tags of this video */
|
|
50
|
-
tags: string[];
|
|
51
|
-
/** Next video / playlist recommended by Youtube */
|
|
52
|
-
upNext: VideoCompact | PlaylistCompact;
|
|
53
|
-
/** Videos / playlists related to this video */
|
|
54
|
-
related: (VideoCompact | PlaylistCompact)[];
|
|
55
|
-
/**
|
|
56
|
-
* Comments of this video
|
|
57
|
-
*
|
|
58
|
-
* You need to load the comment first by calling `video.nextComments()` as youtube doesn't send any comments data when loading the video (from `client.getVideo()`)
|
|
59
|
-
*/
|
|
60
|
-
comments: Comment[];
|
|
61
|
-
private _commentContinuation?;
|
|
62
|
-
/** @hidden */
|
|
63
|
-
constructor(video?: Partial<VideoAttributes>);
|
|
64
|
-
/**
|
|
65
|
-
* Load instance attributes from youtube raw data
|
|
66
|
-
*
|
|
67
|
-
* @param youtubeRawData raw object from youtubei
|
|
68
|
-
* @hidden
|
|
69
|
-
*/
|
|
70
|
-
load(youtubeRawData: YoutubeRawData): Video;
|
|
71
|
-
/**
|
|
72
|
-
* Load next 20 comments of the video
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```js
|
|
76
|
-
* const video = await youtube.getVideo(VIDEO_ID);
|
|
77
|
-
* console.log(video.comments) // first 20 comments
|
|
78
|
-
*
|
|
79
|
-
* let newComments = await video.nextComments();
|
|
80
|
-
* console.log(newComments) // 20 loaded comments
|
|
81
|
-
* console.log(video.comments) // first 40 comments
|
|
82
|
-
*
|
|
83
|
-
* await video.nextComments(0); // load the rest of the comments in the playlist
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @param count How many times to load the next comments. Set 0 to load all comments (might take a while on a video with many comments!)
|
|
87
|
-
*/
|
|
88
|
-
nextComments(count?: number): Promise<Comment[]>;
|
|
89
|
-
}
|
|
90
|
-
export {};
|
package/dist/classes/Video.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
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
|
-
const _1 = require(".");
|
|
13
|
-
const common_1 = require("../common");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
|
-
/** Represents a Video, usually returned from `client.getVideo()` */
|
|
16
|
-
class Video extends _1.Base {
|
|
17
|
-
/** @hidden */
|
|
18
|
-
constructor(video = {}) {
|
|
19
|
-
super();
|
|
20
|
-
Object.assign(this, video);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Load instance attributes from youtube raw data
|
|
24
|
-
*
|
|
25
|
-
* @param youtubeRawData raw object from youtubei
|
|
26
|
-
* @hidden
|
|
27
|
-
*/
|
|
28
|
-
load(youtubeRawData) {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
|
-
const contents = youtubeRawData[3].response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
31
|
-
const primaryInfo = contents.find((c) => "videoPrimaryInfoRenderer" in c)
|
|
32
|
-
.videoPrimaryInfoRenderer;
|
|
33
|
-
const secondaryInfo = contents.find((c) => "videoSecondaryInfoRenderer" in c).videoSecondaryInfoRenderer;
|
|
34
|
-
const videoDetails = youtubeRawData[2].playerResponse.videoDetails;
|
|
35
|
-
const videoInfo = Object.assign(Object.assign(Object.assign({}, secondaryInfo), primaryInfo), { videoDetails });
|
|
36
|
-
// Comment Continuation Token
|
|
37
|
-
this.comments = [];
|
|
38
|
-
const continuation = (_a = contents.find((c) => "itemSectionRenderer" in c)) === null || _a === void 0 ? void 0 : _a.itemSectionRenderer.continuations[0].nextContinuationData;
|
|
39
|
-
if (continuation) {
|
|
40
|
-
this._commentContinuation = {
|
|
41
|
-
token: continuation.continuation,
|
|
42
|
-
itct: continuation.clickTrackingParams,
|
|
43
|
-
xsrfToken: youtubeRawData[3].xsrf_token,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
// Basic information
|
|
47
|
-
this.id = videoInfo.videoDetails.videoId;
|
|
48
|
-
this.title = videoInfo.videoDetails.title;
|
|
49
|
-
this.duration = +videoInfo.videoDetails.lengthSeconds || null;
|
|
50
|
-
this.uploadDate = videoInfo.dateText.simpleText;
|
|
51
|
-
this.viewCount = +videoInfo.videoDetails.viewCount;
|
|
52
|
-
this.isLiveContent = videoInfo.videoDetails.isLiveContent;
|
|
53
|
-
this.thumbnails = new _1.Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
54
|
-
// Channel
|
|
55
|
-
const { title, thumbnail } = videoInfo.owner.videoOwnerRenderer;
|
|
56
|
-
this.channel = new _1.Channel({
|
|
57
|
-
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
58
|
-
name: title.runs[0].text,
|
|
59
|
-
thumbnails: new _1.Thumbnails().load(thumbnail.thumbnails),
|
|
60
|
-
url: `https://www.youtube.com/channel/${title.runs[0].navigationEndpoint.browseEndpoint.browseId}`,
|
|
61
|
-
});
|
|
62
|
-
// Like Count and Dislike Count
|
|
63
|
-
const topLevelButtons = videoInfo.videoActions.menuRenderer.topLevelButtons;
|
|
64
|
-
this.likeCount =
|
|
65
|
-
+((_b = topLevelButtons[0].toggleButtonRenderer.defaultText.accessibility) === null || _b === void 0 ? void 0 : _b.accessibilityData.label.replace(/[^0-9]/g, "")) || null;
|
|
66
|
-
this.dislikeCount =
|
|
67
|
-
+((_c = topLevelButtons[1].toggleButtonRenderer.defaultText.accessibility) === null || _c === void 0 ? void 0 : _c.accessibilityData.label.replace(/[^0-9]/g, "")) || null;
|
|
68
|
-
// Tags and description
|
|
69
|
-
this.tags =
|
|
70
|
-
((_e = (_d = videoInfo.superTitleLink) === null || _d === void 0 ? void 0 : _d.runs) === null || _e === void 0 ? void 0 : _e.reduce((tags, t) => {
|
|
71
|
-
if (t.text.trim())
|
|
72
|
-
tags.push(t.text.trim());
|
|
73
|
-
return tags;
|
|
74
|
-
}, [])) || [];
|
|
75
|
-
this.description =
|
|
76
|
-
((_f = videoInfo.description) === null || _f === void 0 ? void 0 : _f.runs.map((d) => d.text).join("")) || "";
|
|
77
|
-
// Up Next and related videos
|
|
78
|
-
this.related = [];
|
|
79
|
-
const secondaryContents = youtubeRawData[3].response.contents.twoColumnWatchNextResults.secondaryResults
|
|
80
|
-
.secondaryResults.results;
|
|
81
|
-
for (const secondaryContent of secondaryContents) {
|
|
82
|
-
if ("compactAutoplayRenderer" in secondaryContent) {
|
|
83
|
-
const content = secondaryContent.compactAutoplayRenderer.contents[0];
|
|
84
|
-
if ("compactVideoRenderer" in content) {
|
|
85
|
-
this.upNext = new _1.VideoCompact().load(content.compactVideoRenderer);
|
|
86
|
-
}
|
|
87
|
-
else if ("compactRadioRenderer" in content) {
|
|
88
|
-
this.upNext = new _1.PlaylistCompact().load(content.compactRadioRenderer);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else if ("compactVideoRenderer" in secondaryContent) {
|
|
92
|
-
this.related.push(new _1.VideoCompact().load(secondaryContent.compactVideoRenderer));
|
|
93
|
-
}
|
|
94
|
-
else if ("compactRadioRenderer" in secondaryContent) {
|
|
95
|
-
this.related.push(new _1.PlaylistCompact().load(secondaryContent.compactRadioRenderer));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Load next 20 comments of the video
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```js
|
|
105
|
-
* const video = await youtube.getVideo(VIDEO_ID);
|
|
106
|
-
* console.log(video.comments) // first 20 comments
|
|
107
|
-
*
|
|
108
|
-
* let newComments = await video.nextComments();
|
|
109
|
-
* console.log(newComments) // 20 loaded comments
|
|
110
|
-
* console.log(video.comments) // first 40 comments
|
|
111
|
-
*
|
|
112
|
-
* await video.nextComments(0); // load the rest of the comments in the playlist
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* @param count How many times to load the next comments. Set 0 to load all comments (might take a while on a video with many comments!)
|
|
116
|
-
*/
|
|
117
|
-
nextComments(count = 1) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
const newComments = [];
|
|
120
|
-
for (let i = 0; i < count || count == 0; i++) {
|
|
121
|
-
if (!this._commentContinuation)
|
|
122
|
-
break;
|
|
123
|
-
// Send request
|
|
124
|
-
const response = yield common_1.http.post(constants_1.COMMENT_END_POINT, {
|
|
125
|
-
data: { session_token: this._commentContinuation.xsrfToken },
|
|
126
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
127
|
-
params: {
|
|
128
|
-
action_get_comments: "1",
|
|
129
|
-
pbj: "1",
|
|
130
|
-
ctoken: this._commentContinuation.token,
|
|
131
|
-
continuation: this._commentContinuation.token,
|
|
132
|
-
itct: this._commentContinuation.itct,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
const { contents: comments, continuations, } = response.data.response.continuationContents.itemSectionContinuation;
|
|
136
|
-
const continuation = continuations === null || continuations === void 0 ? void 0 : continuations.pop().nextContinuationData;
|
|
137
|
-
this._commentContinuation = continuation
|
|
138
|
-
? {
|
|
139
|
-
token: continuation.continuation,
|
|
140
|
-
itct: continuation.clickTrackingParams,
|
|
141
|
-
xsrfToken: response.data.xsrf_token,
|
|
142
|
-
}
|
|
143
|
-
: undefined;
|
|
144
|
-
for (const comment of comments.map((c) => c.commentThreadRenderer)) {
|
|
145
|
-
newComments.push(new _1.Comment({ video: this }).load(comment));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
this.comments.push(...newComments);
|
|
149
|
-
return newComments;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
exports.default = Video;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { YoutubeRawData } from "../common";
|
|
2
|
-
import { Base, Channel, Thumbnails } from ".";
|
|
3
|
-
/** @hidden */
|
|
4
|
-
interface VideoCompactAttributes {
|
|
5
|
-
id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
thumbnails: Thumbnails;
|
|
8
|
-
duration: number | null;
|
|
9
|
-
isLiveContent: boolean;
|
|
10
|
-
channel?: Channel;
|
|
11
|
-
uploadDate?: string;
|
|
12
|
-
viewCount?: number;
|
|
13
|
-
}
|
|
14
|
-
/** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
|
|
15
|
-
export default class VideoCompact extends Base implements VideoCompactAttributes {
|
|
16
|
-
/** The video's ID */
|
|
17
|
-
id: string;
|
|
18
|
-
/** The title of the video */
|
|
19
|
-
title: string;
|
|
20
|
-
/** Thumbnails of the video with different sizes */
|
|
21
|
-
thumbnails: Thumbnails;
|
|
22
|
-
/** The duration of this video in second, null if the video is live */
|
|
23
|
-
duration: number | null;
|
|
24
|
-
/** Whether this video is a live content or not */
|
|
25
|
-
isLiveContent: boolean;
|
|
26
|
-
/** The channel who uploads this video */
|
|
27
|
-
channel?: Channel;
|
|
28
|
-
/** The date this video is uploaded at */
|
|
29
|
-
uploadDate?: string;
|
|
30
|
-
/** How many view does this video have, null if the view count is hidden */
|
|
31
|
-
viewCount?: number;
|
|
32
|
-
/** @hidden */
|
|
33
|
-
constructor(videoCompact?: Partial<VideoCompactAttributes>);
|
|
34
|
-
/**
|
|
35
|
-
* Load instance attributes from youtube raw data
|
|
36
|
-
*
|
|
37
|
-
* @param youtubeRawData raw object from youtubei
|
|
38
|
-
* @hidden
|
|
39
|
-
*/
|
|
40
|
-
load(youtubeRawData: YoutubeRawData): VideoCompact;
|
|
41
|
-
/**
|
|
42
|
-
* Whether this video is private / deleted or not, only useful in playlist's videos
|
|
43
|
-
*/
|
|
44
|
-
get isPrivateOrDeleted(): boolean;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const common_1 = require("../common");
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
/** Represent a compact video (e.g. from search result, playlist's videos, channel's videos) */
|
|
6
|
-
class VideoCompact extends _1.Base {
|
|
7
|
-
/** @hidden */
|
|
8
|
-
constructor(videoCompact = {}) {
|
|
9
|
-
super();
|
|
10
|
-
Object.assign(this, videoCompact);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Load instance attributes from youtube raw data
|
|
14
|
-
*
|
|
15
|
-
* @param youtubeRawData raw object from youtubei
|
|
16
|
-
* @hidden
|
|
17
|
-
*/
|
|
18
|
-
load(youtubeRawData) {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
-
const { videoId, title, lengthText, thumbnail, ownerText, shortBylineText, publishedTimeText, viewCountText, badges, thumbnailOverlays, } = youtubeRawData;
|
|
21
|
-
this.id = videoId;
|
|
22
|
-
this.title = title.simpleText || ((_a = title.runs[0]) === null || _a === void 0 ? void 0 : _a.text);
|
|
23
|
-
this.thumbnails = new _1.Thumbnails().load(thumbnail.thumbnails);
|
|
24
|
-
this.uploadDate = publishedTimeText === null || publishedTimeText === void 0 ? void 0 : publishedTimeText.simpleText;
|
|
25
|
-
this.duration =
|
|
26
|
-
common_1.getDuration((lengthText === null || lengthText === void 0 ? void 0 : lengthText.simpleText) || ((_b = thumbnailOverlays[0].thumbnailOverlayTimeStatusRenderer) === null || _b === void 0 ? void 0 : _b.text.simpleText) ||
|
|
27
|
-
"") || null;
|
|
28
|
-
this.isLiveContent = badges
|
|
29
|
-
? badges[0].metadataBadgeRenderer.style === "BADGE_STYLE_TYPE_LIVE_NOW"
|
|
30
|
-
: false;
|
|
31
|
-
// Channel
|
|
32
|
-
if (ownerText || shortBylineText) {
|
|
33
|
-
const { browseId, canonicalBaseUrl } = (ownerText || shortBylineText).runs[0].navigationEndpoint.browseEndpoint;
|
|
34
|
-
this.channel = new _1.Channel({
|
|
35
|
-
id: browseId,
|
|
36
|
-
name: (ownerText || shortBylineText).runs[0].text,
|
|
37
|
-
url: "https://www.youtube.com" + (canonicalBaseUrl || `/channel/${browseId}`),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (!this.isLiveContent)
|
|
41
|
-
this.viewCount = +((_c = viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.simpleText) === null || _c === void 0 ? void 0 : _c.replace(/[^0-9]/g, "")) || undefined;
|
|
42
|
-
else
|
|
43
|
-
this.viewCount = +(viewCountText === null || viewCountText === void 0 ? void 0 : viewCountText.runs[0].text.replace(/[^0-9]/g, "")) || undefined;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Whether this video is private / deleted or not, only useful in playlist's videos
|
|
48
|
-
*/
|
|
49
|
-
get isPrivateOrDeleted() {
|
|
50
|
-
return !this.duration;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.default = VideoCompact;
|
package/dist/classes/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { default as Client, SearchOptions, SearchType } from "./Client";
|
|
2
|
-
export { default as Base } from "./Base";
|
|
3
|
-
export { default as VideoCompact } from "./VideoCompact";
|
|
4
|
-
export { default as Thumbnails } from "./Thumbnails";
|
|
5
|
-
export { default as Channel } from "./Channel";
|
|
6
|
-
export { default as Comment } from "./Comment";
|
|
7
|
-
export { default as Chat } from "./Chat";
|
|
8
|
-
export { default as PlaylistCompact } from "./PlaylistCompact";
|
|
9
|
-
export { default as Playlist } from "./Playlist";
|
|
10
|
-
export { default as Video } from "./Video";
|
|
11
|
-
export { default as LiveVideo } from "./LiveVideo";
|
|
12
|
-
export { default as SearchResult } from "./SearchResult";
|
package/dist/classes/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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.SearchResult = exports.LiveVideo = exports.Video = exports.Playlist = exports.PlaylistCompact = exports.Chat = exports.Comment = exports.Channel = exports.Thumbnails = exports.VideoCompact = exports.Base = exports.Client = void 0;
|
|
7
|
-
var Client_1 = require("./Client");
|
|
8
|
-
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return __importDefault(Client_1).default; } });
|
|
9
|
-
var Base_1 = require("./Base");
|
|
10
|
-
Object.defineProperty(exports, "Base", { enumerable: true, get: function () { return __importDefault(Base_1).default; } });
|
|
11
|
-
var VideoCompact_1 = require("./VideoCompact");
|
|
12
|
-
Object.defineProperty(exports, "VideoCompact", { enumerable: true, get: function () { return __importDefault(VideoCompact_1).default; } });
|
|
13
|
-
var Thumbnails_1 = require("./Thumbnails");
|
|
14
|
-
Object.defineProperty(exports, "Thumbnails", { enumerable: true, get: function () { return __importDefault(Thumbnails_1).default; } });
|
|
15
|
-
var Channel_1 = require("./Channel");
|
|
16
|
-
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return __importDefault(Channel_1).default; } });
|
|
17
|
-
var Comment_1 = require("./Comment");
|
|
18
|
-
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return __importDefault(Comment_1).default; } });
|
|
19
|
-
var Chat_1 = require("./Chat");
|
|
20
|
-
Object.defineProperty(exports, "Chat", { enumerable: true, get: function () { return __importDefault(Chat_1).default; } });
|
|
21
|
-
var PlaylistCompact_1 = require("./PlaylistCompact");
|
|
22
|
-
Object.defineProperty(exports, "PlaylistCompact", { enumerable: true, get: function () { return __importDefault(PlaylistCompact_1).default; } });
|
|
23
|
-
var Playlist_1 = require("./Playlist");
|
|
24
|
-
Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return __importDefault(Playlist_1).default; } });
|
|
25
|
-
var Video_1 = require("./Video");
|
|
26
|
-
Object.defineProperty(exports, "Video", { enumerable: true, get: function () { return __importDefault(Video_1).default; } });
|
|
27
|
-
var LiveVideo_1 = require("./LiveVideo");
|
|
28
|
-
Object.defineProperty(exports, "LiveVideo", { enumerable: true, get: function () { return __importDefault(LiveVideo_1).default; } });
|
|
29
|
-
var SearchResult_1 = require("./SearchResult");
|
|
30
|
-
Object.defineProperty(exports, "SearchResult", { enumerable: true, get: function () { return __importDefault(SearchResult_1).default; } });
|
package/dist/common/helper.d.ts
DELETED
package/dist/common/helper.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getQueryParameter = exports.getDuration = void 0;
|
|
4
|
-
const url_1 = require("url");
|
|
5
|
-
/** @hidden */
|
|
6
|
-
const getDuration = (s) => {
|
|
7
|
-
s = s.replace(/:/g, ".");
|
|
8
|
-
const spl = s.split(".");
|
|
9
|
-
if (spl.length === 0)
|
|
10
|
-
return +spl;
|
|
11
|
-
else {
|
|
12
|
-
const sumStr = spl.pop();
|
|
13
|
-
if (sumStr !== undefined) {
|
|
14
|
-
let sum = +sumStr;
|
|
15
|
-
if (spl.length === 1)
|
|
16
|
-
sum += +spl[0] * 60;
|
|
17
|
-
if (spl.length === 2) {
|
|
18
|
-
sum += +spl[1] * 60;
|
|
19
|
-
sum += +spl[0] * 3600;
|
|
20
|
-
}
|
|
21
|
-
return sum;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
exports.getDuration = getDuration;
|
|
29
|
-
/** @hidden */
|
|
30
|
-
const getQueryParameter = (url, queryName) => {
|
|
31
|
-
try {
|
|
32
|
-
return new url_1.URL(url).searchParams.get(queryName) || url;
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
/* not an URL */
|
|
36
|
-
return url;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.getQueryParameter = getQueryParameter;
|
package/dist/common/http.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** @ignore */ /** */
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import https from "https";
|
|
4
|
-
import { IncomingHttpHeaders } from "http";
|
|
5
|
-
import { YoutubeRawData } from "./types";
|
|
6
|
-
/** @hidden */
|
|
7
|
-
interface Options extends https.RequestOptions {
|
|
8
|
-
params: Record<string, any>;
|
|
9
|
-
data: any;
|
|
10
|
-
headers: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
/** @hidden */
|
|
13
|
-
interface Response<T = any> {
|
|
14
|
-
data: T;
|
|
15
|
-
headers: IncomingHttpHeaders;
|
|
16
|
-
status: number | undefined;
|
|
17
|
-
}
|
|
18
|
-
/** @hidden */
|
|
19
|
-
export default class HTTP {
|
|
20
|
-
/**
|
|
21
|
-
* Send request to Youtube
|
|
22
|
-
*/
|
|
23
|
-
static request(partialOptions: Partial<Options>): Promise<Response>;
|
|
24
|
-
/**
|
|
25
|
-
* Send GET request to Youtube
|
|
26
|
-
*/
|
|
27
|
-
static get(path: string, options: Partial<Options>): Promise<YoutubeRawData>;
|
|
28
|
-
/**
|
|
29
|
-
* Send POST request to Youtube
|
|
30
|
-
*/
|
|
31
|
-
static post(path: string, options: Partial<Options>): Promise<YoutubeRawData>;
|
|
32
|
-
}
|
|
33
|
-
export {};
|