[Solved] GAS search and download youtube programmatically


You cannot search by duration with such granular detail; you can only provide a filter parameter that searches for “short” (under 4 minutes), “medium” (4 minutes – 20 minutes), or “long” (more than 20 minutes). The parameter is “videoDuration,” so your query function would look like this:

  var results = YouTube.Search.list('id,snippet', {
    q: 'dogs',
    maxResults: 25,
    videoDuration: 'long',
    type: 'video'
  });

EDIT: Note that, when searching by videoDuration, you also have to include the ‘type’ attribute and set it to video.

Additionally, you cannot download YouTube videos; there is no API for this and it is against the terms of service.

2

solved GAS search and download youtube programmatically