Vincenzo Caserta made this article to help people that want to show the visualizations or else on a YouTube video title.
This is a simple HTML representation of a Google Apps Script that renames a YouTube video using the YouTube Data API.
Script
function renameYouTubeVideo(videoId, newTitle) {
var apiKey = 'YOUR_API_KEY'; // Replace with your API key
var apiUrl = 'https://www.googleapis.com/youtube/v3/videos';
var headers = {
'Authorization': 'Bearer ' + ScriptApp.getOAuthToken(),
'Accept': 'application/json',
'Content-Type': 'application/json'
};
var payload = {
'id': videoId,
'snippet': {
'title': newTitle
}
};
var params = {
'method': 'put',
'headers': headers,
'payload': JSON.stringify(payload),
'muteHttpExceptions': true
};
var response = UrlFetchApp.fetch(apiUrl + '?part=snippet', params);
var result = JSON.parse(response.getContentText());
if (result.error) {
Logger.log('Error updating video title: ' + result.error.message);
return false;
}
Logger.log('Video title updated successfully.');
return true;
}
Make sure to replace 'YOUR_API_KEY' with your actual API key. Also, ensure that your YouTube account has the necessary permissions to modify videos.
Run the Script
- Save your script.
- Run the
renameYouTubeVideo
function. It will prompt you to authorize the script's access to your YouTube account.
Remember to handle authentication and authorization properly. If you are sharing the script with others, they need to have the necessary permissions and API access as well. Additionally, be cautious about storing and sharing API keys as they are sensitive information.