Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Why is the "importchannel" function of this YouTube Data API to Google Sheets Apps Script not working?

$
0
0

Working off Joseph Asinyo's script in this Google Sheet template and every sheet except the Import Channel one is working fine.

Problem: No matter what channel name you enter you get the same output:output screenshot

  1. I assume something needs to be fixed or updated in the "importchannel" section to get the data to populate.

  2. Also wondering if there is a way to change the channel input from "channel name" to "channel handle instead (either the normal @ name or without if the user doesn't type it, perhaps using forHandle or something similar)."

Here is the script:

/** * IMPORT FROM YOUTUBE CUSTOM FUNCTIONS *  * Written with ❤️ by Joseph Asinyo */// IMPORTANT NOTE: Deploy the script as a web app and insert the url belowvar WEB_APP_URL = "https://script.google.com/macros/s/**keyhiddenforprivacy**/exec"// Web Apps using as the wrapper.function doGet(e) {  var request_type = e.parameter.request_type  if(request_type == "importvideo"){    var res = getVideoData(e.parameter.videoLink)  } else if(request_type == "importsearch"){    var res = getSearchData(e.parameter.searchTerm, e.parameter.numberOfVideos)  } else if(request_type == "importchannel"){    var res = getChannelData(e.parameter.channelName)  } else if(request_type == "importchannelvideos"){    var res = getChannelVideosData(e.parameter.channelName, e.parameter.numberOfVideos)  } else if(request_type == "importcomments"){    var res = getCommentsData(e.parameter.videoLink, e.parameter.numberOfComments, e.parameter.getReplies)  }   return ContentService.createTextOutput(JSON.stringify(res));}function makeRequestToWebApp(parameters) {  var url = WEB_APP_URL+"?";  for (const key of Object.keys(parameters)) {    url += key+"="+parameters[key]+"&";  }  url = url.slice(0, -1); // Remove the last "&" character  console.log(url)  var response = UrlFetchApp.fetch(url).getContentText();  var result = JSON.parse(response).data;  return result;}```

Viewing all articles
Browse latest Browse all 3831

Trending Articles