I’m getting video data from Youtube and also the video’s channel’s data using two http modules. However, I want to reduce the operations for the iterations it takes to put the data in a Google spreadsheet. Using the flatten and merge array functions, I’ve managed to get them all in 1 operation, BUT i can’t map them to google sheets like this. so, I want to be able to match the channel id key from the video HTTP module, to the id key in the channel HTTP module, so that they combine.
I’ve tried using chatgpt to tell me the js code I can accomplish this, but I’m still lost.
here is the output from the merge iterator. The output puts all the youtube#channel kind bundles first, then the videos:
Here’s the code chatgpt told me to use:
let channel = {
kind: "youtube#channel",
etag: "wcT2KncGAhdhfoaHxyhZIxIiwHY",
id: "UCHaSwvPfNrjZ9RZy17rAhPw",
statisticsCollection: {
viewCount: 5117220,
subscriberCount: 34800,
hiddenSubscriberCount: false,
videoCount: 536
}
};
let video = {
kind: "youtube#video",
etag: "pWYWHABuYu_goppGBGPhsr05UoU",
id: "BX61XKNYvIY",
snippetCollection: {
publishedAt: "2022-11-09T04:14:24Z",
channelId: "UCjSOwkYUtTDjDoPczoTv_Hw",
title: "What is Airtable? And Is It For Me?",
description: "Airtable is one of my favorite foundational tools that I use for a variety of projects, both for work and personally.",
thumbnailsCollection: {},
channelTitle: "Dan Leeman",
categoryId: 27,
liveBroadcastContent: "none",
localizedCollection: {},
defaultAudioLanguage: "en"
},
statisticsCollection: {
viewCount: 162661,
likeCount: 1965,
favoriteCount: 0,
commentCount: 63
}
};
if (video.snippetCollection.channelId === channel.id) {
let combinedData = {
videoId: video.id,
videoTitle: video.snippetCollection.title,
videoPublishedAt: video.snippetCollection.publishedAt,
videoDescription: video.snippetCollection.description,
videoViewCount: video.statisticsCollection.viewCount,
videoLikeCount: video.statisticsCollection.likeCount,
videoCommentCount: video.statisticsCollection.commentCount,
channelId: channel.id,
channelTitle: video.snippetCollection.channelTitle,
channelSubscriberCount: channel.statisticsCollection.subscriberCount,
channelViewCount: channel.statisticsCollection.viewCount,
channelVideoCount: channel.statisticsCollection.videoCount
};
return [combinedData];
} else {
return [];
}
And here is my flow so far: