Google Apps Script Error
Budget: $2 – $8 USD
i ran this code from this video in appscript to get data in google sheet from here https://www.youtube.com/watch?v=zSgx8U16stk but it gives me this error
1:58:00 AM Notice Execution started
1:58:02 AM Error
Exception: The number of rows in the range must be at least 1.
YoutubeScraper @ Code.gs:17
function YoutubeScraper() {
var spreadSheet = SpreadsheetApp.getActive()
var activeSheet = spreadSheet.getActiveSheet()
var search=YouTube.Search.list("snippet,id",{q:"chris landry",maxResults:50})
var results= search.items.map((item)=>[item.id.videoid, item.snippet.title, item.snippet.publishedAt])
var ids=results.map((id)=> id[0]).join(",")
var stats=YouTube.Videos.list("statistics",{id:ids})
var videoStats= stats.items.map((item)=>[item.statistics.viewCount, item.statistics.likeCount, item.statistics.dislikeCount])
activeSheet.getRange(2,1,results.length,results[0].length).setValues(results)
activeSheet.getRange(2,3,videoStats.length,results[0].length).setValue(videoStats)
}
1:58:00 AM Notice Execution started
1:58:02 AM Error
Exception: The number of rows in the range must be at least 1.
YoutubeScraper @ Code.gs:17
1:58:00 AM Notice Execution started
1:58:02 AM Error
Exception: The number of rows in the range must be at least 1.
YoutubeScraper @ Code.gs:17
function YoutubeScraper() {
var spreadSheet = SpreadsheetApp.getActive()
var activeSheet = spreadSheet.getActiveSheet()
var search=YouTube.Search.list("snippet,id",{q:"chris landry",maxResults:50})
var results= search.items.map((item)=>[item.id.videoid, item.snippet.title, item.snippet.publishedAt])
var ids=results.map((id)=> id[0]).join(",")
var stats=YouTube.Videos.list("statistics",{id:ids})
var videoStats= stats.items.map((item)=>[item.statistics.viewCount, item.statistics.likeCount, item.statistics.dislikeCount])
activeSheet.getRange(2,1,results.length,results[0].length).setValues(results)
activeSheet.getRange(2,3,videoStats.length,results[0].length).setValue(videoStats)
}
1:58:00 AM Notice Execution started
1:58:02 AM Error
Exception: The number of rows in the range must be at least 1.
YoutubeScraper @ Code.gs:17