Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Google Apps Script Tutorial to Upload Video From Google Drive to Youtube Using Javascript

Posted on November 27, 2022

 

 

Welcome folks today in this blog post we will be uploading video from google drive to youtube using google apps script in javascript. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new google apps script project and copy paste the code inside the code.gs file as shown below

 

 

code.gs

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function uploadToYoutube(){
const sourceFile = DriveApp.getFileById("##googledrivevideoid##").getBlob();
const videoResource = {
  snippet: {
    title: 'Summer vacation in California',
    description: 'Had a great time surfing in Santa Cruz',
    tags: [ 'surfing', 'Santa Cruz', ],
    categoryId: '22',
  },
  status: {privacyStatus: 'private'}  // Added
};
const newVideo = YouTube.Videos.insert( videoResource, "snippet,status", sourceFile);  // Modified
console.log(newVideo)
}

 

 

As you can see we are making the function which takes the video from the google drive and take it’s video id and upload it to youtube as a private video and also we are setting the basic information about the video such as the title and description using the drive and youtube api. For this you need to to drive and select the video you want to upload and then get it’s shareable link and from that you need to copy paste the video id and paste it in the above script. The process is shown below

 

 

 

 

 

 

 

 

 

Enabling the Google Drive and Youtube Services

 

 

Now we also need to enable the google drive and youtube api services. At the left hand side you will find the section of services we need to click on that as shown below

 

 

 

 

Now you just need to run the method to execute the script which will automatically fetch the google drive video and upload it to youtube as a private video

 

 

 

Recent Posts

  • Android Java Project to Crop,Scale & Rotate Images Selected From Gallery and Save it inside SD Card
  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Android Java Project to Make HTTP Call to JSONPlaceholder API and Display Data in RecyclerView Using GSON & Volley Library
  • Android Java Project to Download Youtube Video Thumbnail From URL & Save it inside SD Card
  • Android Java Project to Embed Google Maps & Add Markers Using Maps SDK
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme