Google Apps Script – search videos by channel – part 023.
This Google Apps Script tutorial will show you how to search for videos from YouTube.
First, you need to run this script with and YouTube Data A.P.I. and one Spreadsheet.
The script will get the title and id of the first 50 videos info and the result is put into the Shee1.
This is the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | function Search_YouTube_videos_ByChannel() { var results = YouTube.Search.list('id,snippet', { channelId:'UCz75RVbH8q2jdBJ4SnwuZZQ', maxResults: 50 }); var title = ""; var id = ""; var last_row = 0; var spread_active = SpreadsheetApp.getActiveSpreadsheet(); var sheet1 = spread_active.getSheetByName("Sheet1"); for (var i = 0; i < results.items.length; i++) { var item = results.items[i]; title = item.snippet.title; id = item.id.videoId; last_row = sheet1.getLastRow() + 1; sheet1.getRange(last_row, 1).setValue(title); sheet1.getRange(last_row, 2).setValue(id); last_row++; } } |