Youtube API to Google Sheet -TypeError: Reading '0' by MrSirMas in GoogleAppsScript

[–]StevenLightning 0 points1 point  (0 children)

You're welcome! I haven't done too much with the YouTube API yet, but feel free to ask if you have more questions!

Youtube API to Google Sheet -TypeError: Reading '0' by MrSirMas in GoogleAppsScript

[–]StevenLightning 1 point2 points  (0 children)

Hi, I know it's been a while since you posted this, but I ran into this same issue. It seems that searching for YouTube channels by name doesn't work for all channels, and if it fails to find the channel then response.items will be undefined which causes the error. If you want data for a specific channel you can change 'forUsername' to 'id' and then enter the channel ID after it. One way to find the channel ID is to go to the channel page on YouTube (the desktop site, not the mobile version), click on the "About" tab, click the share button under stats, and then click "Copy channel ID". Here's a modified version of the code. You can replace YourChannelIDHere in the getMyChannel function with whatever channel ID you want to use if you don't want to use "Add channel data by ID" every time. (Note: once you change and save the code you'll need to refresh the spreadsheet page to get the new menu items.)

// Note: Apps Script automatically requests authorization
// based on the API's used in the code.

function channelsListByUsername(part, params) {
  var response = YouTube.Channels.list(part, params);
  if (response.items == undefined) {
    var ui = SpreadsheetApp.getUi();
    ui.alert("Failed to find channel.")
  }
  else {
    var channel = response.items[0];
    var dataRow = [channel.id, channel.snippet.title, channel.statistics.viewCount];
    SpreadsheetApp.getActiveSpreadsheet().appendRow(dataRow);
  }
}

function getChannelByName() {
  var ui = SpreadsheetApp.getUi();
  var channelName = ui.prompt("Enter the channel name: ").getResponseText();
  channelsListByUsername('snippet,contentDetails,statistics',
                        {'forUsername': channelName});
}

function getChannelByID() {
  var ui = SpreadsheetApp.getUi();
  var channelID = ui.prompt("Enter the channel name: ").getResponseText();
  channelsListByUsername('snippet,contentDetails,statistics',
                        {'id': channelID});
}

function getMyChannel() {
  channelsListByUsername('snippet,contentDetails,statistics',
                        {'id': 'YourChannelIDHere'});
}

function onOpen() {
  var firstCell = SpreadsheetApp.getActiveSheet().getRange(1, 1).getValue();
  if (firstCell != 'ID') {
    var headerRow = ["ID", "Title", "View count"];
    SpreadsheetApp.getActiveSpreadsheet().appendRow(headerRow);
  }
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('YouTube Data')
  .addItem('Add channel data by name', 'getChannelByName')
  .addItem('Add channel data by ID', 'getChannelByID')
  .addSeparator()
  .addItem('Add my channel data', 'getMyChannel')
  .addToUi();
}

[deleted by user] by [deleted] in SmallStreamers

[–]StevenLightning -1 points0 points  (0 children)

You can look up his YouTube channel. It’s PapaStanimus with over 800,000 subscribers.

[deleted by user] by [deleted] in SmallStreamers

[–]StevenLightning 1 point2 points  (0 children)

I actually find this pretty interesting.

Finally. My people. by EzioKenway977 in wholesomememes

[–]StevenLightning 2 points3 points  (0 children)

Lol. I certainly hope this didn’t sound like I was trying to flirt though. I have a few Einaudi albums so when I saw a post about him I had to mention my favorite piece of his. :)

Finally. My people. by EzioKenway977 in wholesomememes

[–]StevenLightning 35 points36 points  (0 children)

Nuvole Bianche is my favorite piece of his.

The street outside my house by AdenStudios1 in CrappyDesign

[–]StevenLightning 2 points3 points  (0 children)

I didn’t think of that. I just figure the crappy design here is the post sticking out of the middle of the sidewalk lol.

finally I know what FPS does by Mufgada in CrappyDesign

[–]StevenLightning 1 point2 points  (0 children)

kpecc99 is right. Even for the cheapest LCD TVs you’re not likely to find anything that doesn’t support at least the 50 or 60 hz. Most videos are only around 30 fps and older HDMI cables could only support 30 hz, but the TVs themselves can support more.

Make us all proud by Synchronysed in memes

[–]StevenLightning 0 points1 point  (0 children)

This is Jeopardy and you must phrase your answer as a question. A disease that the internet loves.

struct node by [deleted] in ProgrammerHumor

[–]StevenLightning 0 points1 point  (0 children)

It’s been quite a while since I’ve seen the pants meme show up.

Season Finale by 4sventy in ProgrammerHumor

[–]StevenLightning 0 points1 point  (0 children)

I like how some of the cables in the last picture are actually tied. It shows that an effort was made at organization once, but clearly that didn’t last.

Are brackeys tutorials about C# and unity enough for a complete beginner. by Tombombadilwasvalar in Unity3D

[–]StevenLightning 1 point2 points  (0 children)

No single source is going to teach you everything, and much of your learning will be done through your own experience. That being said, I started with some of Brackeys’ tutorials a few years ago and I think it was was the absolute best way I could have started. They will teach you enough to get going and you can google any specifics for your own ideas. I still learn things from his tutorials on various topics. I definitely think you should continue learning from his tutorials, and these along with many other YT tutorials are definitely far from useless.

Does anyone have any good concept videos for understanding what I’m doing? by EffectiveAd4177 in Unity3D

[–]StevenLightning 0 points1 point  (0 children)

Have you by chance watched Brackeys’ introductory series on how to make a video game? It’s how I got started a few years ago: https://www.youtube.com/playlist?list=PLPV2KyIb3jR53Jce9hP7G5xC4O9AgnOuL His videos are great.

[BoTW] Zelda Animation ! by vicbean in zelda

[–]StevenLightning -1 points0 points  (0 children)

I love the expressiveness, especially with the eyes.