I get this error when I run trying to get the statistics:
'Exception: The number of rows in the range must be at least 1.'
It runs well without the last line.
This is the code:
function YoutubeScraper() { var ss = SpreadsheetApp.getActiveSpreadsheet() var sheet = ss.getActiveSheet() var search = YouTube.Search.list ("snippet, id", {q: "searching youtube", maxResults: 30}) var results = search.items.map((item) => [item.snippet.title, item.snippet.channelId, 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.commentCount]) sheet.getRange(2,1, results.length, results[0].length).setValues(results) sheet.getRange(2,3, videoStats.length, results[0].length).setValues(videoStats)}
I was hoping to get a list on my active sheet with the query results and their stats. Can get the results but not the stats. I've tried changing the range on the stats but it doesn't work. Runs well without the last line, my active sheet on Google Docs gets populated with the results (title, channelId, and publish time), but cannot get the last line to work.