youtubei 0.0.1-rc.9 → 1.0.0-rc.3
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/{classes → cjs/classes/LiveVideo}/LiveVideo.js +84 -89
- package/dist/cjs/classes/LiveVideo/LiveVideoParser.js +29 -0
- package/dist/cjs/classes/LiveVideo/index.js +14 -0
- package/dist/cjs/classes/MixPlaylist/MixPlaylist.js +25 -0
- package/dist/cjs/classes/MixPlaylist/MixPlaylistParser.js +27 -0
- package/dist/cjs/classes/MixPlaylist/index.js +14 -0
- package/dist/cjs/classes/Playlist/Playlist.js +25 -0
- package/dist/cjs/classes/Playlist/PlaylistParser.js +83 -0
- package/dist/cjs/classes/Playlist/PlaylistVideos.js +50 -0
- package/dist/cjs/classes/Playlist/index.js +15 -0
- package/dist/cjs/classes/PlaylistCompact/PlaylistCompact.js +45 -0
- package/dist/cjs/classes/PlaylistCompact/PlaylistCompactParser.js +28 -0
- package/dist/cjs/classes/PlaylistCompact/index.js +14 -0
- package/dist/cjs/classes/Reply/Reply.js +23 -0
- package/dist/cjs/classes/Reply/ReplyParser.js +26 -0
- package/dist/cjs/classes/Reply/index.js +14 -0
- package/dist/cjs/classes/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/{classes/Base.js → cjs/classes/SearchResult/proto/SearchProto.js} +2 -5
- package/dist/cjs/classes/SearchResult/proto/index.js +57 -0
- package/dist/{classes → cjs/classes/Thumbnails}/Thumbnails.js +67 -66
- package/dist/cjs/classes/Thumbnails/index.js +13 -0
- package/dist/cjs/classes/Video/Video.js +26 -0
- package/dist/cjs/classes/Video/VideoComments.js +53 -0
- package/dist/cjs/classes/Video/VideoParser.js +29 -0
- package/dist/cjs/classes/Video/index.js +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 -14
- package/dist/cjs/common/helper.js +45 -0
- package/dist/{common → cjs/common}/index.js +16 -23
- package/dist/{common → cjs/common}/mixins.js +14 -12
- package/dist/{common → cjs/common}/types.js +2 -2
- package/dist/{constants.js → cjs/constants.js} +10 -10
- package/dist/{index.js → cjs/index.js} +13 -13
- package/dist/esm/classes/Base/Base.js +8 -0
- package/dist/esm/classes/Base/index.js +1 -0
- package/dist/esm/classes/BaseChannel/BaseChannel.js +48 -0
- package/dist/esm/classes/BaseChannel/BaseChannelParser.js +24 -0
- package/dist/esm/classes/BaseChannel/ChannelPlaylists.js +109 -0
- package/dist/esm/classes/BaseChannel/ChannelVideos.js +109 -0
- package/dist/esm/classes/BaseChannel/index.js +4 -0
- package/dist/esm/classes/BaseVideo/BaseVideo.js +51 -0
- package/dist/esm/classes/BaseVideo/BaseVideoParser.js +93 -0
- package/dist/esm/classes/BaseVideo/VideoRelated.js +87 -0
- package/dist/esm/classes/BaseVideo/index.js +3 -0
- package/dist/esm/classes/Channel/Channel.js +37 -0
- package/dist/esm/classes/Channel/ChannelParser.js +77 -0
- package/dist/esm/classes/Channel/index.js +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/{classes → typings/classes/LiveVideo}/LiveVideo.d.ts +46 -44
- package/dist/typings/classes/LiveVideo/LiveVideoParser.d.ts +10 -0
- package/dist/typings/classes/LiveVideo/index.d.ts +2 -0
- package/dist/typings/classes/MixPlaylist/MixPlaylist.d.ts +29 -0
- package/dist/typings/classes/MixPlaylist/MixPlaylistParser.d.ts +6 -0
- package/dist/typings/classes/MixPlaylist/index.d.ts +2 -0
- package/dist/typings/classes/Playlist/Playlist.d.ts +39 -0
- package/dist/typings/classes/Playlist/PlaylistParser.d.ts +16 -0
- package/dist/typings/classes/Playlist/PlaylistVideos.d.ts +31 -0
- package/dist/typings/classes/Playlist/index.d.ts +3 -0
- package/dist/typings/classes/PlaylistCompact/PlaylistCompact.d.ts +43 -0
- package/dist/typings/classes/PlaylistCompact/PlaylistCompactParser.d.ts +5 -0
- package/dist/typings/classes/PlaylistCompact/index.d.ts +2 -0
- package/dist/typings/classes/Reply/Reply.d.ts +43 -0
- package/dist/typings/classes/Reply/ReplyParser.d.ts +5 -0
- package/dist/typings/classes/Reply/index.d.ts +2 -0
- package/dist/typings/classes/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/{classes → typings/classes/Thumbnails}/Thumbnails.d.ts +41 -42
- package/dist/typings/classes/Thumbnails/index.d.ts +1 -0
- package/dist/typings/classes/Video/Video.d.ts +24 -0
- package/dist/typings/classes/Video/VideoComments.d.ts +34 -0
- package/dist/typings/classes/Video/VideoParser.d.ts +8 -0
- package/dist/typings/classes/Video/index.d.ts +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 -5
- package/dist/typings/common/helper.d.ts +5 -0
- package/dist/typings/common/index.d.ts +4 -0
- package/dist/typings/common/mixins.d.ts +1 -0
- package/dist/{common → typings/common}/types.d.ts +1 -1
- package/dist/{constants.d.ts → typings/constants.d.ts} +7 -7
- package/dist/{index.d.ts → typings/index.d.ts} +1 -1
- package/package.json +68 -53
- package/CHANGELOG.md +0 -6
- package/dist/classes/Base.d.ts +0 -7
- package/dist/classes/BaseVideo.d.ts +0 -54
- package/dist/classes/BaseVideo.js +0 -82
- package/dist/classes/Channel.d.ts +0 -83
- package/dist/classes/Channel.js +0 -138
- package/dist/classes/Chat.d.ts +0 -29
- package/dist/classes/Chat.js +0 -31
- package/dist/classes/Client.d.ts +0 -30
- package/dist/classes/Client.js +0 -69
- package/dist/classes/Comment.d.ts +0 -43
- package/dist/classes/Comment.js +0 -42
- package/dist/classes/Playlist.d.ts +0 -61
- package/dist/classes/Playlist.js +0 -127
- package/dist/classes/PlaylistCompact.d.ts +0 -30
- package/dist/classes/PlaylistCompact.js +0 -45
- package/dist/classes/SearchResult.d.ts +0 -69
- package/dist/classes/SearchResult.js +0 -139
- package/dist/classes/Video.d.ts +0 -49
- package/dist/classes/Video.js +0 -102
- package/dist/classes/VideoCompact.d.ts +0 -40
- package/dist/classes/VideoCompact.js +0 -50
- package/dist/classes/index.d.ts +0 -13
- package/dist/classes/index.js +0 -32
- package/dist/common/helper.d.ts +0 -2
- package/dist/common/helper.js +0 -37
- package/dist/common/http.d.ts +0 -30
- package/dist/common/http.js +0 -108
- package/dist/common/index.d.ts +0 -5
- package/dist/common/mixins.d.ts +0 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Vincent Jonathan
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Vincent Jonathan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
# Youtubei
|
|
2
|
-
|
|
3
|
-
`Youtubei` is made to replace my other library [scrape-yt](https://github.com/SuspiciousLookingOwl/scrape-yt/). Instead of scrapping data from Youtube page, `youtubei` fetches data by sending a request directly to `https://www.youtube.com/youtubei/v1`, which should be faster and provide more reliable result.
|
|
4
|
-
|
|
5
|
-
<b>Requires Node >=
|
|
6
|
-
|
|
7
|
-
#### [Documentation](https://
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Example
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.log(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Features to be added
|
|
52
|
-
- [ ] Get Comment replies
|
|
53
|
-
- [ ] Add related continuation support
|
|
1
|
+
# Youtubei
|
|
2
|
+
|
|
3
|
+
`Youtubei` is made to replace my other library [scrape-yt](https://github.com/SuspiciousLookingOwl/scrape-yt/). Instead of scrapping data from Youtube page, `youtubei` fetches data by sending a request directly to `https://www.youtube.com/youtubei/v1`, which should be faster and provide more reliable result.
|
|
4
|
+
|
|
5
|
+
<b>Requires Node >= 16</b>
|
|
6
|
+
|
|
7
|
+
#### [Documentation](https://suspiciouslookingowl.github.io/youtubei)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm i youtubei
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
const { Client } = require("youtubei");
|
|
19
|
+
// or for TS / ES6
|
|
20
|
+
import { Client } from "youtubei";
|
|
21
|
+
|
|
22
|
+
const youtube = new Client();
|
|
23
|
+
|
|
24
|
+
const run = async () => {
|
|
25
|
+
const videos = await youtube.search("Never gonna give you up", {
|
|
26
|
+
type: "video", // video | playlist | channel | all
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(videos.items.length); // 20
|
|
30
|
+
const nextVideos = await videos.next(); // load next page
|
|
31
|
+
console.log(nextVideos.length); // 18-20, inconsistent next videos count from youtube
|
|
32
|
+
console.log(videos.items.length); // 38 - 40
|
|
33
|
+
|
|
34
|
+
// you can also pass the video URL
|
|
35
|
+
const video = await youtube.getVideo("dQw4w9WgXcQ");
|
|
36
|
+
|
|
37
|
+
const channelVideos = await video.channel.videos.next();
|
|
38
|
+
const channelPlaylists = await video.channel.playlists.next();
|
|
39
|
+
|
|
40
|
+
// you can also pass the playlist URL
|
|
41
|
+
const playlist = await youtube.getPlaylist("UUHnyfMqiRRG1u-2MsSQLbXA");
|
|
42
|
+
console.log(playlist.videos.items.length); // first 100 videos;
|
|
43
|
+
let newVideos = await playlist.videos.next(); // load next 100 videos
|
|
44
|
+
console.log(playlist.videos.items.length); // 200 videos;
|
|
45
|
+
await playlist.videos.next(0); // load the rest videos in the playlist
|
|
46
|
+
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
run();
|
|
50
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Base"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseChannel = void 0;
|
|
4
|
+
const Base_1 = require("../Base");
|
|
5
|
+
const BaseChannelParser_1 = require("./BaseChannelParser");
|
|
6
|
+
const ChannelPlaylists_1 = require("./ChannelPlaylists");
|
|
7
|
+
const ChannelVideos_1 = require("./ChannelVideos");
|
|
8
|
+
/** Represents a Youtube Channel */
|
|
9
|
+
class BaseChannel extends Base_1.Base {
|
|
10
|
+
/** @hidden */
|
|
11
|
+
constructor(attr) {
|
|
12
|
+
super(attr.client);
|
|
13
|
+
Object.assign(this, attr);
|
|
14
|
+
this.videos = new ChannelVideos_1.ChannelVideos({ channel: this, client: this.client });
|
|
15
|
+
this.playlists = new ChannelPlaylists_1.ChannelPlaylists({ channel: this, client: this.client });
|
|
16
|
+
}
|
|
17
|
+
/** The URL of the channel page */
|
|
18
|
+
get url() {
|
|
19
|
+
return `https://www.youtube.com/channel/${this.id}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Load this instance with raw data from Youtube
|
|
23
|
+
*
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
load(data) {
|
|
27
|
+
BaseChannelParser_1.BaseChannelParser.loadBaseChannel(this, data);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BaseChannel = BaseChannel;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseChannelParser = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const Thumbnails_1 = require("../Thumbnails");
|
|
6
|
+
class BaseChannelParser {
|
|
7
|
+
static loadBaseChannel(target, data) {
|
|
8
|
+
const { channelId, title, thumbnail, videoCountText, subscriberCountText } = data;
|
|
9
|
+
target.id = channelId;
|
|
10
|
+
target.name = title.simpleText;
|
|
11
|
+
target.thumbnails = new Thumbnails_1.Thumbnails().load(thumbnail.thumbnails);
|
|
12
|
+
target.videoCount = common_1.stripToInt(videoCountText === null || videoCountText === void 0 ? void 0 : videoCountText.runs[0].text) || 0;
|
|
13
|
+
target.subscriberCount = subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText;
|
|
14
|
+
return target;
|
|
15
|
+
}
|
|
16
|
+
/** Parse tab data from request, tab name is ignored if it's a continuation data */
|
|
17
|
+
static parseTabData(name, data) {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
const index = name === "videos" ? 1 : 2;
|
|
20
|
+
return (((_b = (_a = data.contents) === null || _a === void 0 ? void 0 : _a.twoColumnBrowseResultsRenderer.tabs[index].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer) === null || _b === void 0 ? void 0 : _b.items) || ((_c = data.onResponseReceivedActions) === null || _c === void 0 ? void 0 : _c[0].appendContinuationItemsAction.continuationItems) ||
|
|
21
|
+
[]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.BaseChannelParser = BaseChannelParser;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChannelPlaylists = void 0;
|
|
13
|
+
const common_1 = require("../../common");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const Continuable_1 = require("../Continuable");
|
|
16
|
+
const PlaylistCompact_1 = require("../PlaylistCompact");
|
|
17
|
+
const BaseChannelParser_1 = require("./BaseChannelParser");
|
|
18
|
+
/**
|
|
19
|
+
* {@link Continuable} of playlists inside a {@link BaseChannel}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```js
|
|
23
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
24
|
+
* await channel.playlists.next();
|
|
25
|
+
* console.log(channel.playlists.items) // first 30 playlists
|
|
26
|
+
*
|
|
27
|
+
* let newPlaylists = await channel.playlists.next();
|
|
28
|
+
* console.log(newPlaylists) // 30 loaded playlists
|
|
29
|
+
* console.log(channel.playlists.items) // first 60 playlists
|
|
30
|
+
*
|
|
31
|
+
* await channel.playlists.next(0); // load the rest of the playlists in the channel
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class ChannelPlaylists extends Continuable_1.Continuable {
|
|
35
|
+
/** @hidden */
|
|
36
|
+
constructor({ client, channel }) {
|
|
37
|
+
super({ client, strictContinuationCheck: true });
|
|
38
|
+
this.channel = channel;
|
|
39
|
+
}
|
|
40
|
+
fetch() {
|
|
41
|
+
var _a;
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const params = "EglwbGF5bGlzdHMgAQ%3D%3D";
|
|
44
|
+
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
45
|
+
data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params, continuation: this.continuation },
|
|
46
|
+
});
|
|
47
|
+
const items = BaseChannelParser_1.BaseChannelParser.parseTabData("playlists", response.data);
|
|
48
|
+
const continuation = common_1.getContinuationFromItems(items);
|
|
49
|
+
const data = common_1.mapFilter(items, "gridPlaylistRenderer");
|
|
50
|
+
return {
|
|
51
|
+
continuation,
|
|
52
|
+
items: data.map((i) => new PlaylistCompact_1.PlaylistCompact({ client: this.client, channel: this.channel }).load(i)),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ChannelPlaylists = ChannelPlaylists;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChannelVideos = void 0;
|
|
13
|
+
const common_1 = require("../../common");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const Continuable_1 = require("../Continuable");
|
|
16
|
+
const VideoCompact_1 = require("../VideoCompact");
|
|
17
|
+
const BaseChannelParser_1 = require("./BaseChannelParser");
|
|
18
|
+
/**
|
|
19
|
+
* {@link Continuable} of videos inside a {@link BaseChannel}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```js
|
|
23
|
+
* const channel = await youtube.findOne(CHANNEL_NAME, {type: "channel"});
|
|
24
|
+
* await channel.videos.next();
|
|
25
|
+
* console.log(channel.videos.items) // first 30 videos
|
|
26
|
+
*
|
|
27
|
+
* let newVideos = await channel.videos.next();
|
|
28
|
+
* console.log(newVideos) // 30 loaded videos
|
|
29
|
+
* console.log(channel.videos.items) // first 60 videos
|
|
30
|
+
*
|
|
31
|
+
* await channel.videos.next(0); // load the rest of the videos in the channel
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class ChannelVideos extends Continuable_1.Continuable {
|
|
35
|
+
/** @hidden */
|
|
36
|
+
constructor({ client, channel }) {
|
|
37
|
+
super({ client, strictContinuationCheck: true });
|
|
38
|
+
this.channel = channel;
|
|
39
|
+
}
|
|
40
|
+
fetch() {
|
|
41
|
+
var _a;
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const params = "EgZ2aWRlb3M%3D";
|
|
44
|
+
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/browse`, {
|
|
45
|
+
data: { browseId: (_a = this.channel) === null || _a === void 0 ? void 0 : _a.id, params, continuation: this.continuation },
|
|
46
|
+
});
|
|
47
|
+
const items = BaseChannelParser_1.BaseChannelParser.parseTabData("videos", response.data);
|
|
48
|
+
const continuation = common_1.getContinuationFromItems(items);
|
|
49
|
+
const data = common_1.mapFilter(items, "gridVideoRenderer");
|
|
50
|
+
return {
|
|
51
|
+
continuation,
|
|
52
|
+
items: data.map((i) => new VideoCompact_1.VideoCompact({ client: this.client, channel: this.channel }).load(i)),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ChannelVideos = ChannelVideos;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./BaseChannel"), exports);
|
|
14
|
+
__exportStar(require("./BaseChannelParser"), exports);
|
|
15
|
+
__exportStar(require("./ChannelPlaylists"), exports);
|
|
16
|
+
__exportStar(require("./ChannelVideos"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseVideo = void 0;
|
|
4
|
+
const Base_1 = require("../Base");
|
|
5
|
+
const BaseVideoParser_1 = require("./BaseVideoParser");
|
|
6
|
+
const VideoRelated_1 = require("./VideoRelated");
|
|
7
|
+
/** Represents a Video */
|
|
8
|
+
class BaseVideo extends Base_1.Base {
|
|
9
|
+
/** @hidden */
|
|
10
|
+
constructor(attr) {
|
|
11
|
+
super(attr.client);
|
|
12
|
+
Object.assign(this, attr);
|
|
13
|
+
this.related = new VideoRelated_1.VideoRelated({ client: this.client, video: this });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load this instance with raw data from Youtube
|
|
17
|
+
*
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
load(data) {
|
|
21
|
+
BaseVideoParser_1.BaseVideoParser.loadBaseVideo(this, data);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Video / playlist to play next after this video, alias to
|
|
26
|
+
* ```js
|
|
27
|
+
* video.related.items[0]
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
get upNext() {
|
|
31
|
+
return this.related.items[0];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.BaseVideo = BaseVideo;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseVideoParser = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
6
|
+
const PlaylistCompact_1 = require("../PlaylistCompact");
|
|
7
|
+
const Thumbnails_1 = require("../Thumbnails");
|
|
8
|
+
const VideoCompact_1 = require("../VideoCompact");
|
|
9
|
+
class BaseVideoParser {
|
|
10
|
+
static loadBaseVideo(target, data) {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const videoInfo = BaseVideoParser.parseRawData(data);
|
|
13
|
+
// Basic information
|
|
14
|
+
target.id = videoInfo.videoDetails.videoId;
|
|
15
|
+
target.title = videoInfo.videoDetails.title;
|
|
16
|
+
target.uploadDate = videoInfo.dateText.simpleText;
|
|
17
|
+
target.viewCount = +videoInfo.videoDetails.viewCount || null;
|
|
18
|
+
target.isLiveContent = videoInfo.videoDetails.isLiveContent;
|
|
19
|
+
target.thumbnails = new Thumbnails_1.Thumbnails().load(videoInfo.videoDetails.thumbnail.thumbnails);
|
|
20
|
+
// Channel
|
|
21
|
+
const { title, thumbnail, subscriberCountText } = videoInfo.owner.videoOwnerRenderer;
|
|
22
|
+
target.channel = new BaseChannel_1.BaseChannel({
|
|
23
|
+
client: target.client,
|
|
24
|
+
id: title.runs[0].navigationEndpoint.browseEndpoint.browseId,
|
|
25
|
+
name: title.runs[0].text,
|
|
26
|
+
subscriberCount: subscriberCountText === null || subscriberCountText === void 0 ? void 0 : subscriberCountText.simpleText,
|
|
27
|
+
thumbnails: new Thumbnails_1.Thumbnails().load(thumbnail.thumbnails),
|
|
28
|
+
});
|
|
29
|
+
// Like Count and Dislike Count
|
|
30
|
+
const topLevelButtons = videoInfo.videoActions.menuRenderer.topLevelButtons;
|
|
31
|
+
target.likeCount = common_1.stripToInt(BaseVideoParser.parseButtonRenderer(topLevelButtons[0]));
|
|
32
|
+
// Tags and description
|
|
33
|
+
target.tags =
|
|
34
|
+
((_b = (_a = videoInfo.superTitleLink) === null || _a === void 0 ? void 0 : _a.runs) === null || _b === void 0 ? void 0 : _b.map((r) => r.text.trim()).filter((t) => t)) || [];
|
|
35
|
+
target.description =
|
|
36
|
+
((_c = videoInfo.description) === null || _c === void 0 ? void 0 : _c.runs.map((d) => d.text).join("")) || "";
|
|
37
|
+
// related videos
|
|
38
|
+
const secondaryContents = data[3].response.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults
|
|
39
|
+
.results;
|
|
40
|
+
if (secondaryContents) {
|
|
41
|
+
target.related.items = BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, target.client);
|
|
42
|
+
target.related.continuation = common_1.getContinuationFromItems(secondaryContents);
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
static parseRelated(data, client) {
|
|
47
|
+
const secondaryContents = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
|
|
48
|
+
return BaseVideoParser.parseRelatedFromSecondaryContent(secondaryContents, client);
|
|
49
|
+
}
|
|
50
|
+
static parseContinuation(data) {
|
|
51
|
+
const secondaryContents = data.onResponseReceivedEndpoints[0].appendContinuationItemsAction.continuationItems;
|
|
52
|
+
return common_1.getContinuationFromItems(secondaryContents);
|
|
53
|
+
}
|
|
54
|
+
static parseRawData(data) {
|
|
55
|
+
const contents = data[3].response.contents.twoColumnWatchNextResults.results.results.contents;
|
|
56
|
+
const primaryInfo = contents.find((c) => "videoPrimaryInfoRenderer" in c)
|
|
57
|
+
.videoPrimaryInfoRenderer;
|
|
58
|
+
const secondaryInfo = contents.find((c) => "videoSecondaryInfoRenderer" in c).videoSecondaryInfoRenderer;
|
|
59
|
+
const videoDetails = data[2].playerResponse.videoDetails;
|
|
60
|
+
return Object.assign(Object.assign(Object.assign({}, secondaryInfo), primaryInfo), { videoDetails });
|
|
61
|
+
}
|
|
62
|
+
static parseCompactRenderer(data, client) {
|
|
63
|
+
if ("compactVideoRenderer" in data) {
|
|
64
|
+
return new VideoCompact_1.VideoCompact({ client }).load(data.compactVideoRenderer);
|
|
65
|
+
}
|
|
66
|
+
else if ("compactRadioRenderer" in data) {
|
|
67
|
+
return new PlaylistCompact_1.PlaylistCompact({ client }).load(data.compactRadioRenderer);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static parseRelatedFromSecondaryContent(secondaryContents, client) {
|
|
71
|
+
return secondaryContents
|
|
72
|
+
.map((c) => BaseVideoParser.parseCompactRenderer(c, client))
|
|
73
|
+
.filter((c) => c !== undefined);
|
|
74
|
+
}
|
|
75
|
+
static parseButtonRenderer(data) {
|
|
76
|
+
var _a;
|
|
77
|
+
const buttonRenderer = data.toggleButtonRenderer || data.buttonRenderer;
|
|
78
|
+
const accessibilityData = (((_a = buttonRenderer.defaultText) === null || _a === void 0 ? void 0 : _a.accessibility) || buttonRenderer.accessibilityData).accessibilityData;
|
|
79
|
+
return accessibilityData.label;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.BaseVideoParser = BaseVideoParser;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VideoRelated = void 0;
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
14
|
+
const Continuable_1 = require("../Continuable");
|
|
15
|
+
const BaseVideoParser_1 = require("./BaseVideoParser");
|
|
16
|
+
/**
|
|
17
|
+
* {@link Continuable} of related videos inside a Video
|
|
18
|
+
*/
|
|
19
|
+
class VideoRelated extends Continuable_1.Continuable {
|
|
20
|
+
/** @hidden */
|
|
21
|
+
constructor({ video, client }) {
|
|
22
|
+
super({ client });
|
|
23
|
+
this.video = video;
|
|
24
|
+
}
|
|
25
|
+
fetch() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const response = yield this.client.http.post(`${constants_1.I_END_POINT}/next`, {
|
|
28
|
+
data: { continuation: this.continuation },
|
|
29
|
+
});
|
|
30
|
+
const items = BaseVideoParser_1.BaseVideoParser.parseRelated(response.data, this.client);
|
|
31
|
+
const continuation = BaseVideoParser_1.BaseVideoParser.parseContinuation(response.data);
|
|
32
|
+
return {
|
|
33
|
+
continuation,
|
|
34
|
+
items,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.VideoRelated = VideoRelated;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./BaseVideo"), exports);
|
|
14
|
+
__exportStar(require("./BaseVideoParser"), exports);
|
|
15
|
+
__exportStar(require("./VideoRelated"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Channel = void 0;
|
|
4
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
5
|
+
const ChannelParser_1 = require("./ChannelParser");
|
|
6
|
+
/** Represents a Youtube Channel */
|
|
7
|
+
class Channel extends BaseChannel_1.BaseChannel {
|
|
8
|
+
/** @hidden */
|
|
9
|
+
constructor(attr) {
|
|
10
|
+
super(attr);
|
|
11
|
+
this.shelves = [];
|
|
12
|
+
Object.assign(this, attr);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load this instance with raw data from Youtube
|
|
16
|
+
*
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
load(data) {
|
|
20
|
+
ChannelParser_1.ChannelParser.loadChannel(this, data);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Channel = Channel;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelParser = void 0;
|
|
4
|
+
const BaseChannel_1 = require("../BaseChannel");
|
|
5
|
+
const PlaylistCompact_1 = require("../PlaylistCompact");
|
|
6
|
+
const Thumbnails_1 = require("../Thumbnails");
|
|
7
|
+
const VideoCompact_1 = require("../VideoCompact");
|
|
8
|
+
class ChannelParser {
|
|
9
|
+
static loadChannel(target, data) {
|
|
10
|
+
const { channelId, title, avatar, subscriberCountText, } = data.header.c4TabbedHeaderRenderer;
|
|
11
|
+
target.id = channelId;
|
|
12
|
+
target.name = title;
|
|
13
|
+
target.thumbnails = new Thumbnails_1.Thumbnails().load(avatar.thumbnails);
|
|
14
|
+
target.videoCount = 0; // data not available
|
|
15
|
+
target.subscriberCount = subscriberCountText.simpleText;
|
|
16
|
+
const { tvBanner, mobileBanner, banner } = data.header.c4TabbedHeaderRenderer;
|
|
17
|
+
target.banner = new Thumbnails_1.Thumbnails().load((banner === null || banner === void 0 ? void 0 : banner.thumbnails) || []);
|
|
18
|
+
target.tvBanner = new Thumbnails_1.Thumbnails().load((tvBanner === null || tvBanner === void 0 ? void 0 : tvBanner.thumbnails) || []);
|
|
19
|
+
target.mobileBanner = new Thumbnails_1.Thumbnails().load((mobileBanner === null || mobileBanner === void 0 ? void 0 : mobileBanner.thumbnails) || []);
|
|
20
|
+
target.shelves = ChannelParser.parseShelves(target, data);
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
static parseShelves(target, data) {
|
|
24
|
+
const shelves = [];
|
|
25
|
+
const rawShelves = data.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content
|
|
26
|
+
.sectionListRenderer.contents;
|
|
27
|
+
for (const rawShelf of rawShelves) {
|
|
28
|
+
const shelfRenderer = rawShelf.itemSectionRenderer.contents[0].shelfRenderer;
|
|
29
|
+
if (!shelfRenderer)
|
|
30
|
+
continue;
|
|
31
|
+
const { title, content, subtitle } = shelfRenderer;
|
|
32
|
+
if (!content.horizontalListRenderer)
|
|
33
|
+
continue;
|
|
34
|
+
const items = content.horizontalListRenderer.items
|
|
35
|
+
.map((i) => {
|
|
36
|
+
if (i.gridVideoRenderer)
|
|
37
|
+
return new VideoCompact_1.VideoCompact({ client: target.client }).load(i.gridVideoRenderer);
|
|
38
|
+
if (i.gridPlaylistRenderer)
|
|
39
|
+
return new PlaylistCompact_1.PlaylistCompact({ client: target.client }).load(i.gridPlaylistRenderer);
|
|
40
|
+
if (i.gridChannelRenderer)
|
|
41
|
+
return new BaseChannel_1.BaseChannel({ client: target.client }).load(i.gridChannelRenderer);
|
|
42
|
+
return undefined;
|
|
43
|
+
})
|
|
44
|
+
.filter((i) => i !== undefined);
|
|
45
|
+
const shelf = {
|
|
46
|
+
title: title.runs[0].text,
|
|
47
|
+
subtitle: subtitle === null || subtitle === void 0 ? void 0 : subtitle.simpleText,
|
|
48
|
+
items,
|
|
49
|
+
};
|
|
50
|
+
shelves.push(shelf);
|
|
51
|
+
}
|
|
52
|
+
return shelves;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.ChannelParser = ChannelParser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Channel"), exports);
|
|
14
|
+
__exportStar(require("./ChannelParser"), exports);
|