This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function youtube(){ | |
| // Setup OAuthServiceConfig | |
| var oAuthConfig = UrlFetchApp.addOAuthService("youtube"); | |
| oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); | |
| oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=http%3A%2F%2Fgdata.youtube.com%2F"); | |
| oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); | |
| oAuthConfig.setConsumerKey("anonymous"); | |
| oAuthConfig.setConsumerSecret("anonymous"); | |
| // Setup optional parameters to point request at OAuthConfigService. The "twitter" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doGet(e){ | |
| // get some variables passed from the querystring | |
| var project = e.parameter.title; | |
| var range = e.parameter.range; | |
| var sheet = e.parameter.sheet; | |
| // Grab a basic html template to fill in the blanks - see https://developers.google.com/apps-script/html_service | |
| var t = HtmlService.createTemplateFromFile("reportTemplate"); | |
| // some bits of code to grab the source urls | |
| var doc = SpreadsheetApp.openById(ScriptProperties.getProperty('active')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function youtube(){ | |
| // Setup OAuthServiceConfig | |
| var oAuthConfig = UrlFetchApp.addOAuthService("youtube"); | |
| oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); | |
| oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=http%3A%2F%2Fgdata.youtube.com%2F"); | |
| oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); | |
| oAuthConfig.setConsumerKey("anonymous"); | |
| oAuthConfig.setConsumerSecret("anonymous"); | |
| // Setup optional parameters to point request at OAuthConfigService. The "twitter" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fetchUrlfromRSS(url) { | |
| var cache = CacheService.getPublicCache(); // using Cache service to prevent too many urlfetch | |
| var cached = cache.get(url); | |
| if (cached != null) { // if value in cache return it | |
| return cached; | |
| } | |
| // otherwise build urlfetch | |
| var options = {"method" : "get"}; | |
| try { | |
| var response = UrlFetchApp.fetch(url , options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function scheduledCollection(){ | |
| var schedule = []; | |
| // dates/times in mm/dd/yyyy hh:mm - timezone matches settings in File > Project properties | |
| schedule.push({start:"08/29/2012 15:00", end:"08/29/2012 16:00"}); | |
| schedule.push({start:"08/29/2012 20:00", end:"08/29/2012 22:00"}); | |
| checkCollect(schedule); | |
| } | |
| function checkCollect(schedule){ | |
| var now = new Date(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copyright 2011 Martin Hawksey | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function combineData(){ | |
| var doc = SpreadsheetApp.getActiveSpreadsheet(); | |
| var sheets = doc.getSheets(); // get all the sheets | |
| var outSheet = doc.getSheetByName("combined"); // set where we want to write the results | |
| for (i in sheets){ // loop across all the sheets | |
| if (sheets[i].getSheetName().substring(0,9) == "followers"){ // if sheetname starts with 'follower' then | |
| var target = sheets[i].getSheetName().substring(12); // extract users name for target column | |
| var data = getRowsData(sheets[i]); // get extisting data from current sheet | |
| for (j in data){ | |
| data[j]["target"] = target; // create a target column with the users name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The rest of this code is currently (c) Google Inc. | |
| // setRowsData fills in one row of data per object defined in the objects Array. | |
| // For every Column, it checks if data objects define a value for it. | |
| // Arguments: | |
| // - sheet: the Sheet Object where the data will be written | |
| // - objects: an Array of Objects, each of which contains data for a row | |
| // - optHeadersRange: a Range of cells where the column headers are defined. This | |
| // defaults to the entire first row in sheet. | |
| // - optFirstDataRowIndex: index of the first row where data should be written. This |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copyright 2011 Martin Hawksey | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // script used in http://mashe.hawksey.info/google-refine-apps-script-integration | |
| function setup(){ | |
| ScriptProperties.setProperty('active', SpreadsheetApp.getActiveSpreadsheet().getId()); | |
| } | |
| function doGet(e){ | |
| var secret ="lemons"; //must match secret in Google Refine | |
| if (e.parameter.secret == secret){ | |
| var ss = SpreadsheetApp.openById(ScriptProperties.getProperty('active')); | |
| var sheet = ss.getSheetByName("Vertices"); // sheet name of where you want the data to go | |
| var idx = parseInt(e.parameter.idx); // I had an idx column sequentially numbered to give me a row index |