I'm trying to download all of the videos from a YouTube channel. My original idea was using the YouTube API to get the "uploads" playlist ID (which contains all of the channel's videos), get the video IDs from it (explained here) and then download each video with ytdl.
But, I found the module ytpl, with which I can get all of the video IDs from a playlist, without using the YouTube API. I find it kind of unnecessary to have an API key just to make one request (also, quota), so: is there any way to get every video ID from a user ID (or just the "uploads" playlist ID) with ytdl or another module?
For example, if I pass this channel ID: "UCuAXFkgsw1L7xaCfnd5JJOw"
• it'd give me A. an array of video IDs ([dQw4w9WgXcQ, ...]
•) or B. its "uploads" playlist ID ("UUuAXFkgsw1L7xaCfnd5JJOw"
•).
Here is my original plan:
var baseURL = "https://www.googleapis.com/youtube/v3"
var apiURL1 = `${baseURL}/channels?part=id&id=${channelId}&key=${key}`
request(apiURL1, { json: true }, (err, res, body) => {
const uploads = res.body.items[0].contentDetails.relatedPlaylists.uploads
var apiURL2 = `${baseURL}/playlistItems?part=snippet&playlistId=${uploads}&maxResults=50&key=${key}`
request(apiURL2, { json: true }, (err, res, body) => {
// cycle through pages and get IDs, too lazy to do it but you get the point :P
// then download them with ytdl
}
})
And here is my "goal:"
var uploads = whatever.getPlaylists(channelId).uploads.id // get playlist called "uploads"
ytpl(uploads) // get videos
.then((err, playlist) => {
// download each video with ytdl
})
Or:
var videos = whatever.getAllVideos(channelId)
for (v of videos)
// download with ytdl
Also, I need to get all of the IDs, because in most cases my script will only need to download some videos, not all of them. So a solution like passing ytdl the channel/playlist URL to download all of them won't work.