UNPKG

node-apiless-youtube-upload-nc

Version:

Upload videos to Youtube in Node.js without any Youtube API dependency by using Selenium.

30 lines (23 loc) 1.18 kB
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)