MCPcopy Create free account
hub / github.com/analyticswithadam/App_Script / insertCommentsToSheet

Function insertCommentsToSheet

YOuTube Comment Code with Likes.js:46–60  ·  view source on GitHub ↗
(comments)

Source from the content-addressed store, hash-verified

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

Callers 1

getYouTubeCommentsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected