Question: How to use delete of playlistItems in Google Apps Script?
What I tried:
- All these give
Missing name after . operator. (line 123, file "Code")error (I have a sense it might be related to JavaScript delete operator, not sure.):
YouTube.PlaylistItems.delete()
YouTube.PlaylistItems.delete("PLi22jkbHFzDjQNWcy4qfLamNjyb0nvkq8")
YouTube.PlaylistItems.delete({id: "PLi22jkbHFzDjQNWcy4qfLamNjyb0nvkq8"})
- Apparently, executes fine, but no effect:
var payload =
{
"id" : "PLi22jkbHFzDjQNWcy4qfLamNjyb0nvkq8",
};
var options =
{
"method" : "delete",
"payload" : payload
};
Logger.log(UrlFetchApp.fetch("https://www.googleapis.com/youtube/v3/playlistItems", options));
Any help would be greatly appreciated.
Extra details. The thing I want to do is clear all of the items in a playlist and I already have the following code:
var result = YouTube.PlaylistItems.list('id', {
playlistId: "2L1YG9ktx9sVdo-PMFD2iwCC-UWmkYrgQ-"
});
Logger.log(result.items.length);
var items = result.items;
for (var i = 0; i < items.length; i++) {
Logger.log(items[i].id);
// Deletion of the item with id of "items[i].id is expected to happen here
}