Git Product home page Git Product logo

node-apiless-youtube-upload's Introduction

node-apiless-youtube-upload

Upload videos to Youtube in node.js, ts-node or electron, and on windows or linux without any Youtube API dependency! Chromedriver required by Selenium will be automatically downloaded during runtime (using node-chromedriver-downloader). Note: headless login is out of scope for this module, because it's difficult to maintain.

Installation
npm install node-apiless-youtube-upload
Usage
ES6 Simple
import {promptLoginAndGetCookies, uploadVideo} from 'node-apiless-youtube-upload'

promptLoginAndGetCookies().then(cookies => {
    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
    }, cookies)
})
ES6 With Saving Cookies
import YoutubeUploader from 'node-apiless-youtube-upload'

(async () => {
    const youtubeUploader = new YoutubeUploader()
    const cookiesPath = process.cwd() + '/cookies_saved.json'

    // Try loading cookies from disk
    try {
        await youtubeUploader.loadCookiesFromDisk(cookiesPath)

        if (!(await youtubeUploader.checkCookiesValidity())) {
            throw new Error('Cookies loaded from disk are not valid')
        }
    } catch(e) {
        console.log('Prompting Google login..')

        // Open a login window for Google account. Cookies will be stored in the youtubeUploader instance
        await youtubeUploader.promptLoginAndGetCookies()

        // Save cookies
        await youtubeUploader.saveCookiesToDisk(cookiesPath)
    }
    
    // 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
    })
})()
CommonJS Simple
const {promptLoginAndGetCookies, uploadVideo} = require('node-apiless-youtube-upload')

promptLoginAndGetCookies().then(cookies => {
    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
    }, cookies)
})
Requirements

At least node 7.6 for async/await support and a Chrome web browser. Unfortunately MacOs is not (yet) supported

Motivation

Recent changes in Youtube v3 API (2020, September) made it impossible to upload videos from unverified apps. Google does not verify apps for internal or private use. This module is intended to be an easy solution for programmatically uploading videos to Youtube.

Massive thanks to @Jaqen00 for helping with testing!

node-apiless-youtube-upload's People

Contributors

patrr2 avatar evilive3000 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.