MCPcopy Index your code
hub / github.com/analyticswithadam/App_Script / insertCommentsToSheet

Function insertCommentsToSheet

YouTube_Comments.js:47–61  ·  view source on GitHub ↗
(comments)

Source from the content-addressed store, hash-verified

45
46// Helper function to insert comments into Google Sheets
47function insertCommentsToSheet(comments) {
48 const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
49
50 // Insert header at row 5 and apply formatting
51 const headerRange = sheet.getRange(5, 1, 1, 3);
52 headerRange.setValues([['Author', 'Comment', 'Published At']]);
53 headerRange.setFontWeight('bold'); // Make headers bold
54 headerRange.setBackground('#f0f0f0'); // Light grey background for headers
55 headerRange.setHorizontalAlignment('center'); // Center align headers
56
57 // Insert comments starting from row 5
58 if (comments.length > 0) {
59 sheet.getRange(6, 1, comments.length, comments[0].length).setValues(comments);
60 }
61}
62
63function auth() {
64 cache = CacheService.getUserCache();

Callers 1

getYouTubeCommentsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected