Avoid duplicates and 2) Make sure that YouTube API returns limited number of results.
What is the problem & what have you tried?
I’m building an automation where I provide a list of search phrases, then for each phrase the scenario queries YouTube and retrieves up to N video IDs. After that, the videos are analyzed by IA and a summary is emailed to me.
My issue is the following:
In my first module (Set multiple variables), I intentionally provided 2 identical search terms. I would like to understand how I can remove duplicates later, so that any duplicate videos are filtered out. (The reason is that I’m planning to use a long list of search phrases, and if 2 different search phrases return the same video ID, I don’t want to process or analyze those videos twice). I tried to use Aggregator Array after the first HTTP module, setting the first iterator module as the source module and grouping by IDs, but it only returned the first results from each operation (each search phrase).
In addition, after the first HTTP > Make a request module, I added a “Limit items” module to trim the results and keep only the number of videos I need. I noticed that even when I specify the maximum number of results in the YouTube API request, sometimes the API still returns 25 results per search phrase.
Could you please explain me why this situation (extra results) happens and how to properly deduplicate video IDs in this scenario?
(I didn´t include it in the blueprint that I shared, as it didn’t give me the right result).
As for the exceeded number of results (videos IDs) when I do an API call, it doesn´t happen regularly, so I need to wait until it happens again to attach some screenshots here. It normally takes place with 1 or max 2 operations (search queries), and if it fails, it returns maximum 25 results, even if I limit it to 2, 3 or 5 (it never returns 15 or 20 results).
You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.
Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.
Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.
JSON module export — paste this directly in your scenario
Great. Thank you so much for such a detailed and visual explanation. The Set Multiple Variables module helped me a lot to understand how the above mentioned functions work for a complex data structure.
And, actually, it was a great discovery for me that we can call the data as “data.items” (before I thought that we should call the directly as “items”).
No problem, glad I could help with "YouTube search automation: how to avoid duplicates and get a limited number of videos"!
I’d recommend going through the Make Academy if you haven’t yet!
Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —
Save development time and operation credits with these utility modules: Chunk Text; Chunk Array; Chunk Words; Multiple Find & Replace; Collection to Array/String List; Execute JavaScript; Estimate Tokens; Calculate Difference Between Two Dates; Get Next Business Day (with holidays); List Upcoming Dates of Day of Week; and more!