forked from evilive3000/node-apiless-youtube-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.ts
29 lines (23 loc) · 1.12 KB
/
usage.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
import YoutubeUploader from './YoutubeUploader'
const main = async () => {
const youtubeUploader = new YoutubeUploader()
// Open a login window for Google account. Cookies will be stored in the youtubeUploader instance
await youtubeUploader.promptLoginAndGetCookies()
// Check if cookies are valid
if (await youtubeUploader.checkCookiesValidity()) {
// Upload a video to youtube
await youtubeUploader.uploadVideo({
videoPath: 'C:/Users/gladiatortoise/Desktop/testVideo.mp4',
title: '📡 Automatically Uploaded Video 📡',
description: 'This is a placeholder description.',
thumbnailPath: 'C:/Users/gladiatortoise/Desktop/TestThumbnail.jpg',
visibility: 'unlisted',
monetization: false,
})
}
// save cookies for later usage
await youtubeUploader.saveCookiesToDisk(process.cwd() + '/cookies_saved.json')
// later, cookies can be loaded like this so there's no need to repeatedly call promptLogin
await youtubeUploader.loadCookiesFromDisk(process.cwd() + '/cookies_saved.json')
}
main().catch(console.error)