youtubei 0.0.1-rc.32 → 0.0.1-rc.33
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/CHANGELOG.md +6 -0
- package/dist/classes/BaseVideo.d.ts +7 -3
- package/dist/classes/BaseVideo.js +13 -7
- package/dist/classes/Client.js +2 -2
- package/dist/classes/LiveVideo.js +1 -1
- package/dist/classes/PlaylistCompact.d.ts +1 -1
- package/dist/classes/PlaylistCompact.js +1 -1
- package/dist/classes/Video.js +1 -1
- package/package.json +1 -1
- package/website/README.md +33 -0
package/CHANGELOG.md
ADDED
|
@@ -11,7 +11,6 @@ export interface BaseVideoAttributes extends BaseAttributes {
|
|
|
11
11
|
likeCount: number | null;
|
|
12
12
|
isLiveContent: boolean;
|
|
13
13
|
tags: string[];
|
|
14
|
-
upNext: VideoCompact | PlaylistCompact | null;
|
|
15
14
|
related: (VideoCompact | PlaylistCompact)[];
|
|
16
15
|
relatedContinuation?: string;
|
|
17
16
|
}
|
|
@@ -35,8 +34,6 @@ export default class BaseVideo extends Base implements BaseVideoAttributes {
|
|
|
35
34
|
isLiveContent: boolean;
|
|
36
35
|
/** The tags of this video */
|
|
37
36
|
tags: string[];
|
|
38
|
-
/** Next video / playlist recommended by Youtube */
|
|
39
|
-
upNext: VideoCompact | PlaylistCompact | null;
|
|
40
37
|
/** Videos / playlists related to this video */
|
|
41
38
|
related: (VideoCompact | PlaylistCompact)[];
|
|
42
39
|
/** Current continuation token to load next related content */
|
|
@@ -49,6 +46,13 @@ export default class BaseVideo extends Base implements BaseVideoAttributes {
|
|
|
49
46
|
* @hidden
|
|
50
47
|
*/
|
|
51
48
|
load(data: YoutubeRawData): BaseVideo;
|
|
49
|
+
/**
|
|
50
|
+
* Video / playlist to play next after this video, alias to
|
|
51
|
+
* ```js
|
|
52
|
+
* video.related[0]
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
get upNext(): VideoCompact | PlaylistCompact;
|
|
52
56
|
/** Load next related videos / playlists */
|
|
53
57
|
nextRelated(count?: number): Promise<(VideoCompact | PlaylistCompact)[]>;
|
|
54
58
|
/** @hidden */
|
|
@@ -27,7 +27,7 @@ class BaseVideo extends _1.Base {
|
|
|
27
27
|
* @hidden
|
|
28
28
|
*/
|
|
29
29
|
load(data) {
|
|
30
|
-
var _a, _b, _c
|
|
30
|
+
var _a, _b, _c;
|
|
31
31
|
const videoInfo = BaseVideo.parseRawData(data);
|
|
32
32
|
// Basic information
|
|
33
33
|
this.id = videoInfo.videoDetails.videoId;
|
|
@@ -55,21 +55,27 @@ class BaseVideo extends _1.Base {
|
|
|
55
55
|
((_c = videoInfo.description) === null || _c === void 0 ? void 0 : _c.runs.map((d) => d.text).join("")) || "";
|
|
56
56
|
// Up Next and related videos
|
|
57
57
|
this.related = [];
|
|
58
|
-
const secondaryContents = data
|
|
58
|
+
const secondaryContents = data.response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
|
|
59
59
|
.results;
|
|
60
60
|
if (secondaryContents) {
|
|
61
|
-
const upNext = ((_d = secondaryContents.find((s) => "compactAutoplayRenderer" in s)) === null || _d === void 0 ? void 0 : _d.compactAutoplayRenderer.contents[0]) || null;
|
|
62
|
-
this.upNext = upNext ? BaseVideo.parseCompactRenderer(upNext, this.client) : upNext;
|
|
63
61
|
this.related.push(...BaseVideo.parseRelated(secondaryContents, this.client));
|
|
64
62
|
// Related continuation
|
|
65
63
|
this.relatedContinuation = common_1.getContinuationFromItems(secondaryContents);
|
|
66
64
|
}
|
|
67
65
|
else {
|
|
68
|
-
this.upNext = null;
|
|
69
66
|
this.related = [];
|
|
70
67
|
}
|
|
71
68
|
return this;
|
|
72
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Video / playlist to play next after this video, alias to
|
|
72
|
+
* ```js
|
|
73
|
+
* video.related[0]
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
get upNext() {
|
|
77
|
+
return this.related[0];
|
|
78
|
+
}
|
|
73
79
|
/** Load next related videos / playlists */
|
|
74
80
|
nextRelated(count = 1) {
|
|
75
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -91,11 +97,11 @@ class BaseVideo extends _1.Base {
|
|
|
91
97
|
}
|
|
92
98
|
/** @hidden */
|
|
93
99
|
static parseRawData(data) {
|
|
94
|
-
const contents = data
|
|
100
|
+
const contents = data.response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
95
101
|
const primaryInfo = contents.find((c) => "videoPrimaryInfoRenderer" in c)
|
|
96
102
|
.videoPrimaryInfoRenderer;
|
|
97
103
|
const secondaryInfo = contents.find((c) => "videoSecondaryInfoRenderer" in c).videoSecondaryInfoRenderer;
|
|
98
|
-
const videoDetails = data
|
|
104
|
+
const videoDetails = data.playerResponse.videoDetails;
|
|
99
105
|
return Object.assign(Object.assign(Object.assign({}, secondaryInfo), primaryInfo), { videoDetails });
|
|
100
106
|
}
|
|
101
107
|
static parseRelated(secondaryContents, client) {
|
package/dist/classes/Client.js
CHANGED
|
@@ -73,9 +73,9 @@ class Client {
|
|
|
73
73
|
const response = yield this.http.get(`${constants_1.WATCH_END_POINT}`, {
|
|
74
74
|
params: { v: videoId, pbj: "1" },
|
|
75
75
|
});
|
|
76
|
-
if (!response.data
|
|
76
|
+
if (!response.data.response.contents)
|
|
77
77
|
return undefined;
|
|
78
|
-
return (!response.data
|
|
78
|
+
return (!response.data.playerResponse.playabilityStatus.liveStreamability
|
|
79
79
|
? new _1.Video({ client: this }).load(response.data)
|
|
80
80
|
: new _1.LiveVideo({ client: this }).load(response.data));
|
|
81
81
|
});
|
|
@@ -37,7 +37,7 @@ class LiveVideo extends _1.BaseVideo {
|
|
|
37
37
|
.map((r) => r.text)
|
|
38
38
|
.join(" ")
|
|
39
39
|
.replace(/[^0-9]/g, "");
|
|
40
|
-
this.chatContinuation = (_a = data
|
|
40
|
+
this.chatContinuation = (_a = data.response.contents.twoColumnWatchNextResults.conversationBar.liveChatRenderer) === null || _a === void 0 ? void 0 : _a.continuations[0].reloadContinuationData.continuation;
|
|
41
41
|
return this;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -7,7 +7,7 @@ interface PlaylistCompactAttributes extends BaseAttributes {
|
|
|
7
7
|
channel?: ChannelCompact;
|
|
8
8
|
videoCount: number;
|
|
9
9
|
}
|
|
10
|
-
/** Represents a Compact Playlist (e.g. from search result,
|
|
10
|
+
/** Represents a Compact Playlist (e.g. from search result, related of a video) */
|
|
11
11
|
export default class PlaylistCompact extends Base implements PlaylistCompactAttributes {
|
|
12
12
|
/** The playlist's title */
|
|
13
13
|
title: string;
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const _1 = require(".");
|
|
13
13
|
const common_1 = require("../common");
|
|
14
|
-
/** Represents a Compact Playlist (e.g. from search result,
|
|
14
|
+
/** Represents a Compact Playlist (e.g. from search result, related of a video) */
|
|
15
15
|
class PlaylistCompact extends _1.Base {
|
|
16
16
|
/** @hidden */
|
|
17
17
|
constructor(playlist = {}) {
|
package/dist/classes/Video.js
CHANGED
|
@@ -36,7 +36,7 @@ class Video extends _1.BaseVideo {
|
|
|
36
36
|
// Duration
|
|
37
37
|
const videoInfo = _1.BaseVideo.parseRawData(data);
|
|
38
38
|
this.duration = +videoInfo.videoDetails.lengthSeconds;
|
|
39
|
-
const itemSectionRenderer = data
|
|
39
|
+
const itemSectionRenderer = data.response.contents.twoColumnWatchNextResults.results.results.contents.find((c) => c.itemSectionRenderer).itemSectionRenderer;
|
|
40
40
|
this.commentContinuation = common_1.getContinuationFromItems(itemSectionRenderer.contents);
|
|
41
41
|
return this;
|
|
42
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "youtubei",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"version": "0.0.1-rc.33",
|
|
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/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Website
|
|
2
|
+
|
|
3
|
+
This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```console
|
|
8
|
+
yarn install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Local Development
|
|
12
|
+
|
|
13
|
+
```console
|
|
14
|
+
yarn start
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
|
|
18
|
+
|
|
19
|
+
## Build
|
|
20
|
+
|
|
21
|
+
```console
|
|
22
|
+
yarn build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
|
|
26
|
+
|
|
27
|
+
## Deployment
|
|
28
|
+
|
|
29
|
+
```console
|
|
30
|
+
GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
|