I found a code to upload a Video to YouTube with Google apps script. But with this i can only upload a file from a URL, not from google drive. Now, how can i upload a file from Google Drive using Google Apps Script?
That's the Code i found to upload a Video from a URL to YouTube:
function upload(url, title, description, topics) {
try {
var video = UrlFetchApp.fetch(url);
YouTube.Videos.insert({
snippet: {
title: title,
description: description,
tags: topics
},
status: {
privacyStatus: "public",
},
}, "snippet,status", video);
return ContentService.createTextOutput("done")
} catch (err) {
return ContentService.createTextOutput(err.message)
}
}
You cant upload videos to YouTube directly from Google drive. That is not how things work.
Files are uploaded from the machine running the code via a file stream.
Check the top of the documentation for video.insert
Videos uploaded via the YouTube API in a project that has not yet been verified are set to private automatically you need to go though the verification process.