forked from evilive3000/node-apiless-youtube-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYoutubeUploader.ts
33 lines (27 loc) · 1.01 KB
/
YoutubeUploader.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
import promptLoginAndGetCookies from './methods/promptLoginAndGetCookies'
import checkCookiesValidity from './methods/checkCookiesValidity'
import uploadVideo, {VideoObj} from './methods/uploadVideo'
import {Cookies} from './helpers'
export default class YoutubeUploader {
private cookies: Cookies
async promptLoginAndGetCookies(): Promise<Cookies> {
this.cookies = await promptLoginAndGetCookies()
return this.cookies
}
async checkCookiesValidity(): Promise<boolean> {
return checkCookiesValidity(this.cookies)
}
async loadCookiesFromDisk(path: string): Promise<void> {
this.cookies = Cookies.fromJSONFileSync(path)
}
async saveCookiesToDisk(path: string): Promise<void> {
return this.cookies.saveToFileSync(path)
}
async uploadVideo(
videoObj: VideoObj,
headlessMode?: boolean,
onProgress?: (a: string) => any,
): Promise<void> {
return uploadVideo(videoObj, this.cookies, headlessMode, onProgress)
}
}