generate-youtube-tokens: add more explanatory text and clean up logging

This commit is contained in:
dumbmoron 2024-06-08 11:54:33 +00:00
parent ebe6668bc0
commit 6c1d8ef6c7
No known key found for this signature in database

View file

@ -1,4 +1,5 @@
import { Innertube } from 'youtubei.js';
import { Red } from '../modules/sub/consoleText.js'
const bail = (...msg) => {
console.error(...msg);
@ -9,9 +10,13 @@ const tube = await Innertube.create();
tube.session.once(
'auth-pending',
({ verification_url, user_code }) => console.log(
`Open ${verification_url} in a browser and enter ${user_code} when asked for the code.`
)
({ verification_url, user_code }) => {
console.log(`${Red('[!]')} The token generated by this script is sensitive and you should not share it with anyone!`);
console.log(` By using this token, you are risking your Google account getting terminated.`);
console.log(` You should ${Red('NOT')} use your personal account!`);
console.log();
console.log(`Open ${verification_url} in a browser and enter ${user_code} when asked for the code.`);
}
);
tube.session.once('auth-error', (err) => bail('An error occurred:', err));
@ -20,9 +25,8 @@ tube.session.once('auth', ({ status, credentials, ...rest }) => {
bail('something went wrong', rest);
}
console.log(credentials);
console.log(
'add this cookie to the youtube_oauth array in your cookies file:',
JSON.stringify(
Object.entries(credentials)
.map(([k, v]) => `${k}=${v instanceof Date ? v.toISOString() : v}`)