What is the Difference Between YouTube (Data API) and YouTube (Data API) - Custom App?

This topic was automatically generated from Slack. You can find the original thread here.

Can anyone explain the difference between “YouTube (Data API)” and “YouTube (Data API) - Custom App”?

The custom app uses your own credentials for an OAuth app that you configure on Google Cloud Platform. The benefit of going that route is that you have tighter control over the scopes you grant when you connect the account and you have greater flexibility re: quota limits for their API.

YouTube applies an app-wide quota for their API, which applies to all users who use the normal YouTube Data API app on Pipedream

OK. So if anyone else batters the limit I might not have access to the pipedream app when I try to run my workflow? I just want to update a playlist once a week so pretty low resource use I expect but if the app is regularly over the limit I guess I should get my own. Any idea how often it gos over?

We don’t exceed the quota limit regularly right now

So you can certainly start there and go the custom route if you need to

OK. I’ll stick with your app for now and build my own if it becomes a necessity. Thanks.

Apologies for the noob question. I have more experience in spreadsheets than real coding. In the “array” box to provide the video links to add to the playlist I want to write the equivalent of {{steps.custom_request.$return_value.videos[0]}}:{{steps.custom_request.$return_value.videos[50]}} so that any video from 0-50 in my returned results is added. Sometimes there will be 0 returned results. Sometimes 5. Maximum 50. etc.

> so that any video from 0-50 in my returned results is added
Hello , you will need to use custom expression to add the video id array into the Video IDs prop. Though I’m not seeing video id field in the video array, may I ask if it can be extracted from the url?

To add an expression, you can tap Enter a custom expression and put the Node.js code inside the {{ }} backets. For example; {{ steps.custom_request.$return_value.videos }} (note that this example will not work for your case, as the Video IDs prop accept the IDs, not the video object)

The ID should just be the end of the URL (after the = sign). So I guess I have to run a filter/code of some sort on it. Like

<script type="text/javascript">
function youtube_parser(url){
    var regExp = /^.**(([youtu.be](http://youtu.be)\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]**).*/;
    var match = url.match(regExp);
    return (match&&match[7].length==11)? match[7] : false;
}
</script>

or

regex = /http\:\/\/www\.youtube\.com\/watch\?v=([\w-]{11})/;

url = 'http://www.youtube.com/watch?v=Ahg6qcgoay4';
id = url.match(regex)[1]; // id = 'Ahg6qcgoay4'

So I need to enter these as some sort of code step after my results and before I attempt to build the playlist right?

yes you’re correct. You might need to add a code step to extract ids from the videos object. Then pass them into the Video IDs prop using custom expression

As a test I added Introduction to Pipedream - YouTube to my playlist by adding ivkE26ZsyUo to the array field and hitting test. It worked. I did the same with 9dZW1C3neao. That worked too. When I entered [ivkE26ZsyUo, 9dZW1C3neao] or [ivkE26ZsyUo,9dZW1C3neao] into the array field it did not work. What is the correct format for writing a list of items in an array field on pipedream?

If you manually input the array, you should use Custom Expression and it should be {{ ["ivkE26ZsyUo", "9dZW1C3neao"] }} (notice the quotes and the brackets)

You can watch this video which explain alot

{{ [“ivkE26ZsyUo”, “9dZW1C3neao”] }} in the custom field worked. Thanks. I’ll move onto running that code to trim the video IDs from my previous results and be back with more questions after that! Is there a way to push the results of the ID trimming of the video URLs into a format that can be enterered into the array field? ie something like {{videotrimcode.results}} (pls excuse the bad code example)

> there a way to push the results of the ID trimming of the video URLs into a format that can be enterered into the array field
It is really depend on your code step logic, it should return an array of string, for example: ["ivkE26ZsyUo", "9dZW1C3neao"]. Then you can just simple pass the result into Video IDs field {{steps.extract_video_ids.$return_value}}

Unfortunately I’m stuck again. If I have the results from the previous step as steps.custom_request.$return_value.videos which contains steps.custom_request.$return_value.videos[0].uri steps.custom_request.$return_value.videos[1].uri … steps.custom_request.$return_value.videos[4].uri how do I grab those 5 urls? How do I grab them if there are 0 or 20 instead? I need to grab “all URLs within steps.custom_request.$return_value.videos” but I don’t know how to do that. Once I have that I can try to trim the URLs.

is there such a a thing as steps.custom_request.$return_value.videos[ALL].uri

Hi , you can use Node.js code step to transform the videos object, and return an array of ids

I would strongly recommend you to read through Pipedream Quickstart doc, Pipedream university videos, and also Javascript knowledge to know how to implement your usecase

If you’d like to have a dedicated support for your usecase, you can subscribe to Pipedream team plan, where you’ll be added to a dedicated support channel. Or you can hire a Pipedream expert in via this link: Connect with a Pipedream Partner

OK, thanks I have read and watched those videos. I think they only mentioned how to grab specific paths. Not a group of paths. I’m surprised there’s not a simple line like steps.custom_request.$return_value.videos[ALL].uri because if there was it seems like it would be generally applicable to lots of different workflows I’d try to build. $99 a month for support is understandable but makes me think I shoud just go back to zapier rather than try to work through this. I’ll post in the community forum and see if there’s any help there.