-
-
Notifications
You must be signed in to change notification settings - Fork 235
/
basic-info.ts
50 lines (36 loc) · 1.47 KB
/
basic-info.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Innertube, UniversalCache, YTNodes } from 'youtubei.js';
(async () => {
const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true });
const channel = await yt.getChannel('UCX6OQ3DkcsbYNE6H8uQQuVA');
if (channel.header?.is(YTNodes.C4TabbedHeader)) {
console.info('Viewing channel:', channel?.header?.author.name);
console.info('Family Safe:', channel.metadata.is_family_safe);
}
const about = await channel.getAbout();
console.info('Country:', about.country.toString());
console.info('\nVideos:');
const videos = await channel.getVideos();
for (const video of videos.videos) {
console.info('Video:', video.title.toString());
}
console.info('\nPopular videos:');
const popular_videos = await videos.applyFilter('Popular');
for (const video of popular_videos.videos) {
console.info('Video:', video.title.toString());
}
console.info('\nPlaylists:');
const playlists = await channel.getPlaylists();
for (const playlist of playlists.playlists) {
console.info('Playlist:', playlist.title.toString());
}
console.info('\nChannels:');
const channels = await channel.getChannels();
for (const channel of channels.channels) {
console.info('Channel:', channel.author.name);
}
console.info('\nCommunity posts:');
const posts = await channel.getCommunity();
for (const post of posts.posts) {
console.info('Post:', post.content.toString().substring(0, 20) + '...');
}
})();