-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·40 lines (30 loc) · 1.1 KB
/
index.js
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
import { Innertube, UniversalCache } from "youtubei.js";
import { createSpinner } from "nanospinner";
import config from "./config.json" assert {type: "json"};
// import { prompt } from "./src/utils/input.js";
import { input } from "@inquirer/prompts";
import { search_music } from "./src/music.js";
const spinner = createSpinner("Loading...").start();
(async () => {
// console.log(config);
const yt = await Innertube.create({
...config,
cache: new UniversalCache(true, "./.cache")
});
yt.session.on("auth-pending", (data) => {
console.log(`Enter ${data.verification_url} in your browser and enter ${data.user_code}...`);
})
yt.session.on("auth", ({ credentials }) => {
// console.log(`Signed in successfully: ${credentials}`);
})
yt.session.on("update-credentials", async ({ credentials }) => {
// console.log(`Credentials updated ${ credentials }`);
await yt.session.oauth.cacheCredentials();
})
await yt.session.signIn();
spinner.stop();
console.clear();
const id = await search_music(spinner, yt)
// const inf = await yt.getInfo(id)
// console.dir(inf)
})()